Mercurial > hg
changeset 42583:b9bc47211cf5
abort: added support for rebase
This adds support of `rebase` to `hg abort` plan.
An independent abort logic for `rebase` is created
under `abortrebase()` function. For this a seperate
`rebaseruntime` object is created under the function to
handle an unfinished `rebasestate` and abort that using
abort logic under `_prepareabortorcontinue`.
Results of tests are shown.
Differential Revision: https://phab.mercurial-scm.org/D6568
author | Taapas Agrawal <taapas2897@gmail.com> |
---|---|
date | Sun, 23 Jun 2019 23:11:35 +0530 |
parents | 5171937ad0f9 |
children | db5560c07a28 |
files | hgext/rebase.py tests/test-rebase-abort.t |
diffstat | 2 files changed, 27 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/rebase.py Sun Jun 23 22:31:31 2019 +0530 +++ b/hgext/rebase.py Sun Jun 23 23:11:35 2019 +0530 @@ -1923,6 +1923,11 @@ obsoleteextinctsuccessors, ) +def abortrebase(ui, repo): + with repo.wlock(), repo.lock(): + rbsrt = rebaseruntime(repo, ui) + rbsrt._prepareabortorcontinue(isabort=True) + def summaryhook(ui, repo): if not repo.vfs.exists('rebasestate'): return @@ -1951,4 +1956,4 @@ _("specify merge tool for rebase"))) cmdutil.summaryhooks.add('rebase', summaryhook) statemod.addunfinished('rebase', fname='rebasestate', stopflag=True, - continueflag=True) + continueflag=True, abortfunc=abortrebase)
--- a/tests/test-rebase-abort.t Sun Jun 23 22:31:31 2019 +0530 +++ b/tests/test-rebase-abort.t Sun Jun 23 23:11:35 2019 +0530 @@ -1,3 +1,5 @@ +#testcases abortcommand abortflag + $ cat >> $HGRCPATH <<EOF > [extensions] > rebase= @@ -9,6 +11,12 @@ > tglog = log -G --template "{rev}:{phase} '{desc}' {branches}\n" > EOF +#if abortflag + $ cat >> $HGRCPATH <<EOF + > [alias] + > abort = rebase --abort + > EOF +#endif $ hg init a $ cd a @@ -114,7 +122,13 @@ Abort (should clear out unsupported merge state): - $ hg rebase --abort +#if abortcommand +when in dry-run mode + $ hg abort --dry-run + rebase in progress, will be aborted +#endif + + $ hg abort saved backup bundle to $TESTTMP/a/.hg/strip-backup/3e046f2ecedb-6beef7d5-backup.hg rebase aborted $ hg debugmergestate @@ -154,7 +168,7 @@ [255] $ hg summary | grep '^rebase: ' rebase: (use "hg rebase --abort" to clear broken state) - $ hg rebase --abort + $ hg abort rebase aborted (no revision is removed, only broken state is cleared) $ cd .. @@ -271,7 +285,7 @@ warning: conflicts while merging c! (edit, then use 'hg resolve --mark') unresolved conflicts (see hg resolve, then hg rebase --continue) [1] - $ hg rebase --abort + $ hg abort rebase aborted $ hg log -G --template "{rev} {desc} {bookmarks}" @ 3 C foo @@ -324,7 +338,7 @@ $ cat a new - $ hg rebase --abort + $ hg abort rebase aborted $ cat a new @@ -405,7 +419,7 @@ (use 'hg rebase --continue' or 'hg rebase --abort') [255] - $ hg rebase --abort + $ hg abort saved backup bundle to $TESTTMP/interrupted/.hg/strip-backup/3d8812cf300d-93041a90-backup.hg rebase aborted $ hg log -G --template "{rev} {desc} {bookmarks}" @@ -456,7 +470,7 @@ rebasing 2:e4ea5cdc9789 "conflicting 1" unresolved conflicts (see hg resolve, then hg rebase --continue) [1] - $ hg rebase --abort + $ hg abort rebase aborted $ hg summary parent: 3:b16646383533 tip @@ -497,7 +511,7 @@ warning: conflicts while merging root! (edit, then use 'hg resolve --mark') unresolved conflicts (see hg resolve, then hg rebase --continue) [1] - $ hg rebase --abort + $ hg abort rebase aborted $ cd ..