[PATCH 02 of 12 V3] bookmarks: rewrite "updatefromremote()" by "compare()"

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue Oct 15 10:35:56 CDT 2013


At Wed, 02 Oct 2013 17:55:03 +0200,
David Soria Parra wrote:
> 
> On 10/02/2013 04:38 PM, FUJIWARA Katsunori wrote:

> > @@ -325,46 +325,42 @@
> >  
> >      return results
> >  
> > +def _diverge(ui, b, path, localmarks):
> > +    if b == '@':
> > +        b = ''
> > +    # find a unique @ suffix
> > +    for x in range(1, 100):
> > +        n = '%s@%d' % (b, x)
> > +        if n not in localmarks:
> > +            break
> > +    # try to use an @pathalias suffix
> > +    # if an @pathalias already exists, we overwrite (update) it
> > +    for p, u in ui.configitems("paths"):
> > +        if path == u:
> > +            n = '%s@%s' % (b, p)
> > +    return n
> 
> We prefer pathaliase over integers, so I think it's better to do.
> If we have a path we never have to start looking for anything else.
> 
> def diverge(....):
>     ....
>     for p, u in ui.configitems("paths"):
>         if path == u:
>             return n = '%s@%s' % (b, p)
> 
>     for x in range(1, 100):
>         n = '%s@%d' % (b, x):
>         if n not in localmarks:
>             return n
>     ...error handling..
> 
> followed by error handling in case we cannot find a proper unique suffix.

Thank you for your comments.

This patch just reused original implementation: for compatibility and
review-ability.

Now, I posted revised series including "_diverge()" improvements below:

    http://selenic.com/pipermail/mercurial-devel/2013-October/054292.html
    http://selenic.com/pipermail/mercurial-devel/2013-October/054295.html
    http://selenic.com/pipermail/mercurial-devel/2013-October/054293.html

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list