[PATCH 1 of 4] branchmap: update cache of 'unserved' filter on new changesets

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Jan 15 17:20:28 CST 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1358291288 -3600
# Node ID ce99c3d8f0d8e5c9322c4b777356f75202e90460
# Parent  88a37b19dc0e482b7d6aec386c593a6fae370b96
branchmap: update cache of 'unserved' filter on new changesets

The `commitctx` and `addchangegroup` methods of repo upgrade branchcache after
completion. This behavior aims to keep the branchcache in sync for read only
process as hgweb. See ee317dbfb9d0 for details.

Since changelog filtering is used, those calls only update the cache for unfiltered repo.
One of no interest for typical read only process like hgweb.

Note: By chance in basic case, `repo.unfiltered() == repo.filtered('unserved')`

This changesets have the "unserved" cache updated instead. I think this is the
only cache that matter for hgweb.

We could imagine updating all possible branchcaches instead but:
- I'm not sure it would have any benefit impact. It may even increase the odd of
  all cache being invalidated.
- This is more complicated change.

So I'm going for updating a single cache only which is already better that
updating a cache nobody cares about.

This changeset have a few expected impact on the testsuite are different cache
are updated.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1365,11 +1365,11 @@ class localrepository(object):
                 # be compliant anyway
                 #
                 # if minimal phase was 0 we don't need to retract anything
                 phases.retractboundary(self, targetphase, [n])
             tr.close()
-            branchmap.updatecache(self)
+            branchmap.updatecache(self.filtered('served'))
             return n
         finally:
             if tr:
                 tr.release()
             lock.release()
@@ -2386,11 +2386,11 @@ class localrepository(object):
             if changesets > 0:
                 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)
+                    branchmap.updatecache(self.filtered('served'))
                 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
@@ -577,10 +577,11 @@ Commit and show expansion in original an
 
   $ hg --debug commit -ma2c -d '1 0' -u 'User Name <user at example.com>'
   invalid branchheads cache (served): tip differs
   c
    c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
+  invalid branchheads cache (served): tip differs
   overwriting c expanding keywords
   committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d
   $ cat a c
   expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
   do not process $Id:
@@ -760,11 +761,10 @@ Commit with multi-line message and custo
 | invalid here.
 
   $ hg --debug commit -l log -d '2 0' -u 'User Name <user at example.com>'
   invalid branchheads cache (served): tip differs
   a
-  invalid branchheads cache: tip differs
   invalid branchheads cache (served): tip differs
   overwriting a expanding keywords
   committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
   $ rm log
 
@@ -803,11 +803,10 @@ annotate
 remove with status checks
 
   $ hg debugrebuildstate
   $ hg remove a
   $ hg --debug commit -m rma
-  invalid branchheads cache: tip differs
   committed changeset 3:d14c712653769de926994cf7fbb06c8fbd68f012
   $ hg status
   ? c
 
 Rollback, revert, and check expansion
@@ -916,11 +915,10 @@ kwexpand x/a should abort
   [255]
   $ cd x
   $ hg --debug commit -m xa -d '3 0' -u 'User Name <user at example.com>'
   x/a
    x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
-  invalid branchheads cache: tip differs
   overwriting x/a expanding keywords
   committed changeset 3:b4560182a3f9a358179fd2d835c15e9da379c1e4
   $ cat a
   expand $Id: x/a b4560182a3f9 Thu, 01 Jan 1970 00:00:03 +0000 user $
   do not process $Id:
diff --git a/tests/test-mq-symlinks.t b/tests/test-mq-symlinks.t
--- a/tests/test-mq-symlinks.t
+++ b/tests/test-mq-symlinks.t
@@ -43,10 +43,11 @@ test updating a symlink
   a -> c
   $ hg qpop
   popping updatelink
   now at: symlink.patch
   $ hg qpush --debug
+  invalid branchheads cache (served): tip differs
   applying updatelink
   patching file a
   a
   now at: updatelink
   $ "$TESTDIR/readlink.py" a
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -175,20 +175,30 @@ visible shared between the initial repo 
 
 check that branch cache with "unserved" filter are properly computed and stored
 
   $ ls ../push-dest/.hg/cache/branchheads*
   ../push-dest/.hg/cache/branchheads-served
+  $ cat ../push-dest/.hg/cache/branchheads-served
+  6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722
+  b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e default
+  6d6770faffce199f1fddd1cf87f6f026138cf061 default
+  $ hg heads -R ../push-dest --template '{rev}:{node} {phase}\n'  #update visible cache too
+  6:6d6770faffce199f1fddd1cf87f6f026138cf061 draft
+  5:2713879da13d6eea1ff22b442a5a87cb31a7ce6a secret
+  3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e draft
+  $ ls ../push-dest/.hg/cache/branchheads*
+  ../push-dest/.hg/cache/branchheads-served
   ../push-dest/.hg/cache/branchheads-visible
+  $ cat ../push-dest/.hg/cache/branchheads-served
+  6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722
+  b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e default
+  6d6770faffce199f1fddd1cf87f6f026138cf061 default
   $ cat ../push-dest/.hg/cache/branchheads-visible
   6d6770faffce199f1fddd1cf87f6f026138cf061 6
   b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e default
   2713879da13d6eea1ff22b442a5a87cb31a7ce6a default
   6d6770faffce199f1fddd1cf87f6f026138cf061 default
-  $ cat ../push-dest/.hg/cache/branchheads-served
-  cf9fe039dfd67e829edf6522a45de057b5c86519 4
-  b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e default
-  cf9fe039dfd67e829edf6522a45de057b5c86519 default
 
 
 Restore condition prior extra insertion.
   $ hg -q --config extensions.mq= strip .
   $ hg up -q 7


More information about the Mercurial-devel mailing list