Patchwork [1,of,2,rfc] tests: demonstrate problem with diff not detecting copies

login
register
mail settings
Submitter Mads Kiilerich
Date Nov. 8, 2013, 2:49 a.m.
Message ID <d3df4d706b86fa1780f6.1383878986@mk-desktop>
Download mbox | patch
Permalink /patch/2870/
State Superseded
Headers show

Comments

Mads Kiilerich - Nov. 8, 2013, 2:49 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1383878498 -3600
#      Fri Nov 08 03:41:38 2013 +0100
# Branch stable
# Node ID d3df4d706b86fa1780f6156a033062a7f617cd4c
# Parent  0151b61fed976372a4c26e6a3f09794ff87087b0
tests: demonstrate problem with diff not detecting copies

Patch

diff --git a/tests/test-copied-diff.t b/tests/test-copied-diff.t
new file mode 100644
--- /dev/null
+++ b/tests/test-copied-diff.t
@@ -0,0 +1,96 @@ 
+We had a weird case where diff failed to see a rename as a rename, thus making
+it very hard to review what otherwise would be simple.
+
+Reduced to a pretty minimal test case:
+
+  $ hg init repo1
+  $ cd repo1
+
+  $ echo 0 > f
+  $ hg ci -qAm 'f=0'
+
+  $ echo 1 > f
+  $ hg ci -m 'f=1'
+
+  $ hg up -qr 0
+  $ touch other
+  $ hg ci -qAm 'other'
+
+  $ echo 3 > f
+  $ hg ci -m 'f=3'
+
+  $ hg merge -q 1 --tool internal:local
+  $ hg ci -m 'merge'
+
+  $ hg up -qr 2
+  $ hg mv f g
+  $ hg ci -qm 'mv f g'
+
+  $ hg merge -q -r 3 --tool internal:local
+  $ hg ci -m 'merge'
+
+  $ hg merge -q -r 4 --tool internal:local
+  $ hg ci -m 'merge'
+
+  $ hg log -G --template '{desc}'
+  @    merge
+  |\
+  | o    merge
+  | |\
+  | | o  mv f g
+  | | |
+  o | |  merge
+  |\| |
+  | o |  f=3
+  | |/
+  | o  other
+  | |
+  o |  f=1
+  |/
+  o  f=0
+  
+Diff from "other" to tip do not see the rename:
+
+  $ hg diff --git -r 2 -r tip
+  diff --git a/f b/f
+  deleted file mode 100644
+  --- a/f
+  +++ /dev/null
+  @@ -1,1 +0,0 @@
+  -0
+  diff --git a/g b/g
+  new file mode 100644
+  --- /dev/null
+  +++ b/g
+  @@ -0,0 +1,1 @@
+  +0
+
+  $ cd ..
+
+Diff from "other" to diff with another topological ordering do see the rename:
+
+  $ hg clone -q -U repo1 repo2 -r 5
+  $ cd repo2
+  $ hg pull -q
+  $ hg log -G --template '{desc}'
+  o    merge
+  |\
+  | o    merge
+  | |\
+  o---+  merge
+  | | |
+  | | o  f=3
+  | | |
+  o | |  f=1
+  | | |
+  | o |  mv f g
+  | |/
+  | o  other
+  |/
+  o  f=0
+  
+  $ hg diff --git -r 1 -r tip
+  diff --git a/f b/g
+  rename from f
+  rename to g
+