[PATCH 5 of 6] update: add switch to move active bookmark forward

Idan Kamara idankk86 at gmail.com
Wed Dec 7 12:21:26 CST 2011


On Wed, Dec 7, 2011 at 7:40 PM, Kevin Bullock <
kbullock+mercurial at ringworld.org> wrote:

> # HG changeset patch
> # User Kevin Bullock <kbullock at ringworld.org>
> # Date 1321481586 21600
> # Node ID 6bab2e0693916ee9160f41dc9fe52b9d7304de54
> # Parent  1917c90be9b026cc5aeff849a07045f38e221be7
> update: add switch to move active bookmark forward
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -5586,9 +5586,11 @@
>     ('c', 'check', None,
>      _('update across branches if no uncommitted changes')),
>     ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
> -    ('r', 'rev', '', _('revision'), _('REV'))],
> +    ('r', 'rev', '', _('revision'), _('REV')),
> +    ('B', 'bookmark', None, _('move the active bookmark forward'))],
>     _('[-c] [-C] [-d DATE] [[-r] REV]'))
> -def update(ui, repo, node=None, rev=None, clean=False, date=None,
> check=False):
> +def update(ui, repo, node=None, rev=None, clean=False, date=None,
> check=False,
> +           bookmark=False):
>     """update working directory (or switch revisions)
>
>     Update the repository's working directory to the specified
> @@ -5604,6 +5606,9 @@
>     Update sets the working directory's parent revison to the specified
>     changeset (see :hg:`help parents`).
>
> +    With -B/--bookmark, the active bookmark will be moved forward along
> +    with the update.
> +
>     The following rules apply when the working directory contains
>     uncommitted changes:
>
> @@ -5656,6 +5661,14 @@
>             raise util.Abort(_("you can't specify a revision and a date"))
>         rev = cmdutil.finddate(ui, repo, date)
>
> +    old = repo['.']
> +    if bookmark:
> +        if repo._bookmarks[repo._bookmarkcurrent] != old.node():
> +            raise util.Abort(_("no active bookmark"))
> +        if not bookmarks.updatecurrentbookmark(repo, old.node(),
> +                                               repo['.'].branch()):


This will always move the bookmark to the tip of the current branch, but
the user might
want to update to a different head.

$ hg glog
o  2 - foo
|
| o  1
|/
@  0

$ hg upd -B 1
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg glog
o  2 - foo
|
| @  1
|/
o  0

I think you can just call bookmarks.update instead and pass `rev` to it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20111207/e282b92b/attachment.html>


More information about the Mercurial-devel mailing list