Mercurial > hg
diff hgext/bookmarks.py @ 12714:f5178fbcd197
bookmarks: add revset for referencing bookmarks
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sun, 10 Oct 2010 12:40:25 -0500 |
parents | 9d45f78c465b |
children | 175fb1b193f4 |
line wrap: on
line diff
--- a/hgext/bookmarks.py Sun Oct 10 12:03:28 2010 -0500 +++ b/hgext/bookmarks.py Sun Oct 10 12:40:25 2010 -0500 @@ -29,8 +29,9 @@ ''' from mercurial.i18n import _ -from mercurial.node import nullid, nullrev, hex, short +from mercurial.node import nullid, nullrev, bin, hex, short from mercurial import util, commands, repair, extensions, pushkey, hg, url +from mercurial import revset import os def write(repo): @@ -536,6 +537,26 @@ setcurrent(repo, rev) return res +def bmrevset(repo, subset, x): + args = revset.getargs(x, 0, 1, _('bookmark takes one or no arguments')) + if args: + bm = revset.getstring(args[0], + _('the argument to bookmark must be a string')) + bmrev = 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 listbookmarks(repo).values()]) + return [r for r in subset if r in bms] +revset.symbols['bookmark'] = bmrevset + +def revsetdoc(): + doc = help.loaddoc('revsets')() + doc += _('\nAdded by the bookmarks extension:\n\n' + '``bookmark([name])``\n' + ' The named bookmark or all bookmarks.\n') + return doc + cmdtable = { "bookmarks": (bookmark,