diff hgext/rebase.py @ 45792:1703a7f9d5b8

rebase: update commit hash references in the new commits This excludes the --collapse case because degenerating to p1 is almost certainly as wrong as leaving the old hashes in place. I expect most people to amend the message explicitly when using that. Differential Revision: https://phab.mercurial-scm.org/D9229
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 13 Oct 2020 14:16:21 -0400
parents f90a5c211251
children 89a2afe31e82
line wrap: on
line diff
--- a/hgext/rebase.py	Thu Oct 22 23:35:04 2020 -0700
+++ b/hgext/rebase.py	Tue Oct 13 14:16:21 2020 -0400
@@ -515,6 +515,21 @@
         ctx = repo[rev]
         if commitmsg is None:
             commitmsg = ctx.description()
+
+        # Skip replacement if collapsing, as that degenerates to p1 for all
+        # nodes.
+        if not self.collapsef:
+            cl = repo.changelog
+            commitmsg = rewriteutil.update_hash_refs(
+                repo,
+                commitmsg,
+                {
+                    cl.node(oldrev): [cl.node(newrev)]
+                    for oldrev, newrev in self.state.items()
+                    if newrev != revtodo
+                },
+            )
+
         date = self.date
         if date is None:
             date = ctx.date()