# HG changeset patch # User Matt Harbison # Date 1602214384 14400 # Node ID 3d68b47e461be9bb2cd342fbee7207255ba0f483 # Parent 510995e249c0f89146cb380bd920b9a7bf4affd0 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 diff -r 510995e249c0 -r 3d68b47e461b mercurial/rewriteutil.py --- 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( _(