D6567: abort: added support for graft

taapas1128 (Taapas Agrawal) phabricator at mercurial-scm.org
Thu Jul 4 17:07:45 EDT 2019


taapas1128 updated this revision to Diff 15766.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6567?vs=15751&id=15766

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

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/state.py
  tests/test-graft.t

CHANGE DETAILS

diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1,9 +1,18 @@
+#testcases abortcommand abortflag
+
   $ cat >> $HGRCPATH <<EOF
   > [extdiff]
   > # for portability:
   > pdiff = sh "$RUNTESTDIR/pdiff"
   > EOF
 
+#if abortflag
+  $ cat >> $HGRCPATH <<EOF
+  > [alias]
+  > abort = graft --abort
+  > EOF
+#endif
+
 Create a repo with some stuff in it:
 
   $ hg init a
@@ -1986,8 +1995,9 @@
   $ hg up 9150fe93bec6
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
-  $ hg graft --abort
-  abort: no interrupted graft to abort
+  $ hg abort
+  abort: no interrupted graft to abort (abortflag !)
+  abort: no operation in progress (abortcommand !)
   [255]
 
 when stripping is required
@@ -2016,7 +2026,24 @@
   abort: cannot specify any other flag with '--abort'
   [255]
 
-  $ hg graft --abort
+#if abortcommand
+when in dry-run mode
+  $ hg abort --dry-run
+  aborting graft
+
+when in no-backup mode
+  $ hg abort --no-backup
+  abort: graft does not support no-backup flag
+  [255]
+
+when dry-run mode is used with no backup
+  $ hg abort --dry-run --no-backup
+  aborting graft
+  abort: graft does not support no-backup flag
+  [255]
+#endif
+
+  $ hg abort
   graft aborted
   working directory is now at 9150fe93bec6
   $ hg log -GT "{rev}:{node|short} {desc}"
@@ -2041,7 +2068,7 @@
   (use 'hg resolve' and 'hg graft --continue')
   [255]
 
-  $ hg graft --abort
+  $ hg abort
   graft aborted
   working directory is now at 9150fe93bec6
   $ hg log -GT "{rev}:{node|short} {desc}"
@@ -2085,7 +2112,7 @@
   
   $ hg phase -r 6 --public
 
-  $ hg graft --abort
+  $ hg abort
   cannot clean up public changesets 6ec71c037d94
   graft aborted
   working directory is now at 6ec71c037d94
@@ -2162,7 +2189,7 @@
   new changesets 311dfc6cf3bf (1 drafts)
   (run 'hg heads .' to see heads, 'hg merge' to merge)
 
-  $ hg graft --abort
+  $ hg abort
   new changesets detected on destination branch, can't strip
   graft aborted
   working directory is now at 6b98ff0062dd
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -194,11 +194,6 @@
         _unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
-    'graft', fname='graftstate', clearable=True, stopflag=True,
-    continueflag=True,
-    cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
-)
-addunfinished(
     'unshelve', fname='shelvedstate', continueflag=True,
     cmdmsg=_('unshelve already in progress')
 )
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2730,6 +2730,15 @@
     graftstate.delete()
     return 0
 
+def hgabortgraft(ui, repo, **opts):
+    if opts.get('no_backup'):
+        raise error.Abort(_("graft does not support no-backup flag"))
+    if opts.get('dry_run'):
+        return 0
+    with repo.wlock():
+        graftstate = statemod.cmdstate(repo, 'graftstate')
+        return _abortgraft(ui, repo, graftstate)
+
 def _readgraftstate(repo, graftstate):
     """read the graft state file and return a dict of the data stored in it"""
     try:
@@ -2749,6 +2758,12 @@
     ui.status(_("working directory is now at %s\n") % pctx.hex()[:12])
     return 0
 
+statemod.addunfinished(
+    'graft', fname='graftstate', clearable=True, stopflag=True,
+    continueflag=True, abortfunc=hgabortgraft,
+    cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
+)
+
 @command('grep',
     [('0', 'print0', None, _('end fields with NUL')),
     ('', 'all', None, _('print all revisions that match (DEPRECATED) ')),



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


More information about the Mercurial-devel mailing list