[PATCH 1 of 1] Use tag dict code from tags.py

Benoit Boissinot bboissin at gmail.com
Wed Jun 9 02:23:58 CDT 2010


On Wed, Jun 9, 2010 at 9:13 AM, David Soria Parra <dsoria at gmx.net> wrote:
>
>>> diff --git a/hgext/bookmarks.py b/hgext/bookmarks.py
>>> --- a/hgext/bookmarks.py
>>> +++ b/hgext/bookmarks.py
>>> @@ -29,7 +29,7 @@
>>>  '''
>>>
>>>  from mercurial.i18n import _
>>> -from mercurial.node import nullid, nullrev, hex, short
>>> +from mercurial.node import nullid, nullrev, hex, short, bin
>>>  from mercurial import util, commands, repair, extensions
>>>  import os
>>>
>>> @@ -218,7 +218,9 @@
>>>                 bookmarks = {}
>>>                 for line in self.opener('bookmarks'):
>>>                     sha, refspec = line.strip().split(' ', 1)
>>> -                    bookmarks[refspec] = super(bookmark_repo, self).lookup(sha)
>>> +                    nodebin = bin(sha)
>>> +                    if nodebin in self.changelog.nodemap:
>>> +                        bookmarks[refspec] = nodebin
>>>             except:
>>>                 pass
>>>             return bookmarks
>>
>> Ah, nice. Do we have a guarantee that the file doesn't have some other
>> revision specifier (like a rev or a tag or something else)? As you
>> might be aware, 'lookup' allows a much wider range of input.
> If you read and write the bookmarks store file through the API, it is
> safe to use bin() instead of lookup. We do the lookup when we create the
> bookmark and store just the sha1. Using other revision specifier is
> theoretically possible, but editing the bookmarks store by hand is
> discouraged and I personally think we can safely remove this behavior
> and use bin instead.
>
On the other hand, I'm surprised there's a noticable slowdown, as
lookup() is heavily used and optimizes the case where it's passed a
full hex string.

Friedrich, do you benchmark numbers to show the difference with your
patch applied?

Benoit


More information about the Mercurial-devel mailing list