[PATCH 01 of 10 V2] strip: do not update branchcache when adding un stripped changegroup (issue3745)

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Dec 28 00:56:16 UTC 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1356649360 -3600
# Node ID c5c054b883f2e670c5e7c68fe54627d5d7d21486
# Parent  f23dea2b296e0ec2845fc27746dad6341fa2e338
strip: do not update branchcache when adding un stripped changegroup (issue3745)

At this moment, the cache is invalid and trying to update it will throw it away.
Later the strip function will call the `localrepo.destroyed` method that will
update the branchmap cache.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2393,11 +2393,15 @@ class localrepository(object):
             cl.finalize(trp)
 
             tr.close()
 
             if changesets > 0:
-                branchmap.updatecache(self)
+                if srctype != 'strip':
+                    # During strip, branchcache is invalid but coming call to
+                    # `destroyed` will repair it.
+                    # In other case we can safely update cache on disk.
+                    branchmap.updatecache(self)
                 def runhooks():
                     # forcefully update the on-disk branch cache
                     self.ui.debug("updating the branch cache\n")
                     self.hook("changegroup", node=hex(cl.node(clstart)),
                               source=srctype, url=url)
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -505,11 +505,10 @@ amend
   $ echo amend >> a
   $ echo amend >> b
   $ hg -q commit -d '14 1' -m 'prepare amend'
 
   $ hg --debug commit --amend -d '15 1' -m 'amend without changes' | grep keywords
-  invalidating branch cache (tip differs)
   overwriting a expanding keywords
   $ hg -q id
   67d8c481a6be
   $ head -1 a
   expand $Id: a,v 67d8c481a6be 1970/01/01 00:00:15 test $



More information about the Mercurial-devel mailing list