Mercurial > hg
changeset 39303:1eb370761fa0
revset: expand bookmark(.) to the active bookmark
We do that in several places. I'm not pretty sure if "literal:." should be
expanded or not, so it's disabled for now.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 25 Aug 2018 20:16:28 +0900 |
parents | 11d3cd3f0ae5 |
children | fc54a290b4b0 |
files | mercurial/revset.py tests/test-bookmarks.t |
diffstat | 2 files changed, 36 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Sat Aug 25 15:33:15 2018 +0900 +++ b/mercurial/revset.py Sat Aug 25 20:16:28 2018 +0900 @@ -454,6 +454,8 @@ kind, pattern, matcher = stringutil.stringmatcher(bm) bms = set() if kind == 'literal': + if bm == pattern: + pattern = repo._bookmarks.expandname(pattern) bmrev = repo._bookmarks.get(pattern, None) if not bmrev: raise error.RepoLookupError(_("bookmark '%s' does not exist")
--- a/tests/test-bookmarks.t Sat Aug 25 15:33:15 2018 +0900 +++ b/tests/test-bookmarks.t Sat Aug 25 20:16:28 2018 +0900 @@ -151,6 +151,34 @@ summary: 0 +"." is expanded to the active bookmark: + + $ hg log -r 'bookmark(.)' + changeset: 1:925d80f479bb + bookmark: X2 + tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: 1 + + +but "literal:." is not since "." seems not a literal bookmark: + + $ hg log -r 'bookmark("literal:.")' + abort: bookmark '.' does not exist! + [255] + +"." should fail if there's no active bookmark: + + $ hg bookmark --inactive + $ hg log -r 'bookmark(.)' + abort: no active bookmark + [255] +BUG: this should be resolved to an empty set: + $ hg log -r 'present(bookmark(.))' + abort: no active bookmark + [255] + $ hg log -r 'bookmark(unknown)' abort: bookmark 'unknown' does not exist! [255] @@ -166,6 +194,12 @@ $ hg help revsets | grep 'bookmark(' "bookmark([name])" +reactivate "X2" + + $ hg update X2 + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + (activating bookmark X2) + bookmarks X and X2 moved to rev 1, Y at rev -1 $ hg bookmarks