diff tests/test-touch.t @ 6004:3fdfeca7e45f mercurial-4.9

test-compat: merge mercurial-5.0 into mercurial-4.9
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 12 Aug 2021 22:01:08 +0200
parents 4a09e95d29c9
children 5c921c26dc40
line wrap: on
line diff
--- a/tests/test-touch.t	Fri May 28 00:03:09 2021 +0800
+++ b/tests/test-touch.t	Thu Aug 12 22:01:08 2021 +0200
@@ -212,6 +212,145 @@
 
   $ cd ..
 
+Check that touching a merge commit doesn't lose file changes (issue 6416)
+
+  $ hg init issue-6416
+  $ cd issue-6416
+  $ echo base > base
+  $ hg ci -Aqm base
+  $ echo left1 > left1
+  $ hg ci -Aqm left1
+  $ echo left2 > left2
+  $ hg ci -Aqm left2
+  $ hg up 0 -q
+  $ echo right1 > right1
+  $ hg ci -Aqm right1
+  $ echo right2 > right2
+  $ hg ci -Aqm right2
+  $ hg up 2 -q
+  $ hg merge 4 -q
+  $ hg ci -m merge
+  $ hg touch tip
+  $ hg glog --hidden
+  @    6: merge
+  |\
+  +---x  5: merge
+  | |/
+  | o  4: right2
+  | |
+  | o  3: right1
+  | |
+  o |  2: left2
+  | |
+  o |  1: left1
+  |/
+  o  0: base
+  
+  $ hg glog --hidden --rev 'min(desc("merge"))' --rev 'max(desc("merge"))'
+  @    6: merge
+  |\
+  ~ ~
+  x    5: merge
+  |\
+  ~ ~
+  $ hg status --hidden --change 'min(desc("merge"))'
+  A right1
+  A right2
+  $ hg status --hidden --change 'max(desc("merge"))'
+  A right1
+  A right2
+  $ hg status --hidden --rev 'min(desc("merge"))' --rev 'max(desc("merge"))'
+  $ cd ..
+
+Check that touching a merge commit doesn't lose copies
+
+  $ hg init merge-copies
+  $ cd merge-copies
+  $ echo base > base
+  $ hg ci -Aqm base
+  $ echo left > left
+  $ hg cp base copy-on-left
+  $ hg ci -Aqm left
+  $ hg up 0 -q
+  $ echo right > right
+  $ hg cp base copy-on-right
+  $ hg ci -Aqm right
+  $ hg up 1 -q
+  $ hg merge 2 -q
+  $ hg cp left merge-copy-left
+  $ hg cp right merge-copy-right
+  $ hg ci -m merge
+  $ hg touch tip
+  $ hg glog --hidden
+  @    4: merge
+  |\
+  +---x  3: merge
+  | |/
+  | o  2: right
+  | |
+  o |  1: left
+  |/
+  o  0: base
+  
+  $ hg glog --hidden --rev 'min(desc("merge"))' --rev 'max(desc("merge"))'
+  @    4: merge
+  |\
+  ~ ~
+  x    3: merge
+  |\
+  ~ ~
+  $ hg status --copies --rev 'min(desc("base"))' --rev 'min(desc("merge"))'
+  A copy-on-left
+    base
+  A copy-on-right
+    base
+  A left
+  A merge-copy-left
+  A merge-copy-right
+  A right
+  $ hg status --copies --rev 'min(desc("base"))' --rev 'max(desc("merge"))'
+  A copy-on-left
+    base
+  A copy-on-right
+    base
+  A left
+  A merge-copy-left
+  A merge-copy-right
+  A right
+  $ hg status --copies --rev 'min(desc("left"))' --rev 'min(desc("merge"))'
+  M copy-on-left
+  A copy-on-right
+    base
+  A merge-copy-left
+    left
+  A merge-copy-right
+  A right
+  $ hg status --copies --rev 'min(desc("left"))' --rev 'max(desc("merge"))'
+  M copy-on-left
+  A copy-on-right
+    base
+  A merge-copy-left
+    left
+  A merge-copy-right
+  A right
+  $ hg status --copies --rev 'min(desc("right"))' --rev 'min(desc("merge"))'
+  M copy-on-right
+  A copy-on-left
+    base
+  A left
+  A merge-copy-left
+  A merge-copy-right
+    right
+  $ hg status --copies --rev 'min(desc("right"))' --rev 'max(desc("merge"))'
+  M copy-on-right
+  A copy-on-left
+    base
+  A left
+  A merge-copy-left
+  A merge-copy-right
+    right
+  $ cd ..
+
 Make sure touch doesn't fail to warn about divergence (issue6107)
 
   $ hg init touchdiv
@@ -236,3 +375,20 @@
   1 new content-divergent changesets
 
   $ cd ..
+
+Touch preserves copies
+
+  $ hg init copies
+  $ cd copies
+  $ echo a > a
+  $ hg ci -Aqm a
+  $ hg cp a b
+  $ hg ci -Aqm 'copy a to b'
+  $ hg status --copies --change .
+  A b
+    a
+  $ hg touch
+  $ hg status --copies --change .
+  A b
+    a
+  $ cd ..