[PATCH 05 of 11 RFC] histedit: add support for continuing after an exec

Olle Lundberg olle.lundberg at gmail.com
Wed Mar 5 10:15:16 CST 2014


# HG changeset patch
# User Olle Lundberg <geek at nerd.sh>
# Date 1394034779 -3600
#      Wed Mar 05 16:52:59 2014 +0100
# Node ID cb0ccd948579f1ccbcb39e3749b77268985d0a7b
# Parent  950c8d5b77e8d5eb610cbea159b7c02387bde211
histedit: add support for continuing after an exec

Bail if there are any uncommited changes/merges in the working
directory. Else set the currentnode to the working directories
first parent and let histedit do its magic. Unless the current
node ctx matches the parent ctx, then we can short circuit the
logic since there are no changes and we can just return the
parent with an empty replacements list.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -664,10 +664,28 @@
         os.unlink(repo.sjoin('undo'))
 
 
 def bootstrapcontinue(ui, repo, parentctx, rules, opts):
     action, currentnode = rules.pop(0)
+
+    # track replacements
+    replacements = []
+
+    if action in ('x', 'exec'):
+        # TODO: Do we want to auto-commit anything that the exec did for us?
+        # That would be useful in cases where there is an external tool
+        # modifying commits for us. The auto-commit behaviour is present in
+        # the case when a used have used edit to split/add commits. Whatever
+        # is present in the working dir gets commited.
+        # If the first parent of the working direcroty is the same as the
+        # parentctx from the histedit state, we can short circuit the logic
+        # and just return the parentctx with no replacements.
+        cmdutil.bailifchanged(repo)
+        currentnode = repo[None].p1()
+        if currentnode == parentctx:
+            return parentctx, replacements
+
     ctx = repo[currentnode]
     # is there any new commit between the expected parent and "."
     #
     # note: does not take non linear new change in account (but previous
     #       implementation didn't used them anyway (issue3655)
@@ -698,12 +716,10 @@
                      date=ctx.date(), extra=ctx.extra(),
                      editor=editor)
         if new is not None:
             newchildren.append(new)
 
-    replacements = []
-    # track replacements
     if ctx.node() not in newchildren:
         # note: new children may be empty when the changeset is dropped.
         # this happen e.g during conflicting pick where we revert content
         # to parent.
         replacements.append((ctx.node(), tuple(newchildren)))


More information about the Mercurial-devel mailing list