# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2018-02-09 10:19:46 # Node ID c5687ce3b411410e6e0d2713faa24f2766932d22 # Parent 78c2e9418278c7e9a98090aaa820787caee41289 infinitepush: drop the `--to` flag to push and use `-B` instead The extension added a `--to` flag to specify the bookmark to which revs should be pushed. This patch deletes that flag and instead uses the `-B` flag. After this patch, bookmark passed as `-B` is parsed and if it matches the infinitepush bookmark pattern, we consider that push as infinitepush. This is still not the best of what we can do. Later patches in the series will drop the use of `-B` flag and will instead handle things at bookmark bundle2 part. Plugging these logic to bookmark bundle2 part will also get rid of the scratchbranchparttype bundle2 part. Differential Revision: https://phab.mercurial-scm.org/D2108 diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py --- a/hgext/infinitepush/__init__.py +++ b/hgext/infinitepush/__init__.py @@ -315,9 +315,6 @@ def serverextsetup(ui): def clientextsetup(ui): entry = extensions.wrapcommand(commands.table, 'push', _push) - # Don't add the 'to' arg if it already exists - if not any(a for a in entry[1] if a[1] == 'to'): - entry[1].append(('', 'to', '', _('push revs to this bookmark'))) if not any(a for a in entry[1] if a[1] == 'non-forward-move'): entry[1].append(('', 'non-forward-move', None, @@ -743,7 +740,13 @@ def _findcommonincoming(orig, *args, **k return common, True, remoteheads def _push(orig, ui, repo, dest=None, *args, **opts): - bookmark = opts.get('to') or '' + + bookmark = opts.get('bookmark') + # we only support pushing one infinitepush bookmark at once + if len(bookmark) == 1: + bookmark = bookmark[0] + else: + bookmark = '' oldphasemove = None overrides = {(experimental, configbookmark): bookmark} @@ -759,6 +762,9 @@ def _push(orig, ui, repo, dest=None, *ar ui.setconfig(experimental, confignonforwardmove, opts.get('non_forward_move'), '--non-forward-move') if scratchpush: + # this is an infinitepush, we don't want the bookmark to be applied + # rather that should be stored in the bundlestore + opts['bookmark'] = [] ui.setconfig(experimental, configscratchpush, True) oldphasemove = extensions.wrapfunction(exchange, '_localphasemove', diff --git a/tests/test-infinitepush-bundlestore.t b/tests/test-infinitepush-bundlestore.t --- a/tests/test-infinitepush-bundlestore.t +++ b/tests/test-infinitepush-bundlestore.t @@ -26,7 +26,7 @@ the history but is stored on disk remote: adding file changes remote: added 1 changesets with 1 changes to 1 files $ mkcommit scratchcommit - $ hg push -r . --to scratch/mybranch + $ hg push -r . -B scratch/mybranch pushing to ssh://user@dummy/repo searching for changes remote: pushing 1 commit: @@ -119,7 +119,7 @@ Push to scratch branch $ cd ../client2 $ hg up -q scratch/mybranch $ mkcommit 'new scratch commit' - $ hg push -r . --to scratch/mybranch + $ hg push -r . -B scratch/mybranch pushing to ssh://user@dummy/repo searching for changes remote: pushing 2 commits: @@ -140,7 +140,7 @@ Push to scratch branch scratch/mybranch 1de1d7d92f8965260391d0513fe8a8d5973d3042 Push scratch bookmark with no new revs - $ hg push -r . --to scratch/anotherbranch + $ hg push -r . -B scratch/anotherbranch pushing to ssh://user@dummy/repo searching for changes remote: pushing 2 commits: @@ -216,7 +216,7 @@ Push scratch revision without bookmark w Test with pushrebase $ mkcommit scratchcommitwithpushrebase - $ hg push -r . --to scratch/mybranch + $ hg push -r . -B scratch/mybranch pushing to ssh://user@dummy/repo searching for changes remote: pushing 4 commits: @@ -237,7 +237,7 @@ Test with pushrebase Change the order of pushrebase and infinitepush $ mkcommit scratchcommitwithpushrebase2 - $ hg push -r . --to scratch/mybranch + $ hg push -r . -B scratch/mybranch pushing to ssh://user@dummy/repo searching for changes remote: pushing 5 commits: @@ -300,7 +300,7 @@ Non-fastforward scratch bookmark push $ scratchbookmarks scratch/anotherbranch 1de1d7d92f8965260391d0513fe8a8d5973d3042 scratch/mybranch 6c10d49fe92751666c40263f96721b918170d3da - $ hg push -r . --to scratch/mybranch + $ hg push -r . -B scratch/mybranch pushing to ssh://user@dummy/repo searching for changes remote: non-forward push @@ -308,7 +308,7 @@ Non-fastforward scratch bookmark push abort: push failed on remote [255] - $ hg push -r . --to scratch/mybranch --non-forward-move + $ hg push -r . -B scratch/mybranch --non-forward-move pushing to ssh://user@dummy/repo searching for changes remote: pushing 5 commits: diff --git a/tests/test-infinitepush.t b/tests/test-infinitepush.t --- a/tests/test-infinitepush.t +++ b/tests/test-infinitepush.t @@ -49,7 +49,7 @@ Create two new scratch bookmarks $ hg ci -Am "scratchfirstpart" adding scratchfirstpart created new head - $ hg push -r . --to scratch/firstpart + $ hg push -r . -B scratch/firstpart pushing to ssh://user@dummy/repo searching for changes remote: pushing 1 commit: @@ -60,7 +60,7 @@ Create two new scratch bookmarks $ hg ci -Am "scratchsecondpart" adding scratchsecondpart created new head - $ hg push -r . --to scratch/secondpart + $ hg push -r . -B scratch/secondpart pushing to ssh://user@dummy/repo searching for changes remote: pushing 1 commit: @@ -96,7 +96,7 @@ Make two commits to the scratch branch $ hg log -r '.' -T '{node}\n' > ../testpullbycommithash1 $ echo testpullbycommithash2 > testpullbycommithash2 $ hg ci -Aqm "testpullbycommithash2" - $ hg push -r . --to scratch/mybranch -q + $ hg push -r . -B scratch/mybranch -q Create third client and pull by commit hash. Make sure testpullbycommithash2 has not fetched @@ -144,7 +144,7 @@ Make sure phase on the client is public. 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ echo scratchontopofpublic > scratchontopofpublic $ hg ci -Aqm "scratchontopofpublic" - $ hg push -r . --to scratch/scratchontopofpublic + $ hg push -r . -B scratch/scratchontopofpublic pushing to ssh://user@dummy/repo searching for changes remote: pushing 1 commit: @@ -300,7 +300,7 @@ Test infinitepush.fillmetadatabranchpatt $ hg ci -Aqm "tofillmetadata" $ hg log -r . -T '{node}\n' d2b0410d4da084bc534b1d90df0de9eb21583496 - $ hg push -r . --to scratch/fillmetadata/fill + $ hg push -r . -B scratch/fillmetadata/fill pushing to ssh://user@dummy/repo searching for changes remote: pushing 6 commits: