diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -857,6 +857,32 @@ def commiteditor(self): return cmdutil.getcommiteditor(edit=True, editform='histedit.mess') +@action(['move', 'v'], + _('move (graft and hide) a changeset from elsewhere')) +class move(histeditaction): + def _verifynodeconstraints(self, prev, expected, seen, basenodes): + if self.node in expected: + msg = _('%s "%s" changeset was an edited list candidate') + raise error.ParseError( + msg % (self.verb, node.short(self.node)), + hint=_('move must only use unlisted changesets')) + repo = self.state.repo + ctx = repo[self.node] + if not ctx.mutable(): + raise error.ParseError( + _('%s "%s" is public') % (self.verb, node.short(self.node)), + hint=_('cannot move public changesets')) + for basenode in basenodes: + ancestors = repo.changelog.commonancestorsheads(ctx.node(), + basenode) + if ctx.node() in ancestors: + msg = _('%s "%s" is an ancestor of base changeset "%s"') + raise error.ParseError( + msg % (self.verb, node.short(self.node), + node.short(basenode)), + hint=_('use histedit with a larger range to move older ' + 'changesets')) + @action(['copy', 'c'], _('copy (graft) a changeset from elsewhere')) class copy(histeditaction): 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 @@ -73,6 +73,7 @@ # c, copy = copy (graft) a changeset from elsewhere # d, drop = remove commit from history # f, fold = use commit, but combine it with the one above + # v, move = move (graft and hide) a changeset from elsewhere # r, roll = like fold, but discard this commit's description and date # @@ -309,6 +310,7 @@ # c, copy = copy (graft) a changeset from elsewhere # d, drop = remove commit from history # f, fold = use commit, but combine it with the one above + # v, move = move (graft and hide) a changeset from elsewhere # r, roll = like fold, but discard this commit's description and date # @@ -546,6 +548,7 @@ # c, copy = copy (graft) a changeset from elsewhere # d, drop = remove commit from history # f, fold = use commit, but combine it with the one above + # v, move = move (graft and hide) a changeset from elsewhere # r, roll = like fold, but discard this commit's description and date # diff --git a/tests/test-histedit-bookmark-motion.t b/tests/test-histedit-bookmark-motion.t --- a/tests/test-histedit-bookmark-motion.t +++ b/tests/test-histedit-bookmark-motion.t @@ -79,6 +79,7 @@ # c, copy = copy (graft) a changeset from elsewhere # d, drop = remove commit from history # f, fold = use commit, but combine it with the one above + # v, move = move (graft and hide) a changeset from elsewhere # r, roll = like fold, but discard this commit's description and date # $ hg histedit 1 --commands - --verbose << EOF | grep histedit @@ -136,6 +137,7 @@ # c, copy = copy (graft) a changeset from elsewhere # d, drop = remove commit from history # f, fold = use commit, but combine it with the one above + # v, move = move (graft and hide) a changeset from elsewhere # r, roll = like fold, but discard this commit's description and date # $ hg histedit 1 --commands - --verbose << EOF | grep histedit diff --git a/tests/test-histedit-commute.t b/tests/test-histedit-commute.t --- a/tests/test-histedit-commute.t +++ b/tests/test-histedit-commute.t @@ -73,6 +73,7 @@ # c, copy = copy (graft) a changeset from elsewhere # d, drop = remove commit from history # f, fold = use commit, but combine it with the one above + # v, move = move (graft and hide) a changeset from elsewhere # r, roll = like fold, but discard this commit's description and date # @@ -352,6 +353,7 @@ # c, copy = copy (graft) a changeset from elsewhere # d, drop = remove commit from history # f, fold = use commit, but combine it with the one above + # v, move = move (graft and hide) a changeset from elsewhere # r, roll = like fold, but discard this commit's description and date # diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t --- a/tests/test-histedit-edit.t +++ b/tests/test-histedit-edit.t @@ -479,5 +479,6 @@ # c, copy = copy (graft) a changeset from elsewhere # d, drop = remove commit from history # f, fold = use commit, but combine it with the one above + # v, move = move (graft and hide) a changeset from elsewhere # r, roll = like fold, but discard this commit's description and date # 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 @@ -135,6 +135,7 @@ # c, copy = copy (graft) a changeset from elsewhere # d, drop = remove commit from history # f, fold = use commit, but combine it with the one above + # v, move = move (graft and hide) a changeset from elsewhere # r, roll = like fold, but discard this commit's description and date # $ hg histedit 1 --commands - --verbose <