mercurial/rewriteutil.py
changeset 45425 f7e293e0475f
parent 45424 0a57ef4b3bdb
child 45427 78861610ded8
--- a/mercurial/rewriteutil.py	Mon Aug 24 12:43:53 2020 -0400
+++ b/mercurial/rewriteutil.py	Mon Aug 24 18:44:15 2020 -0400
@@ -79,12 +79,18 @@
         )
 
 
-def update_hash_refs(repo, commitmsg):
+def update_hash_refs(repo, commitmsg, pending=None):
     """Replace all obsolete commit hashes in the message with the current hash.
 
     If the obsolete commit was split or is divergent, the hash is not replaced
     as there's no way to know which successor to choose.
+
+    For commands that update a series of commits in the current transaction, the
+    new obsolete markers can be considered by setting ``pending`` to a mapping
+    of ``pending[oldnode] = [successor_node1, successor_node2,..]``.
     """
+    if not pending:
+        pending = {}
     cache = {}
     sha1s = re.findall(sha1re, commitmsg)
     unfi = repo.unfiltered()
@@ -94,9 +100,13 @@
             continue
         ctx = unfi[fullnode]
         if not ctx.obsolete():
-            continue
-
-        successors = obsutil.successorssets(repo, ctx.node(), cache=cache)
+            successors = pending.get(fullnode)
+            if successors is None:
+                continue
+            # obsutil.successorssets() returns a list of list of nodes
+            successors = [successors]
+        else:
+            successors = obsutil.successorssets(repo, ctx.node(), cache=cache)
 
         # We can't make any assumptions about how to update the hash if the
         # cset in question was split or diverged.