comparison tests/test-renames.t @ 844:da804eac2b00

git_handler.get_files_changed: detect renames when asked to do so We use Dulwich's rename detector to detect any renames over the specified similarity threshold. This isn't fully bidirectional yet -- when the commit is exported to Git the hashes will no longer be the same. That's why that isn't tested here. In upcoming patches we'll make sure it's bidirectional and will add the corresponding tests.
author Siddharth Agarwal <sid0@fb.com>
date Tue, 02 Dec 2014 15:57:21 -0800
parents
children fffe8883960b
comparison
equal deleted inserted replaced
843:cf9dd81b61dc 844:da804eac2b00
1 Test that rename detection works
2 $ . "$TESTDIR/testutil"
3
4 $ cat >> $HGRCPATH <<EOF
5 > [diff]
6 > git = True
7 > [git]
8 > similarity = 50
9 > EOF
10
11 $ git init -q gitrepo
12 $ cd gitrepo
13 $ for i in $(seq 1 10); do echo $i >> alpha; done
14 $ git add alpha
15 $ fn_git_commit -malpha
16
17 Rename a file
18 $ git mv alpha beta
19 $ echo 11 >> beta
20 $ git add beta
21 $ fn_git_commit -mbeta
22
23 Copy a file
24 $ cp beta gamma
25 $ echo 12 >> beta
26 $ echo 13 >> gamma
27 $ git add beta gamma
28 $ fn_git_commit -mgamma
29
30 Add a submodule (gitlink) and move it to a different spot:
31 $ cd ..
32 $ git init -q gitsubmodule
33 $ cd gitsubmodule
34 $ touch subalpha
35 $ git add subalpha
36 $ fn_git_commit -msubalpha
37 $ cd ../gitrepo
38
39 $ rmpwd="import sys; print sys.stdin.read().replace('$(dirname $(pwd))/', '')"
40 $ clonefilt='s/Cloning into/Initialized empty Git repository in/;s/in .*/in .../'
41
42 $ git submodule add ../gitsubmodule 2>&1 | python -c "$rmpwd" | sed "$clonefilt" | egrep -v '^done\.$'
43 Initialized empty Git repository in ...
44
45 $ fn_git_commit -m 'add submodule'
46 $ sed -e 's/path = gitsubmodule/path = gitsubmodule2/' .gitmodules > .gitmodules-new
47 $ mv .gitmodules-new .gitmodules
48 $ mv gitsubmodule gitsubmodule2
49 $ git add .gitmodules gitsubmodule2
50 $ git rm --cached gitsubmodule
51 rm 'gitsubmodule'
52 $ fn_git_commit -m 'move submodule'
53
54 $ cd ..
55 $ hg clone -q gitrepo hgrepo
56 $ cd hgrepo
57 $ hg log -p --graph --template "{rev} {node} {desc|firstline}\n{join(extras, ' ')}\n\n"
58 @ 4 8ef5468692d8a63a2a56d35540ccc2a83970daf1 move submodule
59 | branch=default
60 |
61 | diff --git a/.gitmodules b/.gitmodules
62 | --- a/.gitmodules
63 | +++ b/.gitmodules
64 | @@ -1,3 +1,3 @@
65 | [submodule "gitsubmodule"]
66 | - path = gitsubmodule
67 | + path = gitsubmodule2
68 | url = ../gitsubmodule
69 | diff --git a/.hgsub b/.hgsub
70 | --- a/.hgsub
71 | +++ b/.hgsub
72 | @@ -1,1 +1,1 @@
73 | -gitsubmodule = [git]../gitsubmodule
74 | +gitsubmodule2 = [git]../gitsubmodule
75 | diff --git a/.hgsubstate b/.hgsubstate
76 | --- a/.hgsubstate
77 | +++ b/.hgsubstate
78 | @@ -1,1 +1,1 @@
79 | -5944b31ff85b415573d1a43eb942e2dea30ab8be gitsubmodule
80 | +5944b31ff85b415573d1a43eb942e2dea30ab8be gitsubmodule2
81 |
82 o 3 82b69d514926123f7d83b6a8fb5b041bc79c5af9 add submodule
83 | branch=default
84 |
85 | diff --git a/.gitmodules b/.gitmodules
86 | new file mode 100644
87 | --- /dev/null
88 | +++ b/.gitmodules
89 | @@ -0,0 +1,3 @@
90 | +[submodule "gitsubmodule"]
91 | + path = gitsubmodule
92 | + url = ../gitsubmodule
93 | diff --git a/.hgsub b/.hgsub
94 | new file mode 100644
95 | --- /dev/null
96 | +++ b/.hgsub
97 | @@ -0,0 +1,1 @@
98 | +gitsubmodule = [git]../gitsubmodule
99 | diff --git a/.hgsubstate b/.hgsubstate
100 | new file mode 100644
101 | --- /dev/null
102 | +++ b/.hgsubstate
103 | @@ -0,0 +1,1 @@
104 | +5944b31ff85b415573d1a43eb942e2dea30ab8be gitsubmodule
105 |
106 o 2 79563b42ed93cd47601aec11694f4e0df48457e7 gamma
107 | branch=default
108 |
109 | diff --git a/beta b/beta
110 | --- a/beta
111 | +++ b/beta
112 | @@ -9,3 +9,4 @@
113 | 9
114 | 10
115 | 11
116 | +12
117 | diff --git a/beta b/gamma
118 | copy from beta
119 | copy to gamma
120 | --- a/beta
121 | +++ b/gamma
122 | @@ -9,3 +9,4 @@
123 | 9
124 | 10
125 | 11
126 | +13
127 |
128 o 1 d1c40364c3c996350da6963e605df8269db8e311 beta
129 | branch=default
130 |
131 | diff --git a/alpha b/beta
132 | rename from alpha
133 | rename to beta
134 | --- a/alpha
135 | +++ b/beta
136 | @@ -8,3 +8,4 @@
137 | 8
138 | 9
139 | 10
140 | +11
141 |
142 o 0 0c233c2e91d64435bf329075bc0e7e858bc3b07c alpha
143 branch=default
144
145 diff --git a/alpha b/alpha
146 new file mode 100644
147 --- /dev/null
148 +++ b/alpha
149 @@ -0,0 +1,10 @@
150 +1
151 +2
152 +3
153 +4
154 +5
155 +6
156 +7
157 +8
158 +9
159 +10
160