[PATCH] revset: make id() to not abort on an unknown 40-byte string
Martin von Zweigbergk
martinvonz at google.com
Mon Apr 13 09:39:07 CDT 2015
Would "if len(n) == 40 and n in repo:" be better?
On Mon, Apr 13, 2015, 07:06 Yuya Nishihara <yuya at tcha.org> wrote:
> On Mon, 13 Apr 2015 09:11:02 +0300, Alexander Drozdov wrote:
> > # HG changeset patch
> > # User Alexander Drozdov <al.drozdov at gmail.com>
> > # Date 1428905039 -10800
> > # Mon Apr 13 09:03:59 2015 +0300
> > # Node ID c2e3c9bce437a01584e4c32469c0f5d0fcf566d7
> > # Parent 52ff737c63d2b2cb41185549aa9c35bc47317032
> > revset: make id() to not abort on an unknown 40-byte string
> >
> > Instead, just return an empty set in the case as for less-then-40-byte
> > strings.
> >
> > diff --git a/mercurial/revset.py b/mercurial/revset.py
> > --- a/mercurial/revset.py
> > +++ b/mercurial/revset.py
> > @@ -1292,13 +1292,10 @@ def node_(repo, subset, x):
> > l = getargs(x, 1, 1, _("id requires one argument"))
> > # i18n: "id" is a keyword
> > n = getstring(l[0], _("id requires a string"))
> > - if len(n) == 40:
> > - rn = repo[n].rev()
> > - else:
> > - rn = None
> > - pm = repo.changelog._partialmatch(n)
> > - if pm is not None:
> > - rn = repo.changelog.rev(pm)
> > + rn = None
> > + pm = repo.changelog._partialmatch(n)
> > + if pm is not None:
> > + rn = repo.changelog.rev(pm)
>
> I think "len(n) == 40" is necessary to avoid slow _partialmatch().
>
> FWIW, this patch also fixes the bug of 40-byte tag or bookmark.
>
> $ hg tag xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> $ hg log -r 'id(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)'
>
> Regards,
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150413/43623305/attachment.html>
More information about the Mercurial-devel
mailing list