Patchwork [09,of,10,V2] branchmap: report filtername when read fails

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 28, 2012, 12:56 a.m.
Message ID <cf84b46c2a1a4914ecac.1356656184@yamac.lan>
Download mbox | patch
Permalink /patch/314/
State Superseded, archived
Commit 46ed5226503a3f53194773a57f2e46ba315d6518
Headers show

Comments

Pierre-Yves David - Dec. 28, 2012, 12:56 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1356188217 -3600
# Node ID cf84b46c2a1a4914ecac9659e15c34111aab6022
# Parent  427da70a9d079c6ef91408bad67070fc4c1441ff
branchmap: report filtername when read fails

Now that we can have multiple one, we need to know which filecache failed to be
read from disk.
Augie Fackler - Jan. 1, 2013, 12:19 a.m.
On Dec 27, 2012, at 7:56 PM, Pierre-Yves David <pierre-yves.david at ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1356188217 -3600
> # Node ID cf84b46c2a1a4914ecac9659e15c34111aab6022
> # Parent  427da70a9d079c6ef91408bad67070fc4c1441ff
> branchmap: report filtername when read fails
> 
> Now that we can have multiple one, we need to know which filecache failed to be
> read from disk.
> 
> diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
> --- a/mercurial/branchmap.py
> +++ b/mercurial/branchmap.py
> @@ -46,11 +46,14 @@ def read(repo):
>             partial.setdefault(label, []).append(bin(node))
>     except KeyboardInterrupt:
>         raise
>     except Exception, inst:
>         if repo.ui.debugflag:
> -            repo.ui.warn(('invalid branchheads cache: %s\n') % inst)
> +            msg = 'invalid branchheads cache: %s\n'
> +            if repo.filtername is not None:
> +                msg = 'invalid branchheads cache (%s): %%s\n' % repo.filtername

Double % formatting this weirds me out intensely. Can we do something like this instead?

  extra = ''
  if repo.filtername:
    extra = ' (' + repo.filtername + ')'
  msg % (extra, inst)

or similar?

> +            repo.ui.warn(msg % inst)
>         partial = branchcache()
>     return partial
> 
> 
>
Pierre-Yves David - Jan. 1, 2013, 10:12 p.m.
On 1 janv. 2013, at 01:19, Augie Fackler wrote:

> 
> On Dec 27, 2012, at 7:56 PM, Pierre-Yves David <pierre-yves.david at ens-lyon.org> wrote:
> 
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
>> # Date 1356188217 -3600
>> # Node ID cf84b46c2a1a4914ecac9659e15c34111aab6022
>> # Parent  427da70a9d079c6ef91408bad67070fc4c1441ff
>> branchmap: report filtername when read fails
>> 
>> Now that we can have multiple one, we need to know which filecache failed to be
>> read from disk.
>> 
>> diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
>> --- a/mercurial/branchmap.py
>> +++ b/mercurial/branchmap.py
>> @@ -46,11 +46,14 @@ def read(repo):
>>            partial.setdefault(label, []).append(bin(node))
>>    except KeyboardInterrupt:
>>        raise
>>    except Exception, inst:
>>        if repo.ui.debugflag:
>> -            repo.ui.warn(('invalid branchheads cache: %s\n') % inst)
>> +            msg = 'invalid branchheads cache: %s\n'
>> +            if repo.filtername is not None:
>> +                msg = 'invalid branchheads cache (%s): %%s\n' % repo.filtername
> 
> Double % formatting this weirds me out intensely. Can we do something like this instead?
> 
>  extra = ''
>  if repo.filtername:
>    extra = ' (' + repo.filtername + ')'
>  msg % (extra, inst)
> 
> or similar?

I'm ok with them, but I'll send a V3 with no %%

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -46,11 +46,14 @@  def read(repo):
             partial.setdefault(label, []).append(bin(node))
     except KeyboardInterrupt:
         raise
     except Exception, inst:
         if repo.ui.debugflag:
-            repo.ui.warn(('invalid branchheads cache: %s\n') % inst)
+            msg = 'invalid branchheads cache: %s\n'
+            if repo.filtername is not None:
+                msg = 'invalid branchheads cache (%s): %%s\n' % repo.filtername
+            repo.ui.warn(msg % inst)
         partial = branchcache()
     return partial