changeset 13359:87f248e78173

bookmarks: move revset support to core
author Matt Mackall <mpm@selenic.com>
date Thu, 10 Feb 2011 13:46:28 -0600
parents f26a51857dc7
children bab5490eb2bc
files hgext/bookmarks.py mercurial/revset.py
diffstat 2 files changed, 21 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/bookmarks.py	Thu Feb 10 13:46:27 2011 -0600
+++ b/hgext/bookmarks.py	Thu Feb 10 13:46:28 2011 -0600
@@ -31,7 +31,7 @@
 from mercurial.i18n import _
 from mercurial.node import nullid, nullrev, bin, hex, short
 from mercurial import util, commands, repair, extensions, pushkey, hg, url
-from mercurial import revset, encoding
+from mercurial import encoding
 from mercurial import bookmarks
 import os
 
@@ -353,27 +353,6 @@
     bookmarks.setcurrent(repo, rev)
     return res
 
-def bmrevset(repo, subset, x):
-    """``bookmark([name])``
-    The named bookmark or all bookmarks.
-    """
-    # i18n: "bookmark" is a keyword
-    args = revset.getargs(x, 0, 1, _('bookmark takes one or no arguments'))
-    if args:
-        bm = revset.getstring(args[0],
-                              # i18n: "bookmark" is a keyword
-                              _('the argument to bookmark must be a string'))
-        bmrev = bookmarks.listbookmarks(repo).get(bm, None)
-        if bmrev:
-            bmrev = repo.changelog.rev(bin(bmrev))
-        return [r for r in subset if r == bmrev]
-    bms = set([repo.changelog.rev(bin(r))
-               for r in bookmarks.listbookmarks(repo).values()])
-    return [r for r in subset if r in bms]
-
-def extsetup(ui):
-    revset.symbols['bookmark'] = bmrevset
-
 cmdtable = {
     "bookmarks":
         (bookmark,
@@ -385,6 +364,3 @@
 }
 
 colortable = {'bookmarks.current': 'green'}
-
-# tell hggettext to extract docstrings from these functions:
-i18nfunctions = [bmrevset]
--- a/mercurial/revset.py	Thu Feb 10 13:46:27 2011 -0600
+++ b/mercurial/revset.py	Thu Feb 10 13:46:28 2011 -0600
@@ -7,6 +7,7 @@
 
 import re
 import parser, util, error, discovery
+import bookmarks as bookmarksmod
 import match as matchmod
 from i18n import _, gettext
 
@@ -664,12 +665,31 @@
 def tagged(repo, subset, x):
     return tag(repo, subset, x)
 
+def bookmark(repo, subset, x):
+    """``bookmark([name])``
+    The named bookmark or all bookmarks.
+    """
+    # i18n: "bookmark" is a keyword
+    args = getargs(x, 0, 1, _('bookmark takes one or no arguments'))
+    if args:
+        bm = getstring(args[0],
+                       # i18n: "bookmark" is a keyword
+                       _('the argument to bookmark must be a string'))
+        bmrev = bookmarksmod.listbookmarks(repo).get(bm, None)
+        if bmrev:
+            bmrev = repo[bmrev].rev()
+        return [r for r in subset if r == bmrev]
+    bms = set([repo[r].rev()
+               for r in bookmarksmod.listbookmarks(repo).values()])
+    return [r for r in subset if r in bms]
+
 symbols = {
     "adds": adds,
     "all": getall,
     "ancestor": ancestor,
     "ancestors": ancestors,
     "author": author,
+    "bookmark": bookmark,
     "branch": branch,
     "children": children,
     "closed": closed,