##// END OF EJS Templates
branchmap: make write a method on the branchmap object
Pierre-Yves David -
r18128:f0d56efa default
parent child Browse files
Show More
@@ -42,17 +42,6 b' def read(repo):'
42 42 partial = branchcache()
43 43 return partial
44 44
45 def write(repo, cache):
46 try:
47 f = repo.opener("cache/branchheads", "w", atomictemp=True)
48 f.write("%s %s\n" % (hex(cache.tipnode), cache.tiprev))
49 for label, nodes in cache.iteritems():
50 for node in nodes:
51 f.write("%s %s\n" % (hex(node), encoding.fromlocal(label)))
52 f.close()
53 except (IOError, OSError):
54 pass
55
56 45 def update(repo, partial, ctxgen):
57 46 """Given a branchhead cache, partial, that may have extra nodes or be
58 47 missing heads, and a generator of nodes that are at least a superset of
@@ -133,7 +122,7 b' def updatecache(repo):'
133 122 update(repo, partial, ctxgen)
134 123 partial.tipnode = cl.node(catip)
135 124 partial.tiprev = catip
136 write(repo, partial)
125 partial.write(repo)
137 126 # If cacheable tip were lower than actual tip, we need to update the
138 127 # cache up to tip. This update (from cacheable to actual tip) is not
139 128 # written to disk since it's not cacheable.
@@ -152,3 +141,14 b' class branchcache(dict):'
152 141 super(branchcache, self).__init__(entries)
153 142 self.tipnode = tipnode
154 143 self.tiprev = tiprev
144
145 def write(self, repo):
146 try:
147 f = repo.opener("cache/branchheads", "w", atomictemp=True)
148 f.write("%s %s\n" % (hex(self.tipnode), self.tiprev))
149 for label, nodes in self.iteritems():
150 for node in nodes:
151 f.write("%s %s\n" % (hex(node), encoding.fromlocal(label)))
152 f.close()
153 except (IOError, OSError):
154 pass
@@ -1440,7 +1440,7 b' class localrepository(object):'
1440 1440 branchmap.update(self, cache, ctxgen)
1441 1441 cache.tipnode = self.changelog.tip()
1442 1442 cache.tiprev = self.changelog.rev(cache.tipnode)
1443 branchmap.write(self, cache)
1443 cache.write(self)
1444 1444
1445 1445 # Ensure the persistent tag cache is updated. Doing it now
1446 1446 # means that the tag cache only has to worry about destroyed
@@ -2498,7 +2498,7 b' class localrepository(object):'
2498 2498 self[rtiprev].node(),
2499 2499 rtiprev)
2500 2500 self._branchcache = cache
2501 branchmap.write(self, cache)
2501 cache.write(self)
2502 2502 self.invalidate()
2503 2503 return len(self.heads()) + 1
2504 2504 finally:
General Comments 0
You need to be logged in to leave comments. Login now