Patchwork [1,of,4] subrepo: add shortid() method to subrepo classes

login
register
mail settings
Submitter Angel Ezquerra
Date May 7, 2014, 10:54 p.m.
Message ID <99337cb12ccffe7283da.1399503295@Angel-PC.localdomain>
Download mbox | patch
Permalink /patch/4657/
State Superseded
Headers show

Comments

Angel Ezquerra - May 7, 2014, 10:54 p.m.
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1399414100 -7200
#      Wed May 07 00:08:20 2014 +0200
# Node ID 99337cb12ccffe7283daaa1f117efb5d42211670
# Parent  0768cda8b5799dc803dc0ee27a832cd64e05f28a
subrepo: add shortid() method to subrepo classes

This method takes an "id" (e.g. a revision id) and returns a "short" version
(e.g. a short revision id).

This will be used on the next revision to fix a small bug in the way that the
text on the promptchoice shown when a subrepo diverges is generated.
Pierre-Yves David - May 7, 2014, 11:36 p.m.
On 05/07/2014 03:54 PM, Angel Ezquerra wrote:
> # HG changeset patch
> # User Angel Ezquerra <angel.ezquerra@gmail.com>
> # Date 1399414100 -7200
> #      Wed May 07 00:08:20 2014 +0200
> # Node ID 99337cb12ccffe7283daaa1f117efb5d42211670
> # Parent  0768cda8b5799dc803dc0ee27a832cd64e05f28a
> subrepo: add shortid() method to subrepo classes
>
> This method takes an "id" (e.g. a revision id) and returns a "short" version
> (e.g. a short revision id).
>
> This will be used on the next revision to fix a small bug in the way that the
> text on the promptchoice shown when a subrepo diverges is generated.
>
> diff -r 0768cda8b579 -r 99337cb12ccf mercurial/subrepo.py
> --- a/mercurial/subrepo.py	Tue Apr 29 12:54:01 2014 +0900
> +++ b/mercurial/subrepo.py	Wed May 07 00:08:20 2014 +0200
> @@ -501,6 +501,9 @@
>               % (substate[0], substate[2]))
>           return []
>
> +    def shortid(self, revid):
> +        return revid
> +
>   class hgsubrepo(abstractsubrepo):
>       def __init__(self, ctx, path, state):
>           self._path = path
> @@ -866,6 +869,9 @@
>               pats = []
>           cmdutil.revert(ui, self._repo, ctx, parents, *pats, **opts)
>
> +    def shortid(self, revid):
> +        return revid[:12]
> +
>   class svnsubrepo(abstractsubrepo):
>       def __init__(self, ctx, path, state):
>           self._path = path
> @@ -1561,6 +1567,9 @@
>           deleted = unknown = ignored = clean = []
>           return modified, added, removed, deleted, unknown, ignored, clean
>
> +    def shortid(self, revid):
> +        return revid[:12]

Consider adding diff.showfunc=true to your mercurial config (that adds 
comment in the patch to see what context your are patching)

Also. I suspect git have a 8 char long short version id. Can you double 
check that?
Martin Geisler - May 8, 2014, 6:43 a.m.
Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:

> On 05/07/2014 03:54 PM, Angel Ezquerra wrote:
>> # HG changeset patch
>> # User Angel Ezquerra <angel.ezquerra@gmail.com>
>> # Date 1399414100 -7200
>> #      Wed May 07 00:08:20 2014 +0200
>> # Node ID 99337cb12ccffe7283daaa1f117efb5d42211670
>> # Parent  0768cda8b5799dc803dc0ee27a832cd64e05f28a
>> subrepo: add shortid() method to subrepo classes
>>
>> This method takes an "id" (e.g. a revision id) and returns a "short" version
>> (e.g. a short revision id).
>>
>> This will be used on the next revision to fix a small bug in the way that the
>> text on the promptchoice shown when a subrepo diverges is generated.
>>
>> diff -r 0768cda8b579 -r 99337cb12ccf mercurial/subrepo.py
>> --- a/mercurial/subrepo.py	Tue Apr 29 12:54:01 2014 +0900
>> +++ b/mercurial/subrepo.py	Wed May 07 00:08:20 2014 +0200
>> @@ -501,6 +501,9 @@
>>               % (substate[0], substate[2]))
>>           return []
>>
>> +    def shortid(self, revid):
>> +        return revid
>> +
>>   class hgsubrepo(abstractsubrepo):
>>       def __init__(self, ctx, path, state):
>>           self._path = path
>> @@ -866,6 +869,9 @@
>>               pats = []
>>           cmdutil.revert(ui, self._repo, ctx, parents, *pats, **opts)
>>
>> +    def shortid(self, revid):
>> +        return revid[:12]
>> +
>>   class svnsubrepo(abstractsubrepo):
>>       def __init__(self, ctx, path, state):
>>           self._path = path
>> @@ -1561,6 +1567,9 @@
>>           deleted = unknown = ignored = clean = []
>>           return modified, added, removed, deleted, unknown, ignored, clean
>>
>> +    def shortid(self, revid):
>> +        return revid[:12]
>
> Consider adding diff.showfunc=true to your mercurial config (that adds
> comment in the patch to see what context your are patching)
>
> Also. I suspect git have a 8 char long short version id. Can you
> double check that?

Git normally only shows 7 characters. It has become configurable in
recent versions via the core.abbrev setting.
Angel Ezquerra - May 10, 2014, 9:45 a.m.
On Thu, May 8, 2014 at 8:43 AM, Martin Geisler <martin@geisler.net> wrote:
> Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:
>
>> On 05/07/2014 03:54 PM, Angel Ezquerra wrote:
>>> # HG changeset patch
>>> # User Angel Ezquerra <angel.ezquerra@gmail.com>
>>> # Date 1399414100 -7200
>>> #      Wed May 07 00:08:20 2014 +0200
>>> # Node ID 99337cb12ccffe7283daaa1f117efb5d42211670
>>> # Parent  0768cda8b5799dc803dc0ee27a832cd64e05f28a
>>> subrepo: add shortid() method to subrepo classes
>>>
>>> This method takes an "id" (e.g. a revision id) and returns a "short" version
>>> (e.g. a short revision id).
>>>
>>> This will be used on the next revision to fix a small bug in the way that the
>>> text on the promptchoice shown when a subrepo diverges is generated.
>>>
>>> diff -r 0768cda8b579 -r 99337cb12ccf mercurial/subrepo.py
>>> --- a/mercurial/subrepo.py   Tue Apr 29 12:54:01 2014 +0900
>>> +++ b/mercurial/subrepo.py   Wed May 07 00:08:20 2014 +0200
>>> @@ -501,6 +501,9 @@
>>>               % (substate[0], substate[2]))
>>>           return []
>>>
>>> +    def shortid(self, revid):
>>> +        return revid
>>> +
>>>   class hgsubrepo(abstractsubrepo):
>>>       def __init__(self, ctx, path, state):
>>>           self._path = path
>>> @@ -866,6 +869,9 @@
>>>               pats = []
>>>           cmdutil.revert(ui, self._repo, ctx, parents, *pats, **opts)
>>>
>>> +    def shortid(self, revid):
>>> +        return revid[:12]
>>> +
>>>   class svnsubrepo(abstractsubrepo):
>>>       def __init__(self, ctx, path, state):
>>>           self._path = path
>>> @@ -1561,6 +1567,9 @@
>>>           deleted = unknown = ignored = clean = []
>>>           return modified, added, removed, deleted, unknown, ignored, clean
>>>
>>> +    def shortid(self, revid):
>>> +        return revid[:12]
>>
>> Consider adding diff.showfunc=true to your mercurial config (that adds
>> comment in the patch to see what context your are patching)
>>
>> Also. I suspect git have a 8 char long short version id. Can you
>> double check that?
>
> Git normally only shows 7 characters. It has become configurable in
> recent versions via the core.abbrev setting.

You are right. For example:

git rev-parse --short HEAD

returns a 7 char hash.

However github usually shows 10. Which one do you think we should use?

Angel
Pierre-Yves David - May 10, 2014, 9:56 a.m.
On 05/10/2014 02:45 AM, Angel Ezquerra wrote:
> On Thu, May 8, 2014 at 8:43 AM, Martin Geisler <martin@geisler.net> wrote:
>> Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:
>>
>>> On 05/07/2014 03:54 PM, Angel Ezquerra wrote:
>>>> # HG changeset patch
>>>> # User Angel Ezquerra <angel.ezquerra@gmail.com>
>>>> # Date 1399414100 -7200
>>>> #      Wed May 07 00:08:20 2014 +0200
>>>> # Node ID 99337cb12ccffe7283daaa1f117efb5d42211670
>>>> # Parent  0768cda8b5799dc803dc0ee27a832cd64e05f28a
>>>> subrepo: add shortid() method to subrepo classes
>>>>
>>>> This method takes an "id" (e.g. a revision id) and returns a "short" version
>>>> (e.g. a short revision id).
>>>>
>>>> This will be used on the next revision to fix a small bug in the way that the
>>>> text on the promptchoice shown when a subrepo diverges is generated.
>>>>
>>>> diff -r 0768cda8b579 -r 99337cb12ccf mercurial/subrepo.py
>>>> --- a/mercurial/subrepo.py   Tue Apr 29 12:54:01 2014 +0900
>>>> +++ b/mercurial/subrepo.py   Wed May 07 00:08:20 2014 +0200
>>>> @@ -501,6 +501,9 @@
>>>>                % (substate[0], substate[2]))
>>>>            return []
>>>>
>>>> +    def shortid(self, revid):
>>>> +        return revid
>>>> +
>>>>    class hgsubrepo(abstractsubrepo):
>>>>        def __init__(self, ctx, path, state):
>>>>            self._path = path
>>>> @@ -866,6 +869,9 @@
>>>>                pats = []
>>>>            cmdutil.revert(ui, self._repo, ctx, parents, *pats, **opts)
>>>>
>>>> +    def shortid(self, revid):
>>>> +        return revid[:12]
>>>> +
>>>>    class svnsubrepo(abstractsubrepo):
>>>>        def __init__(self, ctx, path, state):
>>>>            self._path = path
>>>> @@ -1561,6 +1567,9 @@
>>>>            deleted = unknown = ignored = clean = []
>>>>            return modified, added, removed, deleted, unknown, ignored, clean
>>>>
>>>> +    def shortid(self, revid):
>>>> +        return revid[:12]
>>>
>>> Consider adding diff.showfunc=true to your mercurial config (that adds
>>> comment in the patch to see what context your are patching)
>>>
>>> Also. I suspect git have a 8 char long short version id. Can you
>>> double check that?
>>
>> Git normally only shows 7 characters. It has become configurable in
>> recent versions via the core.abbrev setting.
>
> You are right. For example:
>
> git rev-parse --short HEAD
>
> returns a 7 char hash.
>
> However github usually shows 10. Which one do you think we should use?

Lets go for git default: 7

Patch

diff -r 0768cda8b579 -r 99337cb12ccf mercurial/subrepo.py
--- a/mercurial/subrepo.py	Tue Apr 29 12:54:01 2014 +0900
+++ b/mercurial/subrepo.py	Wed May 07 00:08:20 2014 +0200
@@ -501,6 +501,9 @@ 
             % (substate[0], substate[2]))
         return []
 
+    def shortid(self, revid):
+        return revid
+
 class hgsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         self._path = path
@@ -866,6 +869,9 @@ 
             pats = []
         cmdutil.revert(ui, self._repo, ctx, parents, *pats, **opts)
 
+    def shortid(self, revid):
+        return revid[:12]
+
 class svnsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         self._path = path
@@ -1561,6 +1567,9 @@ 
         deleted = unknown = ignored = clean = []
         return modified, added, removed, deleted, unknown, ignored, clean
 
+    def shortid(self, revid):
+        return revid[:12]
+
 types = {
     'hg': hgsubrepo,
     'svn': svnsubrepo,