[PATCH WIP] bookmarks: add 'hg pull -B .' for pulling the active bookmark (issue5258)

Augie Fackler raf at durin42.com
Thu Jun 9 23:55:27 EDT 2016


On Wed, Jun 01, 2016 at 11:17:13PM +0200, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com>
> # Date 1464814737 -7200
> #      Wed Jun 01 22:58:57 2016 +0200
> # Node ID 2d981ec525ca5c9a85143cbbd9aa1c8951e1d88c
> # Parent  48b38b16a8f83ea98ebdf0b370f59fd90dc17935
> bookmarks: add 'hg pull -B .' for pulling the active bookmark (issue5258)
>
> This solution lacks proper error handling when no bookmark is active.
> It currently aborts in this situation with error:
> abort: remote bookmark . not found!

Would it work to have bookmarks.expandname() throw an exception if it
gets '.' with no active mark? We're reserving the name '.' in all
namespaces now, right?

>
> This situation is similiar to pushing with 'push -B .' where message is:
> bookmark None does not exist on the local or remote repository!
>
> Should those situations be handled in commands.py while extracting
> parameters to push/pull or in bmstore.expandname?
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -5805,6 +5805,7 @@ def pull(ui, repo, source="default", **o
>              remotebookmarks = other.listkeys('bookmarks')
>              pullopargs['remotebookmarks'] = remotebookmarks
>              for b in opts['bookmark']:
> +                b = repo._bookmarks.expandname(b)
>                  if b not in remotebookmarks:
>                      raise error.Abort(_('remote bookmark %s not found!') % b)
>                  revs.append(remotebookmarks[b])
> diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
> --- a/tests/test-bookmarks-pushpull.t
> +++ b/tests/test-bookmarks-pushpull.t
> @@ -353,7 +353,10 @@ Update a bookmark right after the initia
>       X                         1:0d2164f0ce0d
>     * Y                         5:35d1ef0a8d1b
>       Z                         1:0d2164f0ce0d
> -  $ hg pull -B Y
> +  $ hg update -r Y
> +  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  (activating bookmark Y)
> +  $ hg pull -B .
>    pulling from http://localhost:$HGPORT/
>    searching for changes
>    adding changesets
> @@ -363,9 +366,9 @@ Update a bookmark right after the initia
>    updating bookmark Y
>    (run 'hg update' to get a working copy)
>    $ hg book
> -   * @                         1:0d2164f0ce0d
> +     @                         1:0d2164f0ce0d
>       X                         1:0d2164f0ce0d
> -     Y                         5:35d1ef0a8d1b
> +   * Y                         5:35d1ef0a8d1b
>       Z                         1:0d2164f0ce0d
>
>  (done with this section of the test)
> _______________________________________________
> 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