D6567: abort: added support for graft
taapas1128 (Taapas Agrawal)
phabricator at mercurial-scm.org
Sat Jul 6 18:50:19 UTC 2019
taapas1128 edited the summary of this revision.
taapas1128 updated this revision to Diff 15779.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D6567?vs=15766&id=15779
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D6567/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D6567
AFFECTED FILES
mercurial/cmdutil.py
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,22 @@
abort: cannot specify any other flag with '--abort'
[255]
- $ hg graft --abort
+#if abortcommand
+when in dry-run mode
+ $ hg abort --dry-run
+ graft in progress, will be aborted
+
+when in no-backup mode
+ $ hg abort --no-backup
+ abort: aborting graft does not support no-backup flag
+ [255]
+
+when dry-run mode is used with no backup
+ $ hg abort --dry-run --no-backup
+ graft in progress, will be aborted
+#endif
+
+ $ hg abort
graft aborted
working directory is now at 9150fe93bec6
$ hg log -GT "{rev}:{node|short} {desc}"
@@ -2041,7 +2066,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 +2110,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 +2187,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
@@ -2686,6 +2686,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=cmdutil.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) ')),
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3411,3 +3411,10 @@
nodes = repo.vfs.read('graftstate').splitlines()
return {'nodes': nodes}
+def hgabortgraft(ui, repo, **opts):
+ """ abort logic for aborting graft using 'hg abort'"""
+ if opts.get('no_backup'):
+ raise error.Abort(_("aborting graft does not support no-backup flag"))
+ with repo.wlock():
+ graftstate = statemod.cmdstate(repo, 'graftstate')
+ return _abortgraft(ui, repo, graftstate)
To: taapas1128, #hg-reviewers
Cc: pulkit, mercurial-devel
More information about the Mercurial-devel
mailing list