changeset 6553:50f55918b417

pick: update commit message hashes like other rewrite commands Maybe it would be better to use `evolvecmd._relocate()`, which does this already, but I don't know what subtle behavior changes that would trigger. Also, there are other commands (like `metaedit`) that use `rewriteutil.rewrite` instead, and so don't refresh their hashes either. We probably need a better way to track all of this, but I'm not sure how.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 12 Sep 2023 11:45:49 -0400
parents 81e89d943a4e
children 279c01842eca
files hgext3rd/evolve/cmdrewrite.py tests/test-pick.t
diffstat 2 files changed, 38 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/cmdrewrite.py	Tue Jun 20 12:30:24 2023 -0300
+++ b/hgext3rd/evolve/cmdrewrite.py	Tue Sep 12 11:45:49 2023 -0400
@@ -1417,9 +1417,10 @@
 def _dopick(ui, repo, pickstate, origctx):
     """shared logic for performing or continuing a pick"""
     overrides = {(b'phases', b'new-commit'): origctx.phase()}
+    new_desc = evolvecmd._rewrite_commit_message_hashes(repo,
+                                                        origctx.description())
     with repo.ui.configoverride(overrides, b'pick'):
-        newnode = repo.commit(text=origctx.description(),
-                              user=origctx.user(),
+        newnode = repo.commit(text=new_desc, user=origctx.user(),
                               date=origctx.date(), extra=origctx.extra())
     compat.setbranch(repo, origctx.branch())
 
--- a/tests/test-pick.t	Tue Jun 20 12:30:24 2023 -0300
+++ b/tests/test-pick.t	Tue Sep 12 11:45:49 2023 -0400
@@ -380,6 +380,41 @@
 
   $ hg phase -r .
   13: secret
+
+Pick rewrites node hashes in commit description
+
+  $ echo 'hg pick rewrites hashes 1' > l
+  $ hg ci -m '1705aa17bfed is my parent'
+  $ echo 'hg pick rewrites hashes 2' > l
+  $ hg ci -m 'f9ed1703aa00 is my parent'
+
+  $ hg glog -r .^^::
+  @  15:e3cb66090723 f9ed1703aa00 is my parent
+  |
+  o  14:f9ed1703aa00 1705aa17bfed is my parent
+  |
+  o  13:1705aa17bfed added l
+  |
+  ~
+
+  $ hg up -q c437988de89f
+  $ hg pick 13
+  picking 13:1705aa17bfed "added l"
+  2 new orphan changesets
+  $ hg pick 14
+  picking 14:f9ed1703aa00 "1705aa17bfed is my parent"
+  $ hg pick 15
+  picking 15:e3cb66090723 "f9ed1703aa00 is my parent"
+
+  $ hg glog -r .^^::
+  @  18:5825531d1322 7a6997f82fbe is my parent
+  |
+  o  17:7a6997f82fbe fb6281ea03e8 is my parent
+  |
+  o  16:fb6281ea03e8 added l
+  |
+  ~
+
   $ cd ..
 
 Check pick behavior regarding working copy branch (issue6089)