D817: histedit: add move histedit action

mbthomas (Mark Thomas) phabricator at mercurial-scm.org
Tue Sep 26 10:14:40 UTC 2017


mbthomas created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Add a new `histedit` action: `move`.  This allows moving of changesets from
  outside of the history that is being edited, using the node hash of the other
  changeset.
  
  The changeset is copied to the location in the edited history, and the other
  changeset is removed from the repository if possible.
  
  If removing the other changeset is not possible (for example, if removing
  the changeset would create an orphaned revision, and this is not allowed)
  then the move becomes a copy and a warning is emitted.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-arguments.t
  tests/test-histedit-bookmark-motion.t
  tests/test-histedit-commute.t
  tests/test-histedit-edit.t
  tests/test-histedit-obsolete.t
  tests/test-histedit-outgoing.t

CHANGE DETAILS

diff --git a/tests/test-histedit-outgoing.t b/tests/test-histedit-outgoing.t
--- a/tests/test-histedit-outgoing.t
+++ b/tests/test-histedit-outgoing.t
@@ -55,6 +55,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
   #
   $ cd ..
@@ -90,6 +91,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
   #
   $ cd ..
@@ -117,6 +119,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-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 <<EOF | grep histedit
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-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-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-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/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')
 
+ at 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):



To: mbthomas, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list