[PATCH 4 of 4] bookmarks: accept explicit -r 'wdir()' when adding new bookmarks (issue6218)

Augie Fackler raf at durin42.com
Mon Nov 11 10:52:22 EST 2019


queued, thanks

> On Nov 8, 2019, at 23:51, Yuya Nishihara <yuya at tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1573271756 -32400
> #      Sat Nov 09 12:55:56 2019 +0900
> # Node ID 295870673214e9b41425066559402618893ccd36
> # Parent  3e4a888ce13ae2737ef1facc3d1b00ed6f295e1a
> bookmarks: accept explicit -r 'wdir()' when adding new bookmarks (issue6218)
> 
> Even though the bookmark semantics can't be fully encoded to the virtual
> working changeset idea, the active bookmark can be considered a bookmark
> of the working revision.
> 
> Before, 'tgt' was None, and changes=[(bm, None)] means deleting a bookmark
> named 'bm'.
> 
> diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
> --- a/mercurial/bookmarks.py
> +++ b/mercurial/bookmarks.py
> @@ -958,8 +958,13 @@ def addbookmarks(repo, tr, names, rev=No
>     if rev:
>         repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
> 
> -    ctx = scmutil.revsingle(repo, rev)
> +    ctx = scmutil.revsingle(repo, rev, None)
> +    # bookmarking wdir means creating a bookmark on p1 and activating it
> +    activatenew = not inactive and ctx.rev() is None
> +    if ctx.node() is None:
> +        ctx = ctx.p1()
>     tgt = ctx.node()
> +    assert tgt
> 
>     for mark in names:
>         mark = checkformat(repo, mark)
> @@ -984,7 +989,7 @@ def addbookmarks(repo, tr, names, rev=No
>             repo.ui.warn(b"(%s)\n" % msg)
> 
>     marks.applychanges(repo, tr, changes)
> -    if not inactive and cur == marks[newact] and not rev:
> +    if activatenew and cur == marks[newact]:
>         activate(repo, newact)
>     elif cur != tgt and newact == repo._activebookmark:
>         deactivate(repo)
> diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
> --- a/tests/test-bookmarks.t
> +++ b/tests/test-bookmarks.t
> @@ -619,6 +619,16 @@ deactivate current 'Z', but also add 'Y'
>      x  y                      2:db815d6d32e6
>   $ hg bookmark Z
> 
> +bookmark wdir to activate it (issue6218)
> +
> +  $ hg bookmark -d Z
> +  $ hg bookmark -r 'wdir()' Z
> +  $ hg bookmark -l
> +     X2                        1:925d80f479bb
> +     Y                         2:db815d6d32e6
> +   * Z                         2:db815d6d32e6
> +     x  y                      2:db815d6d32e6
> +
> test clone
> 
>   $ hg bookmark -r 2 -i @
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list