# HG changeset patch # User Kevin Bullock # Date 1292087335 -3600 # Node ID 9029b1a38c306e5c362d5c276d39eb5ee4ebc0f4 # Parent 9bbaafddfa9010748b61b51a10334d781242df65 bookmarks: allow to create/move bookmark without making it current (issue2788) Adds a -i/--inactive flag to the bookmarks command to create or move a bookmark without making it the current one. This lets you use a bookmark like a shareable, movable 'tag' and less like a 'branch'. Thanks to Alexander Solovyov for most of the work of implementation, and Matt Mackall for suggesting the option name. diff -r 9bbaafddfa90 -r 9029b1a38c30 mercurial/commands.py --- a/mercurial/commands.py Thu May 05 01:57:13 2011 +0200 +++ b/mercurial/commands.py Sat Dec 11 18:08:55 2010 +0100 @@ -483,7 +483,8 @@ cmdutil.bail_if_changed(repo) return hg.clean(repo, node) -def bookmark(ui, repo, mark=None, rev=None, force=False, delete=False, rename=None): +def bookmark(ui, repo, mark=None, rev=None, force=False, delete=False, + rename=None, inactive=False): '''track a line of development with movable markers Bookmarks are pointers to certain commits that move when @@ -514,7 +515,7 @@ if mark is None: raise util.Abort(_("new bookmark name required")) marks[mark] = marks[rename] - if repo._bookmarkcurrent == rename: + if repo._bookmarkcurrent == rename and not inactive: bookmarks.setcurrent(repo, mark) del marks[rename] bookmarks.write(repo) @@ -549,7 +550,7 @@ marks[mark] = repo.lookup(rev) else: marks[mark] = repo.changectx('.').node() - if repo.changectx('.').node() == marks[mark]: + if not inactive and repo.changectx('.').node() == marks[mark]: bookmarks.setcurrent(repo, mark) bookmarks.write(repo) return @@ -4469,8 +4470,9 @@ [('f', 'force', False, _('force')), ('r', 'rev', '', _('revision'), _('REV')), ('d', 'delete', False, _('delete a given bookmark')), - ('m', 'rename', '', _('rename a given bookmark'), _('NAME'))], - _('hg bookmarks [-f] [-d] [-m NAME] [-r REV] [NAME]')), + ('m', 'rename', '', _('rename a given bookmark'), _('NAME')), + ('i', 'inactive', False, _('do not mark a new bookmark active'))], + _('hg bookmarks [-f] [-d] [-i] [-m NAME] [-r REV] [NAME]')), "branch": (branch, [('f', 'force', None, diff -r 9bbaafddfa90 -r 9029b1a38c30 tests/test-bookmarks-current.t --- a/tests/test-bookmarks-current.t Thu May 05 01:57:13 2011 +0200 +++ b/tests/test-bookmarks-current.t Sat Dec 11 18:08:55 2010 +0100 @@ -99,3 +99,10 @@ $ hg bookmark * Y 0:719295282060 + +set bookmark Z using -i + + $ hg bookmark -r . -i Z + $ hg bookmarks + * Y 0:719295282060 + Z 0:719295282060