diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5391,6 +5391,7 @@ _(b'REV'), ), (b'B', b'bookmark', [], _(b"bookmark to push"), _(b'BOOKMARK')), + (b'', b'all-bookmarks', None, _(b"push all bookmarks (EXPERIMENTAL)")), ( b'b', b'branch', @@ -5447,7 +5448,8 @@ If -B/--bookmark is used, the specified bookmarked revision, its ancestors, and the bookmark will be pushed to the remote repository. Specifying ``.`` is equivalent to specifying the active - bookmark's name. + bookmark's name. Use the --all-bookmarks option for pushing all + current bookmarks. Please see :hg:`help urls` for important details about ``ssh://`` URLs. If DESTINATION is omitted, a default path will be used. @@ -5475,6 +5477,13 @@ """ opts = pycompat.byteskwargs(opts) + + if opts.get(b'all_bookmarks'): + cmdutil.check_incompatible_arguments( + opts, b'all_bookmarks', [b'bookmark', b'rev'], + ) + opts[b'bookmark'] = list(repo._bookmarks) + if opts.get(b'bookmark'): ui.setconfig(b'bookmarks', b'pushing', opts[b'bookmark'], b'push') for b in opts[b'bookmark']: 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 @@ -1364,3 +1364,33 @@ no changes found (ignored 1 secret changesets) abort: cannot push bookmark foo as it points to a secret changeset [255] + +Test pushing all bookmarks + + $ hg init $TESTTMP/ab1 + $ cd $TESTTMP/ab1 + $ "$PYTHON" $TESTDIR/seq.py 1 5 | while read i; do + > echo $i > test && hg ci -Am test + > done + adding test + $ hg clone -U . ../ab2 + $ hg book -r 1 A; hg book -r 2 B; hg book -r 3 C + $ hg push ../ab2 + pushing to ../ab2 + searching for changes + no changes found + [1] + $ hg push --all-bookmarks -r 1 ../ab2 + abort: cannot specify both --all-bookmarks and --rev + [255] + $ hg push --all-bookmarks -B A ../ab2 + abort: cannot specify both --all-bookmarks and --bookmark + [255] + $ hg push --all-bookmarks ../ab2 + pushing to ../ab2 + searching for changes + no changes found + exporting bookmark A + exporting bookmark B + exporting bookmark C + [1] diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -352,7 +352,7 @@ paths: template phase: public, draft, secret, force, rev pull: update, force, confirm, rev, bookmark, branch, ssh, remotecmd, insecure - push: force, rev, bookmark, branch, new-branch, pushvars, publish, ssh, remotecmd, insecure + push: force, rev, bookmark, all-bookmarks, branch, new-branch, pushvars, publish, ssh, remotecmd, insecure recover: verify remove: after, force, subrepos, include, exclude, dry-run rename: after, at-rev, force, include, exclude, dry-run