##// END OF EJS Templates
tests: unify test-fetch
Matt Mackall -
r12426:dd600141 default
parent child Browse files
Show More
This diff has been collapsed as it changes many lines, (573 lines changed) Show them Hide them
@@ -1,216 +1,417 b''
1 #!/bin/sh
1 adjust to non-default HGPORT, e.g. with run-tests.py -j
2 2
3 # adjust to non-default HGPORT, e.g. with run-tests.py -j
4 hideport() { sed "s/localhost:$HGPORT/localhost:\$HGPORT/"; }
5 hidehash() { sed "s/changeset 3:............ merges/changeset 3:... merges/"; }
3 $ echo "[extensions]" >> $HGRCPATH
4 $ echo "fetch=" >> $HGRCPATH
6 5
7 echo "[extensions]" >> $HGRCPATH
8 echo "fetch=" >> $HGRCPATH
6 test fetch with default branches only
9 7
10 echo % test fetch with default branches only
11 hg init a
12 echo a > a/a
13 hg --cwd a commit -d '1 0' -Ama
8 $ hg init a
9 $ echo a > a/a
10 $ hg --cwd a commit -d '1 0' -Ama
11 adding a
12 $ hg clone a b
13 updating to branch default
14 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
15 $ hg clone a c
16 updating to branch default
17 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
18 $ echo b > a/b
19 $ hg --cwd a commit -d '2 0' -Amb
20 adding b
21 $ hg --cwd a parents -q
22 1:97d72e5f12c7
14 23
15 hg clone a b
16 hg clone a c
24 should pull one change
17 25
18 echo b > a/b
19 hg --cwd a commit -d '2 0' -Amb
20 hg --cwd a parents -q
21
22 echo % should pull one change
23 hg --cwd b fetch ../a
24 hg --cwd b parents -q
26 $ hg --cwd b fetch ../a
27 pulling from ../a
28 searching for changes
29 adding changesets
30 adding manifests
31 adding file changes
32 added 1 changesets with 1 changes to 1 files
33 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
34 $ hg --cwd b parents -q
35 1:97d72e5f12c7
36 $ echo c > c/c
37 $ hg --cwd c commit -d '3 0' -Amc
38 adding c
39 $ hg clone c d
40 updating to branch default
41 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
42 $ hg clone c e
43 updating to branch default
44 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
25 45
26 echo c > c/c
27 hg --cwd c commit -d '3 0' -Amc
28
29 hg clone c d
30 hg clone c e
31
32 # We cannot use the default commit message if fetching from a local
33 # repo, because the path of the repo will be included in the commit
34 # message, making every commit appear different.
35
36 echo % should merge c into a
37 hg --cwd c fetch -d '4 0' -m 'automated merge' ../a
38 ls c
46 We cannot use the default commit message if fetching from a local
47 repo, because the path of the repo will be included in the commit
48 message, making every commit appear different.
49 should merge c into a
39 50
40 netstat -tnap 2>/dev/null | grep $HGPORT | grep LISTEN
41 hg --cwd a serve -a localhost -p $HGPORT -d --pid-file=hg.pid
42 cat a/hg.pid >> "$DAEMON_PIDS"
51 $ hg --cwd c fetch -d '4 0' -m 'automated merge' ../a
52 pulling from ../a
53 searching for changes
54 adding changesets
55 adding manifests
56 adding file changes
57 added 1 changesets with 1 changes to 1 files (+1 heads)
58 updating to 2:97d72e5f12c7
59 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
60 merging with 1:5e056962225c
61 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
62 new changeset 3:cd3a41621cf0 merges remote changes with local
63 $ ls c
64 a
65 b
66 c
67 $ netstat -tnap 2>/dev/null | grep $HGPORT | grep LISTEN
68 [1]
69 $ hg --cwd a serve -a localhost -p $HGPORT -d --pid-file=hg.pid
70 $ cat a/hg.pid >> "$DAEMON_PIDS"
43 71
44 echo '% fetch over http, no auth'
45 hg --cwd d fetch -d '5 0' http://localhost:$HGPORT/ | hideport | hidehash
46 hg --cwd d tip --template '{desc}\n' | hideport
72 fetch over http, no auth
47 73
48 echo '% fetch over http with auth (should be hidden in desc)'
49 hg --cwd e fetch -d '5 0' http://user:password@localhost:$HGPORT/ | hideport | hidehash
50 hg --cwd e tip --template '{desc}\n' | hideport
74 $ hg --cwd d fetch -d '5 0' http://localhost:$HGPORT/
75 pulling from http://localhost:*/ (glob)
76 searching for changes
77 adding changesets
78 adding manifests
79 adding file changes
80 added 1 changesets with 1 changes to 1 files (+1 heads)
81 updating to 2:97d72e5f12c7
82 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
83 merging with 1:5e056962225c
84 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
85 new changeset 3:0b6439e938f9 merges remote changes with local
86 $ hg --cwd d tip --template '{desc}\n'
87 Automated merge with http://localhost:*/ (glob)
51 88
52 hg clone a f
53 hg clone a g
89 fetch over http with auth (should be hidden in desc)
54 90
55 echo f > f/f
56 hg --cwd f ci -d '6 0' -Amf
57
58 echo g > g/g
59 hg --cwd g ci -d '6 0' -Amg
91 $ hg --cwd e fetch -d '5 0' http://user:password@localhost:$HGPORT/
92 pulling from http://user:***@localhost:*/ (glob)
93 searching for changes
94 adding changesets
95 adding manifests
96 adding file changes
97 added 1 changesets with 1 changes to 1 files (+1 heads)
98 updating to 2:97d72e5f12c7
99 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
100 merging with 1:5e056962225c
101 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
102 new changeset 3:0b6439e938f9 merges remote changes with local
103 $ hg --cwd e tip --template '{desc}\n'
104 Automated merge with http://localhost:*/ (glob)
105 $ hg clone a f
106 updating to branch default
107 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
108 $ hg clone a g
109 updating to branch default
110 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
111 $ echo f > f/f
112 $ hg --cwd f ci -d '6 0' -Amf
113 adding f
114 $ echo g > g/g
115 $ hg --cwd g ci -d '6 0' -Amg
116 adding g
117 $ hg clone -q f h
118 $ hg clone -q g i
60 119
61 hg clone -q f h
62 hg clone -q g i
120 should merge f into g
63 121
64 echo % should merge f into g
65 hg --cwd g fetch -d '7 0' --switch -m 'automated merge' ../f
122 $ hg --cwd g fetch -d '7 0' --switch -m 'automated merge' ../f
123 pulling from ../f
124 searching for changes
125 adding changesets
126 adding manifests
127 adding file changes
128 added 1 changesets with 1 changes to 1 files (+1 heads)
129 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
130 merging with 3:cc6a3744834d
131 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
132 new changeset 4:55aa4f32ec59 merges remote changes with local
133 $ rm i/g
66 134
67 rm i/g
68 echo % should abort, because i is modified
69 hg --cwd i fetch ../h
135 should abort, because i is modified
70 136
137 $ hg --cwd i fetch ../h
138 abort: working directory is missing some files
139 [255]
71 140
72 echo % test fetch with named branches
73 hg init nbase
74 echo base > nbase/a
75 hg -R nbase ci -d '1 0' -Am base
76 hg -R nbase branch a
77 echo a > nbase/a
78 hg -R nbase ci -d '2 0' -m a
79 hg -R nbase up -C 0
80 hg -R nbase branch b
81 echo b > nbase/b
82 hg -R nbase ci -Ad '3 0' -m b
141 test fetch with named branches
142
143 $ hg init nbase
144 $ echo base > nbase/a
145 $ hg -R nbase ci -d '1 0' -Am base
146 adding a
147 $ hg -R nbase branch a
148 marked working directory as branch a
149 $ echo a > nbase/a
150 $ hg -R nbase ci -d '2 0' -m a
151 $ hg -R nbase up -C 0
152 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
153 $ hg -R nbase branch b
154 marked working directory as branch b
155 $ echo b > nbase/b
156 $ hg -R nbase ci -Ad '3 0' -m b
157 adding b
158 $ echo
159
160
161 pull in change on foreign branch
83 162
84 echo
85 echo % pull in change on foreign branch
86 hg clone nbase n1
87 hg clone nbase n2
88 hg -R n1 up -C a
89 echo aa > n1/a
90 hg -R n1 ci -d '4 0' -m a1
163 $ hg clone nbase n1
164 updating to branch default
165 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
166 $ hg clone nbase n2
167 updating to branch default
168 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
169 $ hg -R n1 up -C a
170 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
171 $ echo aa > n1/a
172 $ hg -R n1 ci -d '4 0' -m a1
173 $ hg -R n2 up -C b
174 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
175 $ hg -R n2 fetch -d '9 0' -m 'merge' n1
176 pulling from n1
177 searching for changes
178 adding changesets
179 adding manifests
180 adding file changes
181 added 1 changesets with 1 changes to 1 files
91 182
92 hg -R n2 up -C b
93 hg -R n2 fetch -d '9 0' -m 'merge' n1
94 echo '% parent should be 2 (no automatic update)'
95 hg -R n2 parents --template '{rev}\n'
96 rm -fr n1 n2
183 parent should be 2 (no automatic update)
97 184
98 echo
99 echo % pull in changes on both foreign and local branches
100 hg clone nbase n1
101 hg clone nbase n2
102 hg -R n1 up -C a
103 echo aa > n1/a
104 hg -R n1 ci -d '4 0' -m a1
105 hg -R n1 up -C b
106 echo bb > n1/b
107 hg -R n1 ci -d '5 0' -m b1
185 $ hg -R n2 parents --template '{rev}\n'
186 2
187 $ rm -fr n1 n2
188 $ echo
189
190
191 pull in changes on both foreign and local branches
108 192
109 hg -R n2 up -C b
110 hg -R n2 fetch -d '9 0' -m 'merge' n1
111 echo '% parent should be 4 (fast forward)'
112 hg -R n2 parents --template '{rev}\n'
113 rm -fr n1 n2
193 $ hg clone nbase n1
194 updating to branch default
195 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
196 $ hg clone nbase n2
197 updating to branch default
198 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
199 $ hg -R n1 up -C a
200 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
201 $ echo aa > n1/a
202 $ hg -R n1 ci -d '4 0' -m a1
203 $ hg -R n1 up -C b
204 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
205 $ echo bb > n1/b
206 $ hg -R n1 ci -d '5 0' -m b1
207 $ hg -R n2 up -C b
208 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
209 $ hg -R n2 fetch -d '9 0' -m 'merge' n1
210 pulling from n1
211 searching for changes
212 adding changesets
213 adding manifests
214 adding file changes
215 added 2 changesets with 2 changes to 2 files
216 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
114 217
115 echo
116 echo '% pull changes on foreign (2 new heads) and local (1 new head) branches'
117 echo % with a local change
118 hg clone nbase n1
119 hg clone nbase n2
120 hg -R n1 up -C a
121 echo a1 > n1/a
122 hg -R n1 ci -d '4 0' -m a1
123 hg -R n1 up -C b
124 echo bb > n1/b
125 hg -R n1 ci -d '5 0' -m b1
126 hg -R n1 up -C 1
127 echo a2 > n1/a
128 hg -R n1 ci -d '6 0' -m a2
218 parent should be 4 (fast forward)
219
220 $ hg -R n2 parents --template '{rev}\n'
221 4
222 $ rm -fr n1 n2
223 $ echo
224
225
226 pull changes on foreign (2 new heads) and local (1 new head) branches
227 with a local change
129 228
130 hg -R n2 up -C b
131 echo change >> n2/c
132 hg -R n2 ci -Ad '7 0' -m local
133 hg -R n2 fetch -d '9 0' -m 'merge' n1
134 echo '% parent should be 7 (new merge changeset)'
135 hg -R n2 parents --template '{rev}\n'
136 rm -fr n1 n2
229 $ hg clone nbase n1
230 updating to branch default
231 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
232 $ hg clone nbase n2
233 updating to branch default
234 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
235 $ hg -R n1 up -C a
236 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
237 $ echo a1 > n1/a
238 $ hg -R n1 ci -d '4 0' -m a1
239 $ hg -R n1 up -C b
240 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
241 $ echo bb > n1/b
242 $ hg -R n1 ci -d '5 0' -m b1
243 $ hg -R n1 up -C 1
244 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
245 $ echo a2 > n1/a
246 $ hg -R n1 ci -d '6 0' -m a2
247 created new head
248 $ hg -R n2 up -C b
249 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
250 $ echo change >> n2/c
251 $ hg -R n2 ci -Ad '7 0' -m local
252 adding c
253 $ hg -R n2 fetch -d '9 0' -m 'merge' n1
254 pulling from n1
255 searching for changes
256 adding changesets
257 adding manifests
258 adding file changes
259 added 3 changesets with 3 changes to 2 files (+2 heads)
260 updating to 5:708c6cce3d26
261 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
262 merging with 3:d83427717b1f
263 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
264 new changeset 7:48f1a33f52af merges remote changes with local
137 265
138 echo '% pull in changes on foreign (merge of local branch) and local (2 new'
139 echo '% heads) with a local change'
140 hg clone nbase n1
141 hg clone nbase n2
142 hg -R n1 up -C a
143 hg -R n1 merge b
144 hg -R n1 ci -d '4 0' -m merge
145 hg -R n1 up -C 2
146 echo c > n1/a
147 hg -R n1 ci -d '5 0' -m c
148 hg -R n1 up -C 2
149 echo cc > n1/a
150 hg -R n1 ci -d '6 0' -m cc
266 parent should be 7 (new merge changeset)
151 267
152 hg -R n2 up -C b
153 echo change >> n2/b
154 hg -R n2 ci -Ad '7 0' -m local
155 hg -R n2 fetch -d '9 0' -m 'merge' n1
156 echo '% parent should be 3 (fetch did not merge anything)'
157 hg -R n2 parents --template '{rev}\n'
158 rm -fr n1 n2
268 $ hg -R n2 parents --template '{rev}\n'
269 7
270 $ rm -fr n1 n2
271
272 pull in changes on foreign (merge of local branch) and local (2 new
273 heads) with a local change
159 274
160 echo % pull in change on different branch than dirstate
161 hg init n1
162 echo a > n1/a
163 hg -R n1 ci -Am initial
164 hg clone n1 n2
165 echo b > n1/a
166 hg -R n1 ci -m next
167 hg -R n2 branch topic
168 hg -R n2 fetch -d '0 0' -m merge n1
169 echo '% parent should be 0 (fetch did not update or merge anything)'
170 hg -R n2 parents --template '{rev}\n'
171 rm -fr n1 n2
275 $ hg clone nbase n1
276 updating to branch default
277 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
278 $ hg clone nbase n2
279 updating to branch default
280 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
281 $ hg -R n1 up -C a
282 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
283 $ hg -R n1 merge b
284 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
285 (branch merge, don't forget to commit)
286 $ hg -R n1 ci -d '4 0' -m merge
287 $ hg -R n1 up -C 2
288 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
289 $ echo c > n1/a
290 $ hg -R n1 ci -d '5 0' -m c
291 $ hg -R n1 up -C 2
292 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
293 $ echo cc > n1/a
294 $ hg -R n1 ci -d '6 0' -m cc
295 created new head
296 $ hg -R n2 up -C b
297 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
298 $ echo change >> n2/b
299 $ hg -R n2 ci -Ad '7 0' -m local
300 $ hg -R n2 fetch -d '9 0' -m 'merge' n1
301 pulling from n1
302 searching for changes
303 adding changesets
304 adding manifests
305 adding file changes
306 added 3 changesets with 2 changes to 1 files (+2 heads)
307 not merging with 1 other new branch heads (use "hg heads ." and "hg merge" to merge them)
172 308
173 echo % test fetch with inactive branches
174 hg init ib1
175 echo a > ib1/a
176 hg --cwd ib1 ci -Am base
177 hg --cwd ib1 branch second
178 echo b > ib1/b
179 hg --cwd ib1 ci -Am onsecond
180 hg --cwd ib1 branch -f default
181 echo c > ib1/c
182 hg --cwd ib1 ci -Am newdefault
183 hg clone ib1 ib2
184 echo % fetch should succeed
185 hg --cwd ib2 fetch ../ib1
186 rm -fr ib1 ib2
309 parent should be 3 (fetch did not merge anything)
310
311 $ hg -R n2 parents --template '{rev}\n'
312 3
313 $ rm -fr n1 n2
314
315 pull in change on different branch than dirstate
316
317 $ hg init n1
318 $ echo a > n1/a
319 $ hg -R n1 ci -Am initial
320 adding a
321 $ hg clone n1 n2
322 updating to branch default
323 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
324 $ echo b > n1/a
325 $ hg -R n1 ci -m next
326 $ hg -R n2 branch topic
327 marked working directory as branch topic
328 $ hg -R n2 fetch -d '0 0' -m merge n1
329 abort: working dir not at branch tip (use "hg update" to check out branch tip)
330 [255]
331
332 parent should be 0 (fetch did not update or merge anything)
333
334 $ hg -R n2 parents --template '{rev}\n'
335 0
336 $ rm -fr n1 n2
337
338 test fetch with inactive branches
187 339
188 echo % test issue1726
189 hg init i1726r1
190 echo a > i1726r1/a
191 hg --cwd i1726r1 ci -Am base
192 hg clone i1726r1 i1726r2
193 echo b > i1726r1/a
194 hg --cwd i1726r1 ci -m second
195 echo c > i1726r2/a
196 hg --cwd i1726r2 ci -m third
197 HGMERGE=true hg --cwd i1726r2 fetch ../i1726r1 | sed 's/new changeset 3:[0-9a-zA-Z]* /new changeset 3 /'
198 hg --cwd i1726r2 heads default --template '{rev}\n'
340 $ hg init ib1
341 $ echo a > ib1/a
342 $ hg --cwd ib1 ci -Am base
343 adding a
344 $ hg --cwd ib1 branch second
345 marked working directory as branch second
346 $ echo b > ib1/b
347 $ hg --cwd ib1 ci -Am onsecond
348 adding b
349 $ hg --cwd ib1 branch -f default
350 marked working directory as branch default
351 $ echo c > ib1/c
352 $ hg --cwd ib1 ci -Am newdefault
353 adding c
354 created new head
355 $ hg clone ib1 ib2
356 updating to branch default
357 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
358
359 fetch should succeed
360
361 $ hg --cwd ib2 fetch ../ib1
362 pulling from ../ib1
363 searching for changes
364 no changes found
365 $ rm -fr ib1 ib2
366
367 test issue1726
199 368
200 echo
201 echo % test issue2047
202 hg -q init i2047a
203 cd i2047a
204 echo a > a
205 hg -q ci -Am a
206 hg -q branch stable
207 echo b > b
208 hg -q ci -Am b
209 cd ..
210 hg -q clone -r 0 i2047a i2047b
211 cd i2047b
212 hg fetch ../i2047a
369 $ hg init i1726r1
370 $ echo a > i1726r1/a
371 $ hg --cwd i1726r1 ci -Am base
372 adding a
373 $ hg clone i1726r1 i1726r2
374 updating to branch default
375 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
376 $ echo b > i1726r1/a
377 $ hg --cwd i1726r1 ci -m second
378 $ echo c > i1726r2/a
379 $ hg --cwd i1726r2 ci -m third
380 $ HGMERGE=true hg --cwd i1726r2 fetch ../i1726r1
381 pulling from ../i1726r1
382 searching for changes
383 adding changesets
384 adding manifests
385 adding file changes
386 added 1 changesets with 1 changes to 1 files (+1 heads)
387 updating to 2:7837755a2789
388 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
389 merging with 1:d1f0c6c48ebd
390 merging a
391 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
392 new changeset 3:* merges remote changes with local (glob)
393 $ hg --cwd i1726r2 heads default --template '{rev}\n'
394 3
395 $ echo
396
213 397
214 "$TESTDIR/killdaemons.py"
398 test issue2047
215 399
216 true
400 $ hg -q init i2047a
401 $ cd i2047a
402 $ echo a > a
403 $ hg -q ci -Am a
404 $ hg -q branch stable
405 $ echo b > b
406 $ hg -q ci -Am b
407 $ cd ..
408 $ hg -q clone -r 0 i2047a i2047b
409 $ cd i2047b
410 $ hg fetch ../i2047a
411 pulling from ../i2047a
412 searching for changes
413 adding changesets
414 adding manifests
415 adding file changes
416 added 1 changesets with 1 changes to 1 files
417 $ "$TESTDIR/killdaemons.py"
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now