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

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 26, 2012, 8:32 p.m.
Message ID <2745467aa74ecaeb7c4c.1356553977@yamac.local>
Download mbox | patch
Permalink /patch/298/
State Superseded, archived
Commit 3a2e810dd3d85e18d214598c6f41d54fe3529ee7
Headers show

Comments

Pierre-Yves David - Dec. 26, 2012, 8:32 p.m.
# 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.
Kevin Bullock - Dec. 27, 2012, 4:43 p.m.
On Dec 26, 2012, at 2:32 PM, Pierre-Yves David wrote:

> # 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
       factors out
> 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)

1. Choose either this colon, or parentheses around the message on inst, but not both.
2. Shouldn't we be using ui.debug() here?
3. Am I recalling correctly that we don't translate debug messages? If so, the inner parentheses are unnecessary. If not, you're missing an underscore before them.

pacem in terris / ??? / ?????? / ????????? / ??
Kevin R. Bullock
Pierre-Yves David - Dec. 27, 2012, 5:12 p.m.
On 27 d?c. 2012, at 17:43, Kevin Bullock wrote:

> On Dec 26, 2012, at 2:32 PM, Pierre-Yves David wrote:
> 
>>    except Exception, inst:
>>        if repo.ui.debugflag:
>> -            repo.ui.warn(str(inst), '\n')
>> +            repo.ui.warn(('invalid branchheads cache: %s\n') % inst)
> 
> 1. Choose either this colon, or parentheses around the message on inst, but not both.

I'll drop the parantheses in the exception message, they do not belong here.

> 2. Shouldn't we be using ui.debug() here?

No, we want that written on stderr

> 3. Am I recalling correctly that we don't translate debug messages? If so, the inner parentheses are unnecessary. If not, you're missing an underscore before them.

We do not translate debug message. check code requires those inner parentheses to distinguish that from real error.

Patch

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