##// END OF EJS Templates
tests: unify test-convert-filemap
Matt Mackall -
r12529:00e7a7fd default
parent child Browse files
Show More
@@ -1,141 +1,284
1 #!/bin/sh
2
3 HGMERGE=true; export HGMERGE
4
5 echo '[extensions]' >> $HGRCPATH
6 echo 'graphlog =' >> $HGRCPATH
7 echo 'convert =' >> $HGRCPATH
8
9 glog()
10 {
11 hg glog --template '{rev} "{desc}" files: {files}\n' "$@"
12 }
13
14 hg init source
15 cd source
16
1
17 echo foo > foo
2 $ HGMERGE=true; export HGMERGE
18 echo baz > baz
3 $ echo '[extensions]' >> $HGRCPATH
19 mkdir -p dir/subdir
4 $ echo 'graphlog =' >> $HGRCPATH
20 echo dir/file >> dir/file
5 $ echo 'convert =' >> $HGRCPATH
21 echo dir/file2 >> dir/file2
6 $ glog()
22 echo dir/subdir/file3 >> dir/subdir/file3
7 > {
23 echo dir/subdir/file4 >> dir/subdir/file4
8 > hg glog --template '{rev} "{desc}" files: {files}\n' "$@"
24 hg ci -d '0 0' -qAm '0: add foo baz dir/'
9 > }
10 $ hg init source
11 $ cd source
12 $ echo foo > foo
13 $ echo baz > baz
14 $ mkdir -p dir/subdir
15 $ echo dir/file >> dir/file
16 $ echo dir/file2 >> dir/file2
17 $ echo dir/subdir/file3 >> dir/subdir/file3
18 $ echo dir/subdir/file4 >> dir/subdir/file4
19 $ hg ci -d '0 0' -qAm '0: add foo baz dir/'
20 $ echo bar > bar
21 $ echo quux > quux
22 $ hg copy foo copied
23 $ hg ci -d '1 0' -qAm '1: add bar quux; copy foo to copied'
24 $ echo >> foo
25 $ hg ci -d '2 0' -m '2: change foo'
26 $ hg up -qC 1
27 $ echo >> bar
28 $ echo >> quux
29 $ hg ci -d '3 0' -m '3: change bar quux'
30 created new head
31 $ hg up -qC 2
32 $ hg merge -qr 3
33 $ echo >> bar
34 $ echo >> baz
35 $ hg ci -d '4 0' -m '4: first merge; change bar baz'
36 $ echo >> bar
37 $ echo 1 >> baz
38 $ echo >> quux
39 $ hg ci -d '5 0' -m '5: change bar baz quux'
40 $ hg up -qC 4
41 $ echo >> foo
42 $ echo 2 >> baz
43 $ hg ci -d '6 0' -m '6: change foo baz'
44 created new head
45 $ hg up -qC 5
46 $ hg merge -qr 6
47 $ echo >> bar
48 $ hg ci -d '7 0' -m '7: second merge; change bar'
49 $ echo >> foo
50 $ hg ci -m '8: change foo'
51 $ glog
52 @ 8 "8: change foo" files: foo
53 |
54 o 7 "7: second merge; change bar" files: bar baz
55 |\
56 | o 6 "6: change foo baz" files: baz foo
57 | |
58 o | 5 "5: change bar baz quux" files: bar baz quux
59 |/
60 o 4 "4: first merge; change bar baz" files: bar baz
61 |\
62 | o 3 "3: change bar quux" files: bar quux
63 | |
64 o | 2 "2: change foo" files: foo
65 |/
66 o 1 "1: add bar quux; copy foo to copied" files: bar copied quux
67 |
68 o 0 "0: add foo baz dir/" files: baz dir/file dir/file2 dir/subdir/file3 dir/subdir/file4 foo
25
69
26 echo bar > bar
27 echo quux > quux
28 hg copy foo copied
29 hg ci -d '1 0' -qAm '1: add bar quux; copy foo to copied'
30
31 echo >> foo
32 hg ci -d '2 0' -m '2: change foo'
33
70
34 hg up -qC 1
71 final file versions in this repo:
35 echo >> bar
36 echo >> quux
37 hg ci -d '3 0' -m '3: change bar quux'
38
72
39 hg up -qC 2
73 $ hg manifest --debug
40 hg merge -qr 3
74 9463f52fe115e377cf2878d4fc548117211063f2 644 bar
41 echo >> bar
75 94c1be4dfde2ee8d78db8bbfcf81210813307c3d 644 baz
42 echo >> baz
76 7711d36246cc83e61fb29cd6d4ef394c63f1ceaf 644 copied
43 hg ci -d '4 0' -m '4: first merge; change bar baz'
77 3e20847584beff41d7cd16136b7331ab3d754be0 644 dir/file
44
78 75e6d3f8328f5f6ace6bf10b98df793416a09dca 644 dir/file2
45 echo >> bar
79 5fe139720576e18e34bcc9f79174db8897c8afe9 644 dir/subdir/file3
46 echo 1 >> baz
80 57a1c1511590f3de52874adfa04effe8a77d64af 644 dir/subdir/file4
47 echo >> quux
81 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo
48 hg ci -d '5 0' -m '5: change bar baz quux'
82 bc3eca3f47023a3e70ca0d8cc95a22a6827db19d 644 quux
83 $ hg debugrename copied
84 copied renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd
85 $ echo
49
86
50 hg up -qC 4
87 $ cd ..
51 echo >> foo
88 $ splitrepo()
52 echo 2 >> baz
89 > {
53 hg ci -d '6 0' -m '6: change foo baz'
90 > msg="$1"
54
91 > files="$2"
55 hg up -qC 5
92 > opts=$3
56 hg merge -qr 6
93 > echo "% $files: $msg"
57 echo >> bar
94 > prefix=`echo "$files" | sed -e 's/ /-/g'`
58 hg ci -d '7 0' -m '7: second merge; change bar'
95 > fmap="$prefix.fmap"
96 > repo="$prefix.repo"
97 > for i in $files; do
98 > echo "include $i" >> "$fmap"
99 > done
100 > hg -q convert $opts --filemap "$fmap" --datesort source "$repo"
101 > hg up -q -R "$repo"
102 > glog -R "$repo"
103 > hg -R "$repo" manifest --debug
104 > }
105 $ splitrepo 'skip unwanted merges; use 1st parent in 1st merge, 2nd in 2nd' foo
106 % foo: skip unwanted merges; use 1st parent in 1st merge, 2nd in 2nd
107 @ 3 "8: change foo" files: foo
108 |
109 o 2 "6: change foo baz" files: foo
110 |
111 o 1 "2: change foo" files: foo
112 |
113 o 0 "0: add foo baz dir/" files: foo
59
114
60 echo >> foo
115 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo
61 hg ci -m '8: change foo'
116 $ splitrepo 'merges are not merges anymore' bar
62
117 % bar: merges are not merges anymore
63 glog
118 @ 4 "7: second merge; change bar" files: bar
119 |
120 o 3 "5: change bar baz quux" files: bar
121 |
122 o 2 "4: first merge; change bar baz" files: bar
123 |
124 o 1 "3: change bar quux" files: bar
125 |
126 o 0 "1: add bar quux; copy foo to copied" files: bar
64
127
65 echo '% final file versions in this repo:'
128 9463f52fe115e377cf2878d4fc548117211063f2 644 bar
66 hg manifest --debug
129 $ splitrepo '1st merge is not a merge anymore; 2nd still is' baz
67 hg debugrename copied
130 % baz: 1st merge is not a merge anymore; 2nd still is
68 echo
131 @ 4 "7: second merge; change bar" files: baz
69
132 |\
70 cd ..
133 | o 3 "6: change foo baz" files: baz
134 | |
135 o | 2 "5: change bar baz quux" files: baz
136 |/
137 o 1 "4: first merge; change bar baz" files: baz
138 |
139 o 0 "0: add foo baz dir/" files: baz
71
140
72 splitrepo()
141 94c1be4dfde2ee8d78db8bbfcf81210813307c3d 644 baz
73 {
142 $ splitrepo 'we add additional merges when they are interesting' 'foo quux'
74 msg="$1"
143 % foo quux: we add additional merges when they are interesting
75 files="$2"
144 @ 8 "8: change foo" files: foo
76 opts=$3
145 |
77 echo "% $files: $msg"
146 o 7 "7: second merge; change bar" files:
78 prefix=`echo "$files" | sed -e 's/ /-/g'`
147 |\
79 fmap="$prefix.fmap"
148 | o 6 "6: change foo baz" files: foo
80 repo="$prefix.repo"
149 | |
81 for i in $files; do
150 o | 5 "5: change bar baz quux" files: quux
82 echo "include $i" >> "$fmap"
151 |/
83 done
152 o 4 "4: first merge; change bar baz" files:
84 hg -q convert $opts --filemap "$fmap" --datesort source "$repo"
153 |\
85 hg up -q -R "$repo"
154 | o 3 "3: change bar quux" files: quux
86 glog -R "$repo"
155 | |
87 hg -R "$repo" manifest --debug
156 o | 2 "2: change foo" files: foo
88 }
157 |/
158 o 1 "1: add bar quux; copy foo to copied" files: quux
159 |
160 o 0 "0: add foo baz dir/" files: foo
161
162 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo
163 bc3eca3f47023a3e70ca0d8cc95a22a6827db19d 644 quux
164 $ splitrepo 'partial conversion' 'bar quux' '-r 3'
165 % bar quux: partial conversion
166 @ 1 "3: change bar quux" files: bar quux
167 |
168 o 0 "1: add bar quux; copy foo to copied" files: bar quux
89
169
90 splitrepo 'skip unwanted merges; use 1st parent in 1st merge, 2nd in 2nd' foo
170 b79105bedc55102f394e90a789c9c380117c1b4a 644 bar
91
171 db0421cc6b685a458c8d86c7d5c004f94429ea23 644 quux
92 splitrepo 'merges are not merges anymore' bar
172 $ splitrepo 'complete the partial conversion' 'bar quux'
93
173 % bar quux: complete the partial conversion
94 splitrepo '1st merge is not a merge anymore; 2nd still is' baz
174 @ 4 "7: second merge; change bar" files: bar
175 |
176 o 3 "5: change bar baz quux" files: bar quux
177 |
178 o 2 "4: first merge; change bar baz" files: bar
179 |
180 o 1 "3: change bar quux" files: bar quux
181 |
182 o 0 "1: add bar quux; copy foo to copied" files: bar quux
95
183
96 splitrepo 'we add additional merges when they are interesting' 'foo quux'
184 9463f52fe115e377cf2878d4fc548117211063f2 644 bar
185 bc3eca3f47023a3e70ca0d8cc95a22a6827db19d 644 quux
186 $ rm -r foo.repo
187 $ splitrepo 'partial conversion' 'foo' '-r 3'
188 % foo: partial conversion
189 @ 0 "0: add foo baz dir/" files: foo
97
190
98 splitrepo 'partial conversion' 'bar quux' '-r 3'
191 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644 foo
99 splitrepo 'complete the partial conversion' 'bar quux'
192 $ splitrepo 'complete the partial conversion' 'foo'
193 % foo: complete the partial conversion
194 @ 3 "8: change foo" files: foo
195 |
196 o 2 "6: change foo baz" files: foo
197 |
198 o 1 "2: change foo" files: foo
199 |
200 o 0 "0: add foo baz dir/" files: foo
100
201
101 rm -r foo.repo
202 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo
102 splitrepo 'partial conversion' 'foo' '-r 3'
203 $ splitrepo 'copied file; source not included in new repo' copied
103 splitrepo 'complete the partial conversion' 'foo'
204 % copied: copied file; source not included in new repo
205 @ 0 "1: add bar quux; copy foo to copied" files: copied
104
206
105 splitrepo 'copied file; source not included in new repo' copied
207 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644 copied
106 hg --cwd copied.repo debugrename copied
208 $ hg --cwd copied.repo debugrename copied
107
209 copied not renamed
108 splitrepo 'copied file; source included in new repo' 'foo copied'
210 $ splitrepo 'copied file; source included in new repo' 'foo copied'
109 hg --cwd foo-copied.repo debugrename copied
211 % foo copied: copied file; source included in new repo
212 @ 4 "8: change foo" files: foo
213 |
214 o 3 "6: change foo baz" files: foo
215 |
216 o 2 "2: change foo" files: foo
217 |
218 o 1 "1: add bar quux; copy foo to copied" files: copied
219 |
220 o 0 "0: add foo baz dir/" files: foo
110
221
111 cat > renames.fmap <<EOF
222 7711d36246cc83e61fb29cd6d4ef394c63f1ceaf 644 copied
112 include dir
223 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo
113 exclude dir/file2
224 $ hg --cwd foo-copied.repo debugrename copied
114 rename dir dir2
225 copied renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd
115 include foo
226 $ cat > renames.fmap <<EOF
116 include copied
227 > include dir
117 rename foo foo2
228 > exclude dir/file2
118 rename copied copied2
229 > rename dir dir2
119 exclude dir/subdir
230 > include foo
120 include dir/subdir/file3
231 > include copied
121 EOF
232 > rename foo foo2
122 hg -q convert --filemap renames.fmap --datesort source renames.repo
233 > rename copied copied2
123 hg up -q -R renames.repo
234 > exclude dir/subdir
124 glog -R renames.repo
235 > include dir/subdir/file3
125 hg -R renames.repo manifest --debug
236 > EOF
126 hg --cwd renames.repo debugrename copied2
237 $ hg -q convert --filemap renames.fmap --datesort source renames.repo
127 echo 'copied:'
238 $ hg up -q -R renames.repo
128 hg --cwd source cat copied
239 $ glog -R renames.repo
129 echo 'copied2:'
240 @ 4 "8: change foo" files: foo2
130 hg --cwd renames.repo cat copied2
241 |
242 o 3 "6: change foo baz" files: foo2
243 |
244 o 2 "2: change foo" files: foo2
245 |
246 o 1 "1: add bar quux; copy foo to copied" files: copied2
247 |
248 o 0 "0: add foo baz dir/" files: dir2/file dir2/subdir/file3 foo2
131
249
132 echo % filemap errors
250 $ hg -R renames.repo manifest --debug
133 cat > errors.fmap <<EOF
251 d43feacba7a4f1f2080dde4a4b985bd8a0236d46 644 copied2
134 include dir/ # beware that comments changes error line numbers!
252 3e20847584beff41d7cd16136b7331ab3d754be0 644 dir2/file
135 exclude /dir
253 5fe139720576e18e34bcc9f79174db8897c8afe9 644 dir2/subdir/file3
136 rename dir//dir /dir//dir/ "out of sync"
254 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo2
137 include
255 $ hg --cwd renames.repo debugrename copied2
138 EOF
256 copied2 renamed from foo2:2ed2a3912a0b24502043eae84ee4b279c18b90dd
139 hg -q convert --filemap errors.fmap source errors.repo
257
258 copied:
259
260 $ hg --cwd source cat copied
261 foo
262
263 copied2:
264
265 $ hg --cwd renames.repo cat copied2
266 foo
140
267
141 true # happy ending
268 filemap errors
269
270 $ cat > errors.fmap <<EOF
271 > include dir/ # beware that comments changes error line numbers!
272 > exclude /dir
273 > rename dir//dir /dir//dir/ "out of sync"
274 > include
275 > EOF
276 $ hg -q convert --filemap errors.fmap source errors.repo
277 errors.fmap:1: superfluous / in exclude 'dir/'
278 errors.fmap:3: superfluous / in include '/dir'
279 errors.fmap:3: superfluous / in rename '/dir'
280 errors.fmap:3: superfluous / in exclude 'dir//dir'
281 errors.fmap:4: unknown directive 'out of sync'
282 errors.fmap:5: path to exclude is missing
283 abort: errors in filemap
284 [255]
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now