Mercurial > public > mercurial-scm > hg
comparison mercurial/branchmap.py @ 18184:8d48af68e2ae
branchmap: read and write key part related to filtered revision
Now that we have a third part for the cache key we need to write and read it on
disk. It is only written when there is filtered revision. This keep the format
compatible with older version.
Notes that, at this state, filtered repository does not use any disk caches yet.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Tue, 01 Jan 2013 18:19:24 +0100 |
parents | c351759ab0a0 |
children | 5a047276764e |
comparison
equal
deleted
inserted
replaced
18183:e1caaeb5a2ed | 18184:8d48af68e2ae |
---|---|
16 f.close() | 16 f.close() |
17 except (IOError, OSError): | 17 except (IOError, OSError): |
18 return branchcache() | 18 return branchcache() |
19 | 19 |
20 try: | 20 try: |
21 last, lrev = lines.pop(0).split(" ", 1) | 21 cachekey = lines.pop(0).split(" ", 2) |
22 last, lrev = cachekey[:2] | |
22 last, lrev = bin(last), int(lrev) | 23 last, lrev = bin(last), int(lrev) |
23 partial = branchcache(tipnode=last, tiprev=lrev) | 24 filteredhash = None |
25 if len(cachekey) > 2: | |
26 filteredhash = bin(cachekey[2]) | |
27 partial = branchcache(tipnode=last, tiprev=lrev, | |
28 filteredhash=filteredhash) | |
24 if not partial.validfor(repo): | 29 if not partial.validfor(repo): |
25 # invalidate the cache | 30 # invalidate the cache |
26 raise ValueError('tip differs') | 31 raise ValueError('tip differs') |
27 for l in lines: | 32 for l in lines: |
28 if not l: | 33 if not l: |
111 | 116 |
112 | 117 |
113 def write(self, repo): | 118 def write(self, repo): |
114 try: | 119 try: |
115 f = repo.opener("cache/branchheads", "w", atomictemp=True) | 120 f = repo.opener("cache/branchheads", "w", atomictemp=True) |
116 f.write("%s %s\n" % (hex(self.tipnode), self.tiprev)) | 121 cachekey = [hex(self.tipnode), str(self.tiprev)] |
122 if self.filteredhash is not None: | |
123 cachekey.append(hex(self.filteredhash)) | |
124 f.write(" ".join(cachekey) + '\n') | |
117 for label, nodes in self.iteritems(): | 125 for label, nodes in self.iteritems(): |
118 for node in nodes: | 126 for node in nodes: |
119 f.write("%s %s\n" % (hex(node), encoding.fromlocal(label))) | 127 f.write("%s %s\n" % (hex(node), encoding.fromlocal(label))) |
120 f.close() | 128 f.close() |
121 except (IOError, OSError): | 129 except (IOError, OSError): |