[PATCH 1 of 9] branchmap: improve invalid cache message when reading

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Dec 26 20:32:57 UTC 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1356273303 -3600
# Node ID 2745467aa74ecaeb7c4c244c65a8e05fb2fc10a9
# Parent  7f5a0eba37683f04bfb2beab62edfd4732b88ea3
branchmap: improve invalid cache message when reading

This factorise the generation of the message. This helps future error reporting
when reading cache for filtered repository.

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -20,25 +20,24 @@ def read(repo):
         last, lrev = lines.pop(0).split(" ", 1)
         last, lrev = bin(last), int(lrev)
         partial = branchcache(tipnode=last, tiprev=lrev)
         if not partial.validfor(repo):
             # invalidate the cache
-            raise ValueError('invalidating branch cache (tip differs)')
+            raise ValueError('(tip differs)')
         for l in lines:
             if not l:
                 continue
             node, label = l.split(" ", 1)
             label = encoding.tolocal(label.strip())
             if not node in repo:
-                raise ValueError('invalidating branch cache because node '+
-                                 '%s does not exist' % node)
+                raise ValueError('node %s does not exist' % node)
             partial.setdefault(label, []).append(bin(node))
     except KeyboardInterrupt:
         raise
     except Exception, inst:
         if repo.ui.debugflag:
-            repo.ui.warn(str(inst), '\n')
+            repo.ui.warn(('invalid branchheads cache: %s\n') % inst)
         partial = branchcache()
     return partial
 
 
 
diff --git a/tests/test-acl.t b/tests/test-acl.t
--- a/tests/test-acl.t
+++ b/tests/test-acl.t
@@ -138,11 +138,11 @@ Extension disabled for lack of acl.sourc
   """
   pushing to ../b
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalidating branch cache (tip differs)
+  invalid branchheads cache: (tip differs)
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -200,11 +200,11 @@ No [acl.allow]/[acl.deny]
   """
   pushing to ../b
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalidating branch cache (tip differs)
+  invalid branchheads cache: (tip differs)
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -272,11 +272,11 @@ Empty [acl.allow]
   """
   pushing to ../b
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalidating branch cache (tip differs)
+  invalid branchheads cache: (tip differs)
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -771,11 +771,11 @@ wilma can change files with a .txt exten
   """
   pushing to ../b
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalidating branch cache (tip differs)
+  invalid branchheads cache: (tip differs)
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -1089,11 +1089,11 @@ fred is always allowed
   """
   pushing to ../b
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalidating branch cache (tip differs)
+  invalid branchheads cache: (tip differs)
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -1165,11 +1165,11 @@ no one is allowed inside foo/Bar/
   """
   pushing to ../b
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalidating branch cache (tip differs)
+  invalid branchheads cache: (tip differs)
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -1317,11 +1317,11 @@ OS-level groups
   """
   pushing to ../b
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalidating branch cache (tip differs)
+  invalid branchheads cache: (tip differs)
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -1515,11 +1515,11 @@ Branch acl deny test
   """
   pushing to ../b
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalidating branch cache (tip differs)
+  invalid branchheads cache: (tip differs)
   listing keys for "bookmarks"
   4 changesets found
   list of changesets:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -1827,11 +1827,11 @@ push foobar into the remote
   """
   pushing to ../b
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalidating branch cache (tip differs)
+  invalid branchheads cache: (tip differs)
   listing keys for "bookmarks"
   4 changesets found
   list of changesets:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -1915,11 +1915,11 @@ Branch acl conflicting deny
   """
   pushing to ../b
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalidating branch cache (tip differs)
+  invalid branchheads cache: (tip differs)
   listing keys for "bookmarks"
   4 changesets found
   list of changesets:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -2071,11 +2071,11 @@ Non-astro users must be denied
   """
   pushing to ../b
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalidating branch cache (tip differs)
+  invalid branchheads cache: (tip differs)
   listing keys for "bookmarks"
   4 changesets found
   list of changesets:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
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,11 @@ 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)
+  invalid branchheads 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 $
diff --git a/tests/test-newbranch.t b/tests/test-newbranch.t
--- a/tests/test-newbranch.t
+++ b/tests/test-newbranch.t
@@ -124,11 +124,11 @@ Test for invalid branch cache:
   summary:     modify a branch
   
   $ cp .hg/bc-invalid $branchcache
 
   $ hg --debug log -r foo
-  invalidating branch cache (tip differs)
+  invalid branchheads cache: (tip differs)
   changeset:   4:adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6
   branch:      foo
   tag:         tip
   phase:       draft
   parent:      1:6c0e42da283a56b5edc5b4fadb491365ec7f5fa8


More information about the Mercurial-devel mailing list