[PATCH 1 of 2] bookmarks: don't use bookmarks.listbookmarks in local computations

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sun Jan 27 17:59:32 CST 2013


On 27 janv. 2013, at 22:15, Kevin Bullock wrote:

> # HG changeset patch
> # User Kevin Bullock <kbullock at ringworld.org>
> # Date 1359318277 21600
> # Branch stable
> # Node ID 14fe65a26547fe63963f4e6062b26f07a9443860
> # Parent  b404fa103253960824500066dffa2b7d6cff33ee
> bookmarks: don't use bookmarks.listbookmarks in local computations
> 
> bookmarks.listbookmarks is for wire-protocol use. The normal way to get
> all the bookmarks on a local repository is repo._bookmarks.

repo._bookmarks.values() and bookmarks.listbookmarks(repo) have different returns.
(divergent bookmark are excluded from listbookmarks)

I would make sense to test that neither filtering nor revset ignore them.

Patches (1 and 2) looks good to me otherwise.

> diff --git a/mercurial/repoview.py b/mercurial/repoview.py
> --- a/mercurial/repoview.py
> +++ b/mercurial/repoview.py
> @@ -9,7 +9,7 @@
> import copy
> import phases
> import util
> -import obsolete, bookmarks, revset
> +import obsolete, revset
> 
> 
> def hideablerevs(repo):
> @@ -32,7 +32,7 @@ def computehidden(repo):
>                       if r not in hideable]
>         for par in repo[None].parents():
>             blockers.append(par.rev())
> -        for bm in bookmarks.listbookmarks(repo).values():
> +        for bm in repo._bookmarks.values():
>             blockers.append(repo[bm].rev())
>         blocked = cl.ancestors(blockers, inclusive=True)
>         return frozenset(r for r in hideable if r not in blocked)
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -8,7 +8,6 @@
> import re
> import parser, util, error, discovery, hbisect, phases
> import node
> -import bookmarks as bookmarksmod
> import match as matchmod
> from i18n import _
> import encoding
> @@ -375,14 +374,14 @@ def bookmark(repo, subset, x):
>                        _('the argument to bookmark must be a string'))
>         kind, pattern, matcher = _stringmatcher(bm)
>         if kind == 'literal':
> -            bmrev = bookmarksmod.listbookmarks(repo).get(bm, None)
> +            bmrev = repo._bookmarks.get(bm, None)
>             if not bmrev:
>                 raise util.Abort(_("bookmark '%s' does not exist") % bm)
>             bmrev = repo[bmrev].rev()
>             return [r for r in subset if r == bmrev]
>         else:
>             matchrevs = set()
> -            for name, bmrev in bookmarksmod.listbookmarks(repo).iteritems():
> +            for name, bmrev in repo._bookmarks.iteritems():
>                 if matcher(name):
>                     matchrevs.add(bmrev)
>             if not matchrevs:
> @@ -394,7 +393,7 @@ def bookmark(repo, subset, x):
>             return [r for r in subset if r in bmrevs]
> 
>     bms = set([repo[r].rev()
> -               for r in bookmarksmod.listbookmarks(repo).values()])
> +               for r in repo._bookmarks.values()])
>     return [r for r in subset if r in bms]
> 
> def branch(repo, subset, x):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list