# HG changeset patch # User Taapas Agrawal # Date 2019-07-15 20:29:28 # Node ID db963eda96ef5041fbc2e5dc923ecc9f05325826 # Parent b53633d3f809370fa209049295fd15754d0a3327 continue: added support for rebase This adds support of rebase to hg continue plan. An independent continue logic for rebase is created under continuerebase() function. For this a seperate rebaseruntime object is created under the function to handle an interrupted rebasestate. Results of tests are shown. Differential Revision: https://phab.mercurial-scm.org/D6646 diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -1928,6 +1928,17 @@ def abortrebase(ui, repo): rbsrt = rebaseruntime(repo, ui) rbsrt._prepareabortorcontinue(isabort=True) +def continuerebase(ui, repo): + with repo.wlock(), repo.lock(): + rbsrt = rebaseruntime(repo, ui) + ms = mergemod.mergestate.read(repo) + mergeutil.checkunresolved(ms) + retcode = rbsrt._prepareabortorcontinue(isabort=False) + if retcode is not None: + return retcode + rbsrt._performrebase(None) + rbsrt._finishrebase() + def summaryhook(ui, repo): if not repo.vfs.exists('rebasestate'): return @@ -1956,4 +1967,5 @@ def uisetup(ui): _("specify merge tool for rebase"))) cmdutil.summaryhooks.add('rebase', summaryhook) statemod.addunfinished('rebase', fname='rebasestate', stopflag=True, - continueflag=True, abortfunc=abortrebase) + continueflag=True, abortfunc=abortrebase, + continuefunc=continuerebase) diff --git a/tests/test-narrow-rebase.t b/tests/test-narrow-rebase.t --- a/tests/test-narrow-rebase.t +++ b/tests/test-narrow-rebase.t @@ -1,3 +1,10 @@ +#testcases continuecommand continueflag +#if continueflag + $ cat >> $HGRCPATH < [alias] + > continue = rebase --continue + > EOF +#endif $ . "$TESTDIR/narrow-library.sh" @@ -69,7 +76,7 @@ Can rebase onto conflicting changes insi $ echo modified3 > inside/f1 $ hg resolve -m 2>&1 | grep -v continue: (no more unresolved files) - $ hg rebase --continue + $ hg continue rebasing 6:cdce97fbf653 "conflicting inside/f1" (tip) saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-rebase.hg (glob) diff --git a/tests/test-rebase-abort.t b/tests/test-rebase-abort.t --- a/tests/test-rebase-abort.t +++ b/tests/test-rebase-abort.t @@ -1,4 +1,5 @@ #testcases abortcommand abortflag +#testcases continuecommand continueflag $ cat >> $HGRCPATH < [extensions] @@ -18,6 +19,13 @@ > EOF #endif +#if continueflag + $ cat >> $HGRCPATH < [alias] + > continue = rebase --continue + > EOF +#endif + $ hg init a $ cd a @@ -162,7 +170,7 @@ earlier than 2.7 by renaming ".hg/rebase $ hg --config extensions.mq= strip --quiet "destination()" $ mv .hg/rebasestate.back .hg/rebasestate - $ hg rebase --continue + $ hg continue abort: cannot continue inconsistent rebase (use "hg rebase --abort" to clear broken state) [255] diff --git a/tests/test-rebase-legacy.t b/tests/test-rebase-legacy.t --- a/tests/test-rebase-legacy.t +++ b/tests/test-rebase-legacy.t @@ -1,3 +1,4 @@ +#testcases continuecommand continueflag Test rebase --continue with rebasestate written by legacy client $ cat >> $HGRCPATH < drawdag=$TESTDIR/drawdag.py > EOF +#if continueflag + $ cat >> $HGRCPATH < [alias] + > continue = rebase --continue + > EOF +#endif + $ hg init $ hg debugdrawdag <<'EOF' > D H @@ -40,7 +48,12 @@ rebasestate generated by a legacy client > 6582e6951a9c48c236f746f186378e36f59f4928:0000000000000000000000000000000000000000 > EOF - $ hg rebase --continue +#if continuecommand + $ hg continue --dry-run + rebase in progress, will be resumed +#endif + + $ hg continue rebasing 4:c1e6b162678d "B" (B) rebasing 8:6f7a236de685 "D" (D) rebasing 2:de008c61a447 "E" (E) diff --git a/tests/test-rebase-mq-skip.t b/tests/test-rebase-mq-skip.t --- a/tests/test-rebase-mq-skip.t +++ b/tests/test-rebase-mq-skip.t @@ -1,3 +1,4 @@ +#testcases continuecommand continueflag This emulates the effects of an hg pull --rebase in which the remote repo already has one local mq patch @@ -13,6 +14,12 @@ already has one local mq patch > tglog = log -G --template "{rev}: {node|short} '{desc}' tags: {tags}\n" > EOF +#if continueflag + $ cat >> $HGRCPATH < [alias] + > continue = rebase --continue + > EOF +#endif $ hg init a $ cd a @@ -155,7 +162,7 @@ already has one local mq patch (no more unresolved files) continue: hg rebase --continue - $ hg rebase --continue + $ hg continue already rebased 1:b4bffa6e4776 "r1" (qbase r1) as 057f55ff8f44 already rebased 2:c0fd129beb01 "r2" (r2) as 1660ab13ce9a already rebased 3:6ff5b8feed8e "r3" (r3) as 1660ab13ce9a diff --git a/tests/test-rebase-transaction.t b/tests/test-rebase-transaction.t --- a/tests/test-rebase-transaction.t +++ b/tests/test-rebase-transaction.t @@ -1,3 +1,4 @@ +#testcases continuecommand continueflag Rebasing using a single transaction $ cat >> $HGRCPATH < tglog = log -G --template "{rev}: {desc}" > EOF +#if continueflag + $ cat >> $HGRCPATH < [alias] + > continue = rebase --continue + > EOF +#endif + Check that a simple rebase works $ hg init simple && cd simple @@ -123,7 +131,7 @@ continued $ hg resolve -m (no more unresolved files) continue: hg rebase --continue - $ hg rebase --continue + $ hg continue already rebased 1:112478962961 "B" (B) as 79bc8f4973ce rebasing 3:c26739dbe603 "C" (C) rebasing 5:d24bb333861c "D" (D tip) @@ -177,7 +185,7 @@ rebase can then be continued |/ o 0: A - $ hg rebase --continue + $ hg continue rebasing 1:112478962961 "B" (B) rebasing 3:26805aba1e60 "C" (C) rebasing 5:f585351a92f8 "D" (D tip)