diff hgext/histedit.py @ 27085:d50ff8f4891f

histedit: add an experimental base action This is a first (very simple) version of the histedit base action. It works well in common usecases like rebasing the whole stack and spliting the stack. I don't see any obvious edge cases - but probably there is more than one. That's why I want to keep it behind experimental.histeditng config knob for now. I think on knob for all new histedit behaviors is better because we will test all of them together and testers will need to turn it on only once to get all new nice things.
author Mateusz Kwapich <mitrandir@fb.com>
date Tue, 17 Nov 2015 15:04:31 -0800
parents 383f10b67fd6
children 5f5c7d9f4a08
line wrap: on
line diff
--- a/hgext/histedit.py	Tue Nov 17 17:53:52 2015 -0800
+++ b/hgext/histedit.py	Tue Nov 17 15:04:31 2015 -0800
@@ -646,6 +646,23 @@
             replacements.append((ich, (n,)))
         return repo[n], replacements
 
+class base(histeditaction):
+    def constraints(self):
+        return set(['forceother'])
+
+    def run(self):
+        if self.repo['.'].node() != self.node:
+            mergemod.update(self.repo, self.node, False, True, False)
+            #                                     branchmerge, force, partial)
+        return self.continueclean()
+
+    def continuedirty(self):
+        abortdirty()
+
+    def continueclean(self):
+        basectx = self.repo['.']
+        return basectx, []
+
 class _multifold(fold):
     """fold subclass used for when multiple folds happen in a row
 
@@ -1291,3 +1308,5 @@
     cmdutil.unfinishedstates.append(
         ['histedit-state', False, True, _('histedit in progress'),
          _("use 'hg histedit --continue' or 'hg histedit --abort'")])
+    if ui.configbool("experimental", "histeditng"):
+        actiontable.update({'b': base, 'base': base})