[PATCH 02 of 10 V8] bookmarks: introduce listbookmarks()

Gregory Szorc gregory.szorc at gmail.com
Sat Nov 12 18:41:25 EST 2016


On Sat, Nov 12, 2016 at 12:19 PM, Stanislau Hlebik <stash at fb.com> wrote:

> # HG changeset patch
> # User Stanislau Hlebik <stash at fb.com>
> # Date 1478980589 28800
> #      Sat Nov 12 11:56:29 2016 -0800
> # Branch stable
> # Node ID 13b3e16c68d303a523550980d7739bb676420851
> # Parent  fe9e78883230a875ae7acf6c7a5b324c1d9016f5
> bookmarks: introduce listbookmarks()
>
> `bookmarks` bundle2 part will work with binary nodes.
> To avoid unnecessary conversions between binary and hex nodes
> let's add `listbookmarks()` that returns binary nodes.
>

Between this and part 1, you've introduced API compatibility breakage
without an "(API)" annotation in the commit message.

I'm not sure why you've done it this way. Introducing `listbookmarksbin()`
gets you to a near identical end state without the API breakage.

I'm -0 on the current approach.


>
> diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
> --- a/mercurial/bookmarks.py
> +++ b/mercurial/bookmarks.py
> @@ -284,17 +284,21 @@
>              lockmod.release(tr, lock)
>      return update
>
> -def listhexbookmarks(repo):
> +def listbookmarks(repo):
>      # We may try to list bookmarks on a repo type that does not
>      # support it (e.g., statichttprepository).
>      marks = getattr(repo, '_bookmarks', {})
>
> -    d = {}
>      hasnode = repo.changelog.hasnode
>      for k, v in marks.iteritems():
>          # don't expose local divergent bookmarks
>          if hasnode(v) and ('@' not in k or k.endswith('@')):
> -            d[k] = hex(v)
> +            yield k, v
> +
> +def listhexbookmarks(repo):
> +    d = {}
> +    for book, node in listbookmarks(repo):
> +        d[book] = hex(node)
>      return d
>
>  def pushbookmark(repo, key, old, new):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20161112/11bfa517/attachment.html>


More information about the Mercurial-devel mailing list