Patchwork context: make warning message for hidden revision extensible

login
register
mail settings
Submitter Laurent Charignon
Date May 4, 2015, 7:57 p.m.
Message ID <0136dbe8f026cb0a3f80.1430769470@lcharignon-mbp.local>
Download mbox | patch
Permalink /patch/8871/
State Accepted
Headers show

Comments

Laurent Charignon - May 4, 2015, 7:57 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1430761125 25200
#      Mon May 04 10:38:45 2015 -0700
# Node ID 0136dbe8f026cb0a3f8035136d79f8cc05c72857
# Parent  e9edd53770fb77a9787a3e6592a3bf0a29c1bd80
context: make warning message for hidden revision extensible

Extensions might want to create new filternames and change what revisions
are considered hidden or shown. This is the case for inhibit that enables
direct access to hidden hashes with the visible-directaccess-nowarn filtername.
By using startswith instead of a direct comparison with 'visible' we
allow extensions to do that and not work directly on the 'visible' filtername
used by core.
Pierre-Yves David - May 4, 2015, 10:12 p.m.
On 05/04/2015 12:57 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1430761125 25200
> #      Mon May 04 10:38:45 2015 -0700
> # Node ID 0136dbe8f026cb0a3f8035136d79f8cc05c72857
> # Parent  e9edd53770fb77a9787a3e6592a3bf0a29c1bd80
> context: make warning message for hidden revision extensible
>
> Extensions might want to create new filternames and change what revisions
> are considered hidden or shown. This is the case for inhibit that enables
> direct access to hidden hashes with the visible-directaccess-nowarn filtername.
> By using startswith instead of a direct comparison with 'visible' we
> allow extensions to do that and not work directly on the 'visible' filtername
> used by core.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -459,7 +459,7 @@
>                   pass
>           except (error.FilteredIndexError, error.FilteredLookupError,
>                   error.FilteredRepoLookupError):
> -            if repo.filtername == 'visible':
> +            if repo.filtername.startswith('visible'):
>                   msg = _("hidden revision '%s'") % changeid
>                   hint = _('use --hidden to access hidden revisions')
>                   raise error.FilteredRepoLookupError(msg, hint=hint)

This change looks small enough to me to be reasonable. I'll let someone 
else queue it.
Matt Mackall - May 4, 2015, 10:25 p.m.
On Mon, 2015-05-04 at 12:57 -0700, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1430761125 25200
> #      Mon May 04 10:38:45 2015 -0700
> # Node ID 0136dbe8f026cb0a3f8035136d79f8cc05c72857
> # Parent  e9edd53770fb77a9787a3e6592a3bf0a29c1bd80
> context: make warning message for hidden revision extensible

Queued for default, thanks.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -459,7 +459,7 @@ 
                 pass
         except (error.FilteredIndexError, error.FilteredLookupError,
                 error.FilteredRepoLookupError):
-            if repo.filtername == 'visible':
+            if repo.filtername.startswith('visible'):
                 msg = _("hidden revision '%s'") % changeid
                 hint = _('use --hidden to access hidden revisions')
                 raise error.FilteredRepoLookupError(msg, hint=hint)