rewriteutil: handle dropped commits when updating description hashes
In looking to leverage this with the absorb extension, the old -> new mapping
there allows the new value to be None. We could filter that out and not pass it
to this method, but it seems worth a message to the user. (I wonder if these
should be an info or warning, because it's unlikely people are using `-v`
regularly.)
Differential Revision: https://phab.mercurial-scm.org/D9181
--- a/mercurial/rewriteutil.py Fri Oct 09 10:20:53 2020 +0200
+++ b/mercurial/rewriteutil.py Thu Oct 08 23:33:04 2020 -0400
@@ -111,8 +111,18 @@
# We can't make any assumptions about how to update the hash if the
# cset in question was split or diverged.
if len(successors) == 1 and len(successors[0]) == 1:
- newhash = node.hex(successors[0][0])
- commitmsg = commitmsg.replace(h, newhash[: len(h)])
+ successor = successors[0][0]
+ if successor is not None:
+ newhash = node.hex(successor)
+ commitmsg = commitmsg.replace(h, newhash[: len(h)])
+ else:
+ repo.ui.note(
+ _(
+ b'The stale commit message reference to %s could '
+ b'not be updated\n(The referenced commit was dropped)\n'
+ )
+ % h
+ )
else:
repo.ui.note(
_(