##// END OF EJS Templates
branchmap: stop writing cache for uncommitted data...
marmoute -
r49526:8e5effbf stable
parent child Browse files
Show More
@@ -149,6 +149,13 b' class BranchMapCache(object):'
149 def clear(self):
149 def clear(self):
150 self._per_filter.clear()
150 self._per_filter.clear()
151
151
152 def write_delayed(self, repo):
153 unfi = repo.unfiltered()
154 for filtername, cache in self._per_filter.items():
155 if cache._delayed:
156 repo = unfi.filtered(filtername)
157 cache.write(repo)
158
152
159
153 def _unknownnode(node):
160 def _unknownnode(node):
154 """raises ValueError when branchcache found a node which does not exists"""
161 """raises ValueError when branchcache found a node which does not exists"""
@@ -199,6 +206,7 b' class branchcache(object):'
199 has a given node or not. If it's not provided, we assume that every node
206 has a given node or not. If it's not provided, we assume that every node
200 we have exists in changelog"""
207 we have exists in changelog"""
201 self._repo = repo
208 self._repo = repo
209 self._delayed = False
202 if tipnode is None:
210 if tipnode is None:
203 self.tipnode = repo.nullid
211 self.tipnode = repo.nullid
204 else:
212 else:
@@ -403,6 +411,13 b' class branchcache(object):'
403 )
411 )
404
412
405 def write(self, repo):
413 def write(self, repo):
414 tr = repo.currenttransaction()
415 if not getattr(tr, 'finalized', True):
416 # Avoid premature writing.
417 #
418 # (The cache warming setup by localrepo will update the file later.)
419 self._delayed = True
420 return
406 try:
421 try:
407 f = repo.cachevfs(self._filename(repo), b"w", atomictemp=True)
422 f = repo.cachevfs(self._filename(repo), b"w", atomictemp=True)
408 cachekey = [hex(self.tipnode), b'%d' % self.tiprev]
423 cachekey = [hex(self.tipnode), b'%d' % self.tiprev]
@@ -427,6 +442,7 b' class branchcache(object):'
427 len(self._entries),
442 len(self._entries),
428 nodecount,
443 nodecount,
429 )
444 )
445 self._delayed = False
430 except (IOError, OSError, error.Abort) as inst:
446 except (IOError, OSError, error.Abort) as inst:
431 # Abort may be raised by read only opener, so log and continue
447 # Abort may be raised by read only opener, so log and continue
432 repo.ui.debug(
448 repo.ui.debug(
@@ -2830,6 +2830,8 b' class localrepository(object):'
2830 self.ui.debug(b'updating the branch cache\n')
2830 self.ui.debug(b'updating the branch cache\n')
2831 self.filtered(b'served').branchmap()
2831 self.filtered(b'served').branchmap()
2832 self.filtered(b'served.hidden').branchmap()
2832 self.filtered(b'served.hidden').branchmap()
2833 # flush all possibly delayed write.
2834 self._branchcaches.write_delayed(self)
2833
2835
2834 if repository.CACHE_CHANGELOG_CACHE in caches:
2836 if repository.CACHE_CHANGELOG_CACHE in caches:
2835 self.changelog.update_caches(transaction=tr)
2837 self.changelog.update_caches(transaction=tr)
@@ -1336,7 +1336,5 b' aborted Unbundle should not update the o'
1336 abort: pretxnclose hook failed
1336 abort: pretxnclose hook failed
1337 [40]
1337 [40]
1338 $ cat branchmap-update-02/.hg/cache/branch2-served
1338 $ cat branchmap-update-02/.hg/cache/branch2-served
1339 99ba08759bc7f6fdbe5304e83d0387f35c082479 1 (missing-correct-output !)
1339 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
1340 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A (missing-correct-output !)
1340 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
1341 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 3 (known-bad-output !)
1342 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 o A (known-bad-output !)
General Comments 0
You need to be logged in to leave comments. Login now