D6568: abort: added support for rebase

taapas1128 (Taapas Agrawal) phabricator at mercurial-scm.org
Sat Jul 6 14:49:23 EDT 2019


taapas1128 edited the summary of this revision.
taapas1128 updated this revision to Diff 15780.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6568?vs=15767&id=15780

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6568/new/

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-abort.t

CHANGE DETAILS

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,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,22 @@
 
 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
+
+when in no-backup mode
+  $ hg abort --no-backup
+  abort: aborting rebase does not support no-backup flag
+  [255]
+
+when dry-run mode is used with no backup
+  $ hg abort --dry-run --no-backup
+  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 +177,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 +294,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 +347,7 @@
 
   $ cat a
   new
-  $ hg rebase --abort
+  $ hg abort
   rebase aborted
   $ cat a
   new
@@ -405,7 +428,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 +479,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 +520,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
-  rebase aborted
-  $ cd ..
-
+  $ hg abort
+  rebase aborted
+  $ cd ..
+
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1923,6 +1923,14 @@
         obsoleteextinctsuccessors,
     )
 
+def abortrebase(ui, repo, **opts):
+    if opts.get('no_backup'):
+        raise error.Abort(_("aborting rebase does not support no-backup flag"))
+    with repo.wlock(), repo.lock():
+        rbsrt = rebaseruntime(repo, ui)
+        rbsrt._prepareabortorcontinue(isabort=True, backup=True,
+                                      suppwarns=False)
+
 def summaryhook(ui, repo):
     if not repo.vfs.exists('rebasestate'):
         return
@@ -1951,4 +1959,4 @@
                      _("specify merge tool for rebase")))
     cmdutil.summaryhooks.add('rebase', summaryhook)
     statemod.addunfinished('rebase', fname='rebasestate', stopflag=True,
-                            continueflag=True)
+                            continueflag=True, abortfunc=abortrebase)



To: taapas1128, martinvonz, #hg-reviewers
Cc: pulkit, mercurial-devel


More information about the Mercurial-devel mailing list