[PATCH 4 of 5] histedit: convert pick action into a class
Durham Goode
durham at fb.com
Tue Apr 14 18:35:21 UTC 2015
# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1428172748 25200
# Sat Apr 04 11:39:08 2015 -0700
# Node ID cc333abf57472637a5d33f0df2869cbe0bad0bde
# Parent 0428c284052ea07c09ff8043c38c5acb2a750da9
histedit: convert pick action into a class
This converts the pick action into a histeditclass instance, as part of an
ongoing effort to refactor histedit for maintainability and robustness.
The test output changed because previously pick would only report the commit
disappearing if there were no merge conflicts. Now that we've unified the normal
and the --continue flows, they act the same and we get the warning even after
--continue.
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -420,28 +420,14 @@ def collapse(repo, first, last, commitop
editor=editor)
return repo.commitctx(new)
-def pick(ui, state, ha, opts):
- repo, ctxnode = state.repo, state.parentctxnode
- ctx = repo[ctxnode]
- oldctx = repo[ha]
- if oldctx.parents()[0] == ctx:
- ui.debug('node %s unchanged\n' % ha[:12])
- return oldctx, []
- hg.update(repo, ctx.node())
- stats = applychanges(ui, repo, oldctx, opts)
- if stats and stats[3] > 0:
- raise error.InterventionRequired(_('Fix up the change and run '
- 'hg histedit --continue'))
- # drop the second merge parent
- commit = commitfuncfor(repo, oldctx)
- n = commit(text=oldctx.description(), user=oldctx.user(),
- date=oldctx.date(), extra=oldctx.extra())
- if n is None:
- ui.warn(_('%s: empty changeset\n') % ha[:12])
- return ctx, []
- new = repo[n]
- return new, [(oldctx.node(), (n,))]
+class pick(histeditaction):
+ def run(self):
+ rulectx = self.repo[self.node]
+ if rulectx.parents()[0].node() == self.state.parentctxnode:
+ self.repo.ui.debug('node %s unchanged\n' % node.short(self.node))
+ return rulectx, []
+ return super(pick, self).run()
def edit(ui, state, ha, opts):
repo, ctxnode = state.repo, state.parentctxnode
@@ -855,7 +841,7 @@ def bootstrapcontinue(ui, state, opts):
else:
message = ctx.description()
editopt = action in ('e', 'edit', 'm', 'mess')
- canonaction = {'e': 'edit', 'm': 'mess', 'p': 'pick'}
+ canonaction = {'e': 'edit', 'm': 'mess'}
editform = 'histedit.%s' % canonaction.get(action, action)
editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
commit = commitfuncfor(repo, ctx)
diff --git a/tests/test-histedit-fold-non-commute.t b/tests/test-histedit-fold-non-commute.t
--- a/tests/test-histedit-fold-non-commute.t
+++ b/tests/test-histedit-fold-non-commute.t
@@ -132,6 +132,7 @@ just continue this time
$ hg resolve --mark e
(no more unresolved files)
$ hg histedit --continue 2>&1 | fixbundle
+ 7b4e2f4b7bcd: empty changeset
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -274,6 +275,7 @@ just continue this time
$ hg resolve --mark e
(no more unresolved files)
$ hg histedit --continue 2>&1 | fixbundle
+ 7b4e2f4b7bcd: empty changeset
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
diff --git a/tests/test-histedit-non-commute.t b/tests/test-histedit-non-commute.t
--- a/tests/test-histedit-non-commute.t
+++ b/tests/test-histedit-non-commute.t
@@ -170,6 +170,7 @@ just continue this time
$ hg resolve --mark e
(no more unresolved files)
$ hg histedit --continue 2>&1 | fixbundle
+ 7b4e2f4b7bcd: empty changeset
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -253,6 +254,7 @@ second edit also fails, but just continu
$ hg resolve --mark e
(no more unresolved files)
$ hg histedit --continue 2>&1 | fixbundle
+ 7b4e2f4b7bcd: empty changeset
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
More information about the Mercurial-devel
mailing list