Mercurial > hg
changeset 12714:f5178fbcd197
bookmarks: add revset for referencing bookmarks
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sun, 10 Oct 2010 12:40:25 -0500 |
parents | bd37e7492478 |
children | 33820dccbea4 |
files | hgext/bookmarks.py tests/test-bookmarks.t |
diffstat | 2 files changed, 44 insertions(+), 1 deletions(-) [+] |
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,
--- a/tests/test-bookmarks.t Sun Oct 10 12:03:28 2010 -0500 +++ b/tests/test-bookmarks.t Sun Oct 10 12:40:25 2010 -0500 @@ -62,6 +62,28 @@ $ hg add b $ hg commit -m 1 +bookmarks revset + + $ hg log -r 'bookmark()' + changeset: 1:925d80f479bb + tag: X + tag: X2 + tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: 1 + + $ hg log -r 'bookmark(Y)' + $ hg log -r 'bookmark(X2)' + changeset: 1:925d80f479bb + tag: X + tag: X2 + tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: 1 + + bookmarks X and X2 moved to rev 1, Y at rev -1 $ hg bookmarks