D6582: abort: added support for histedit

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


taapas1128 updated this revision to Diff 15782.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6582?vs=15769&id=15782

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

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

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-arguments.t
  tests/test-histedit-no-backup.t
  tests/test-histedit-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -1,3 +1,12 @@
+#testcases abortcommand abortflag
+
+#if abortflag
+  $ cat >> $HGRCPATH <<EOF
+  > [alias]
+  > abort = histedit --abort
+  > EOF
+#endif
+
   $ . "$TESTDIR/histedit-helpers.sh"
 
 Enable obsolete
@@ -522,7 +531,17 @@
   (hg histedit --continue to resume)
   [1]
 
-  $ hg histedit --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  histedit in progress, will be aborted
+
+when dry-run mode is used with no backup
+  $ hg abort --dry-run --no-backup
+  histedit in progress, will be aborted
+#endif
+
+  $ hg abort
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to $TESTTMP/abort/.hg/strip-backup/4dc06258baa6-dff4ef05-backup.hg
 
diff --git a/tests/test-histedit-no-backup.t b/tests/test-histedit-no-backup.t
--- a/tests/test-histedit-no-backup.t
+++ b/tests/test-histedit-no-backup.t
@@ -1,3 +1,12 @@
+#testcases abortcommand abortflag
+
+#if abortflag
+  $ cat >> $HGRCPATH <<EOF
+  > [alias]
+  > abort = histedit --abort
+  > EOF
+#endif
+
   $ . "$TESTDIR/histedit-helpers.sh"
 
 Enable extension used by this test
@@ -44,17 +53,19 @@
   Editing (7d5187087c79), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
-  $ hg histedit --abort
+  $ hg abort
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to $TESTTMP/foo/.hg/strip-backup/1d8f701c7b35-cf7be322-backup.hg
   saved backup bundle to $TESTTMP/foo/.hg/strip-backup/5c0056670bce-b54b65d0-backup.hg
 
 Test when `backup-bundle` config option is not enabled
 Enable config option:
+#if abortflag
   $ cat >>$HGRCPATH <<EOF
   > [rewrite]
   > backup-bundle = False
   > EOF
+#endif
 
   $ hg histedit -r '36b4bdd91f5b' --commands - << EOF
   > pick 36b4bdd91f5b 0 one
@@ -66,5 +77,10 @@
   Editing (7d5187087c79), you may commit or record as needed now.
   (hg histedit --continue to resume)
   [1]
+#if abortflag
   $ hg histedit --abort
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#else
+  $ hg abort --no-backup
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+#endif
diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -1,3 +1,12 @@
+#testcases abortcommand abortflag
+
+#if abortflag
+  $ cat >> $HGRCPATH <<EOF
+  > [alias]
+  > abort = histedit --abort
+  > EOF
+#endif
+
 Test argument handling and various data parsing
 ==================================================
 
@@ -47,8 +56,9 @@
   $ hg histedit --continue
   abort: no histedit in progress
   [255]
-  $ hg histedit --abort
-  abort: no histedit in progress
+  $ hg abort
+  abort: no histedit in progress (abortflag !)
+  abort: no operation in progress (abortcommand !)
   [255]
 
 Run a dummy edit to make sure we get tip^^ correctly via revsingle.
@@ -358,7 +368,7 @@
 Corrupt histedit state file
   $ sed 's/8fda0c726bf2/123456789012/' .hg/histedit-state > ../corrupt-histedit
   $ mv ../corrupt-histedit .hg/histedit-state
-  $ hg histedit --abort
+  $ hg abort
   warning: encountered an exception during histedit --abort; the repository may not have been completely cleaned up
   abort: $TESTTMP/foo/.hg/strip-backup/*-histedit.hg: $ENOENT$ (glob) (windows !)
   abort: $ENOENT$: '$TESTTMP/foo/.hg/strip-backup/*-histedit.hg' (glob) (no-windows !)
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1919,6 +1919,16 @@
     finally:
             state.clear()
 
+def hgaborthistedit(ui, repo, **opts):
+    state = histeditstate(repo)
+    nobackup = False
+    if opts.get('no_backup'):
+        nobackup = True
+    with repo.wlock() as wlock, repo.lock() as lock:
+        state.wlock = wlock
+        state.lock = lock
+        _aborthistedit(ui, repo, state, nobackup=nobackup)
+
 def _edithisteditplan(ui, repo, state, rules):
     state.read()
     if not rules:
@@ -2314,5 +2324,5 @@
 def extsetup(ui):
     cmdutil.summaryhooks.add('histedit', summaryhook)
     statemod.addunfinished('histedit', fname='histedit-state', allowcommit=True,
-                            continueflag=True)
-
+                            continueflag=True, abortfunc=hgaborthistedit)
+



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


More information about the Mercurial-devel mailing list