Patchwork D9181: rewriteutil: handle dropped commits when updating description hashes

login
register
mail settings
Submitter phabricator
Date Oct. 9, 2020, 4:22 p.m.
Message ID <differential-rev-PHID-DREV-uml6yicvm37beon45aj6-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47418/
State Superseded
Headers show

Comments

phabricator - Oct. 9, 2020, 4:22 p.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.)

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9181

AFFECTED FILES
  mercurial/rewriteutil.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py
--- a/mercurial/rewriteutil.py
+++ b/mercurial/rewriteutil.py
@@ -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(
                 _(