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

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 28, 2012, 12:56 a.m.
Message ID <c5c054b883f2e670c5e7.1356656176@yamac.lan>
Download mbox | patch
Permalink /patch/306/
State Accepted
Headers show

Comments

Pierre-Yves David - Dec. 28, 2012, 12:56 a.m.
# 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.

Patch

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 $