comparison tests/test-touch.t @ 5979:4a09e95d29c9 stable

rewriteutil: fix broken touch of merge commits (issue6416) `rewriteutil.rewrite()` is for rewriting a linear chain of commits into a single commit, i.e. what `hg fold` does. Many of the callers passed in a single commit because they wanted to rewrite just a single commit (e.g. `hg touch`). Before this patch, the code worked by going through the commits to fold and adding up all the modified files in them, then building a `memctx` based on that. As reported in issue6416, that can lose changes in merge commits. We could probably fix that without changing the existing code too much, but it seems the easiest way is to rewrite the code so it instead creates the new commit by effectively checking out the base and then revert to the head of the chain, so that's what this patch does. It does so by using in-memory merge.
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 05 Oct 2020 08:35:17 -0700
parents bf48247af25a
children e97fbded40a5 3fdfeca7e45f
comparison
equal deleted inserted replaced
5978:bf48247af25a 5979:4a09e95d29c9
254 |\ 254 |\
255 ~ ~ 255 ~ ~
256 $ hg status --hidden --change 'min(desc("merge"))' 256 $ hg status --hidden --change 'min(desc("merge"))'
257 A right1 257 A right1
258 A right2 258 A right2
259 BROKEN: should be the same as "5"
260 $ hg status --hidden --change 'max(desc("merge"))' 259 $ hg status --hidden --change 'max(desc("merge"))'
260 A right1
261 A right2 261 A right2
262 BROKEN: There should be no difference
263 $ hg status --hidden --rev 'min(desc("merge"))' --rev 'max(desc("merge"))' 262 $ hg status --hidden --rev 'min(desc("merge"))' --rev 'max(desc("merge"))'
264 R right1
265 $ cd .. 263 $ cd ..
266 264
267 Check that touching a merge commit doesn't lose copies 265 Check that touching a merge commit doesn't lose copies
268 266
269 $ hg init merge-copies 267 $ hg init merge-copies
313 $ hg debugpathcopies 'min(desc("left"))' 'max(desc("merge"))' 311 $ hg debugpathcopies 'min(desc("left"))' 'max(desc("merge"))'
314 base -> copy-on-right 312 base -> copy-on-right
315 left -> merge-copy-left 313 left -> merge-copy-left
316 $ hg debugpathcopies 'min(desc("right"))' 'min(desc("merge"))' 314 $ hg debugpathcopies 'min(desc("right"))' 'min(desc("merge"))'
317 base -> copy-on-left 315 base -> copy-on-left
318 right -> merge-copy-right (missing-correct-output !) 316 right -> merge-copy-right
319 $ hg debugpathcopies 'min(desc("right"))' 'max(desc("merge"))' 317 $ hg debugpathcopies 'min(desc("right"))' 'max(desc("merge"))'
320 base -> copy-on-left 318 base -> copy-on-left
321 right -> merge-copy-right (missing-correct-output !) 319 right -> merge-copy-right
322 $ cd .. 320 $ cd ..
323 321
324 Make sure touch doesn't fail to warn about divergence (issue6107) 322 Make sure touch doesn't fail to warn about divergence (issue6107)
325 323
326 $ hg init touchdiv 324 $ hg init touchdiv