Patchwork [08,of,12] context: use labels instead of hardcoding tags and bookmarks

login
register
mail settings
Submitter Sean Farley
Date Aug. 18, 2014, 9:18 p.m.
Message ID <5e3722e0076cc2a3c927.1408396684@1.0.0.127.in-addr.arpa>
Download mbox | patch
Permalink /patch/5466/
State Changes Requested
Headers show

Comments

Sean Farley - Aug. 18, 2014, 9:18 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1396309619 18000
#      Mon Mar 31 18:46:59 2014 -0500
# Node ID 5e3722e0076cc2a3c92758ff762e2916ce05e569
# Parent  80fe2f84bc7a0d327aac7456eec8e996a3d3488d
context: use labels instead of hardcoding tags and bookmarks
Pierre-Yves David - Aug. 21, 2014, 7:56 a.m.
On 08/18/2014 02:18 PM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1396309619 18000
> #      Mon Mar 31 18:46:59 2014 -0500
> # Node ID 5e3722e0076cc2a3c92758ff762e2916ce05e569
> # Parent  80fe2f84bc7a0d327aac7456eec8e996a3d3488d
> context: use labels instead of hardcoding tags and bookmarks
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -424,18 +424,15 @@ class changectx(basectx):
>                   self._rev = repo.changelog.rev(self._node)
>                   return
>               except (TypeError, LookupError):
>                   pass
>
> -        if changeid in repo._bookmarks:
> -            self._node = repo._bookmarks[changeid]
> -            self._rev = repo.changelog.rev(self._node)
> -            return
> -        if changeid in repo._tagscache.tags:
> -            self._node = repo._tagscache.tags[changeid]
> -            self._rev = repo.changelog.rev(self._node)
> -            return
> +        for namespace, labels in repo.alllabels().iteritems():
> +            if changeid in labels:
> +                self._node = labels[changeid]
> +                self._rev = repo.changelog.rev(self._node)
> +                return

This means that resolution is done in namespace alphabetical order this 
should probably be highlighted sooner and louder


>           try:
>               self._node = repo.branchtip(changeid)
>               self._rev = repo.changelog.rev(self._node)
>               return
>           except error.RepoLookupError:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
Sean Farley - Aug. 21, 2014, 6:23 p.m.
Pierre-Yves David writes:

> On 08/18/2014 02:18 PM, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley@gmail.com>
>> # Date 1396309619 18000
>> #      Mon Mar 31 18:46:59 2014 -0500
>> # Node ID 5e3722e0076cc2a3c92758ff762e2916ce05e569
>> # Parent  80fe2f84bc7a0d327aac7456eec8e996a3d3488d
>> context: use labels instead of hardcoding tags and bookmarks
>>
>> diff --git a/mercurial/context.py b/mercurial/context.py
>> --- a/mercurial/context.py
>> +++ b/mercurial/context.py
>> @@ -424,18 +424,15 @@ class changectx(basectx):
>>                   self._rev = repo.changelog.rev(self._node)
>>                   return
>>               except (TypeError, LookupError):
>>                   pass
>>
>> -        if changeid in repo._bookmarks:
>> -            self._node = repo._bookmarks[changeid]
>> -            self._rev = repo.changelog.rev(self._node)
>> -            return
>> -        if changeid in repo._tagscache.tags:
>> -            self._node = repo._tagscache.tags[changeid]
>> -            self._rev = repo.changelog.rev(self._node)
>> -            return
>> +        for namespace, labels in repo.alllabels().iteritems():
>> +            if changeid in labels:
>> +                self._node = labels[changeid]
>> +                self._rev = repo.changelog.rev(self._node)
>> +                return
>
> This means that resolution is done in namespace alphabetical order this 
> should probably be highlighted sooner and louder

Ah, I think I see what you mean now. Previously, we preferred bookmarks,
then tags. Now it's alphabetical. Yes, that should be, at the very
least, documented in a comment.
Pierre-Yves David - Aug. 21, 2014, 7:30 p.m.
On 08/21/2014 11:23 AM, Sean Farley wrote:
>
> Pierre-Yves David writes:
>
>> On 08/18/2014 02:18 PM, Sean Farley wrote:
>>> # HG changeset patch
>>> # User Sean Farley <sean.michael.farley@gmail.com>
>>> # Date 1396309619 18000
>>> #      Mon Mar 31 18:46:59 2014 -0500
>>> # Node ID 5e3722e0076cc2a3c92758ff762e2916ce05e569
>>> # Parent  80fe2f84bc7a0d327aac7456eec8e996a3d3488d
>>> context: use labels instead of hardcoding tags and bookmarks
>>>
>>> diff --git a/mercurial/context.py b/mercurial/context.py
>>> --- a/mercurial/context.py
>>> +++ b/mercurial/context.py
>>> @@ -424,18 +424,15 @@ class changectx(basectx):
>>>                    self._rev = repo.changelog.rev(self._node)
>>>                    return
>>>                except (TypeError, LookupError):
>>>                    pass
>>>
>>> -        if changeid in repo._bookmarks:
>>> -            self._node = repo._bookmarks[changeid]
>>> -            self._rev = repo.changelog.rev(self._node)
>>> -            return
>>> -        if changeid in repo._tagscache.tags:
>>> -            self._node = repo._tagscache.tags[changeid]
>>> -            self._rev = repo.changelog.rev(self._node)
>>> -            return
>>> +        for namespace, labels in repo.alllabels().iteritems():
>>> +            if changeid in labels:
>>> +                self._node = labels[changeid]
>>> +                self._rev = repo.changelog.rev(self._node)
>>> +                return
>>
>> This means that resolution is done in namespace alphabetical order this
>> should probably be highlighted sooner and louder
>
> Ah, I think I see what you mean now. Previously, we preferred bookmarks,
> then tags. Now it's alphabetical. Yes, that should be, at the very
> least, documented in a comment.

at the very list yes. I think there is a whole help topic on specifying 
revision. It should probably be updated too.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -424,18 +424,15 @@  class changectx(basectx):
                 self._rev = repo.changelog.rev(self._node)
                 return
             except (TypeError, LookupError):
                 pass
 
-        if changeid in repo._bookmarks:
-            self._node = repo._bookmarks[changeid]
-            self._rev = repo.changelog.rev(self._node)
-            return
-        if changeid in repo._tagscache.tags:
-            self._node = repo._tagscache.tags[changeid]
-            self._rev = repo.changelog.rev(self._node)
-            return
+        for namespace, labels in repo.alllabels().iteritems():
+            if changeid in labels:
+                self._node = labels[changeid]
+                self._rev = repo.changelog.rev(self._node)
+                return
         try:
             self._node = repo.branchtip(changeid)
             self._rev = repo.changelog.rev(self._node)
             return
         except error.RepoLookupError: