bookmarks: don't use bookmarks.listbookmarks in local computations stable
authorKevin Bullock <kbullock@ringworld.org>
Sun, 27 Jan 2013 14:24:37 -0600
branchstable
changeset 18495 8260fa9f30b9
parent 18494 e945bcb87973
child 18496 d1c13a4dc638
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.
mercurial/repoview.py
mercurial/revset.py
tests/test-bookmarks-pushpull.t
tests/test-log.t
--- a/mercurial/repoview.py	Mon Jan 28 20:25:56 2013 -0600
+++ b/mercurial/repoview.py	Sun Jan 27 14:24:37 2013 -0600
@@ -9,7 +9,7 @@
 import copy
 import phases
 import util
-import obsolete, bookmarks, revset
+import obsolete, revset
 
 
 def hideablerevs(repo):
@@ -32,7 +32,7 @@
                       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)
--- a/mercurial/revset.py	Mon Jan 28 20:25:56 2013 -0600
+++ b/mercurial/revset.py	Sun Jan 27 14:24:37 2013 -0600
@@ -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 @@
                        _('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 @@
             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):
--- a/tests/test-bookmarks-pushpull.t	Mon Jan 28 20:25:56 2013 -0600
+++ b/tests/test-bookmarks-pushpull.t	Sun Jan 27 14:24:37 2013 -0600
@@ -171,6 +171,18 @@
      Y                         0:4e3505fd9583
      Z                         1:0d2164f0ce0d
 
+revsets should not ignore divergent bookmarks
+
+  $ hg bookmark -fr 1 Z
+  $ hg log -r 'bookmark()' --template '{rev}:{node|short} {bookmarks}\n'
+  0:4e3505fd9583 Y
+  1:9b140be10808 @ X Z foobar
+  2:0d2164f0ce0d @foo X@foo
+  $ hg log -r 'bookmark("X@foo")' --template '{rev}:{node|short} {bookmarks}\n'
+  2:0d2164f0ce0d @foo X@foo
+  $ hg log -r 'bookmark("re:X@foo")' --template '{rev}:{node|short} {bookmarks}\n'
+  2:0d2164f0ce0d @foo X@foo
+
 update a remote bookmark from a non-head to a head
 
   $ hg up -q Y
@@ -299,7 +311,7 @@
   @	9b140be1080824d768c5a4691a564088eede71f9
   X	9b140be1080824d768c5a4691a564088eede71f9
   Y	c922c0139ca03858f655e4a2af4dd02796a63969
-  Z	0d2164f0ce0d8f1d6f94351eba04b794909be66c
+  Z	9b140be1080824d768c5a4691a564088eede71f9
   foo	0000000000000000000000000000000000000000
   foobar	9b140be1080824d768c5a4691a564088eede71f9
   $ hg out -B http://localhost:$HGPORT/
--- a/tests/test-log.t	Mon Jan 28 20:25:56 2013 -0600
+++ b/tests/test-log.t	Sun Jan 27 14:24:37 2013 -0600
@@ -1210,6 +1210,14 @@
   $ hg log --template '{rev}:{node}\n'
   1:a765632148dc55d38c35c4f247c618701886cb2f
   0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
+  $ hg bookmark -d X
+
+divergent bookmarks are not hidden
+
+  $ hg bookmark --hidden -r 1 X@foo
+  $ hg log --template '{rev}:{node}\n'
+  1:a765632148dc55d38c35c4f247c618701886cb2f
+  0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
 
 clear extensions configuration
   $ echo '[extensions]' >> $HGRCPATH