Patchwork D9261: push: add --all-bookmarks option

login
register
mail settings
Submitter phabricator
Date Oct. 29, 2020, 1:17 p.m.
Message ID <differential-rev-PHID-DREV-tytayb5xguv7lho3ie36-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47532/
State Superseded
Headers show

Comments

phabricator - Oct. 29, 2020, 1:17 p.m.
danchr created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D9261

AFFECTED FILES
  mercurial/commands.py
  tests/test-bookmarks-pushpull.t

CHANGE DETAILS




To: danchr, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5385,6 +5385,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',
@@ -5441,7 +5442,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.
@@ -5469,6 +5471,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']: