Mercurial > hg
annotate tests/test-split.t @ 36753:742ce6fbc109 stable
wireproto: move command permissions dict out of hgweb_mod
The operation type associated with wire protocol commands is supposed
to be defined in a dictionary so it can be used for permissions
checking.
Since this metadata is closely associated with wire protocol commands
themselves, it makes sense to define it in the same module where
wire protocol commands are defined.
This commit moves hgweb_mod.perms to wireproto.PERMISSIONS and
updates most references in the code to use the new home. The old
symbol remains an alias for the new symbol. Tests pass with the
code pointing at the old symbol. So this should be API compatible
for extensions.
As part of the code move, we split up the assignment to the dict
so it is next to the @wireprotocommand. This reinforces that a
@wireprotocommand should have an entry in this dict.
In the future, we'll want to declare permissions as part of the
@wireprotocommand decorator. But this isn't appropriate for the
stable branch.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 20 Feb 2018 18:53:39 -0800 |
parents | 1a09dad8b85a |
children | 7bc33d677c0c |
rev | line source |
---|---|
35455 | 1 #testcases obsstore-on obsstore-off |
2 | |
3 $ cat > $TESTTMP/editor.py <<EOF | |
4 > #!$PYTHON | |
5 > import os, sys | |
6 > path = os.path.join(os.environ['TESTTMP'], 'messages') | |
7 > messages = open(path).read().split('--\n') | |
8 > prompt = open(sys.argv[1]).read() | |
9 > sys.stdout.write(''.join('EDITOR: %s' % l for l in prompt.splitlines(True))) | |
10 > sys.stdout.flush() | |
11 > with open(sys.argv[1], 'w') as f: | |
12 > f.write(messages[0]) | |
13 > with open(path, 'w') as f: | |
14 > f.write('--\n'.join(messages[1:])) | |
15 > EOF | |
16 | |
17 $ cat >> $HGRCPATH <<EOF | |
18 > [extensions] | |
19 > drawdag=$TESTDIR/drawdag.py | |
20 > split= | |
21 > [ui] | |
22 > interactive=1 | |
35479
8d05705bde0a
test-split: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
35455
diff
changeset
|
23 > color=no |
8d05705bde0a
test-split: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
35455
diff
changeset
|
24 > paginate=never |
35455 | 25 > [diff] |
26 > git=1 | |
27 > unified=0 | |
28 > [alias] | |
29 > glog=log -G -T '{rev}:{node|short} {desc} {bookmarks}\n' | |
30 > EOF | |
31 | |
32 #if obsstore-on | |
33 $ cat >> $HGRCPATH <<EOF | |
34 > [experimental] | |
35 > evolution=all | |
36 > EOF | |
37 #endif | |
38 | |
39 $ hg init a | |
40 $ cd a | |
41 | |
42 Nothing to split | |
43 | |
44 $ hg split | |
45 nothing to split | |
46 [1] | |
47 | |
48 $ hg commit -m empty --config ui.allowemptycommit=1 | |
49 $ hg split | |
50 abort: cannot split an empty revision | |
51 [255] | |
52 | |
53 $ rm -rf .hg | |
54 $ hg init | |
55 | |
56 Cannot split working directory | |
57 | |
58 $ hg split -r 'wdir()' | |
59 abort: cannot split working directory | |
60 [255] | |
61 | |
35479
8d05705bde0a
test-split: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
35455
diff
changeset
|
62 Generate some content. The sed filter drop CR on Windows, which is dropped in |
8d05705bde0a
test-split: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
35455
diff
changeset
|
63 the a > b line. |
35455 | 64 |
35479
8d05705bde0a
test-split: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
35455
diff
changeset
|
65 $ $TESTDIR/seq.py 1 5 | sed 's/\r$//' >> a |
35455 | 66 $ hg ci -m a1 -A a -q |
67 $ hg bookmark -i r1 | |
68 $ sed 's/1/11/;s/3/33/;s/5/55/' a > b | |
69 $ mv b a | |
70 $ hg ci -m a2 -q | |
71 $ hg bookmark -i r2 | |
72 | |
73 Cannot split a public changeset | |
74 | |
75 $ hg phase --public -r 'all()' | |
76 $ hg split . | |
77 abort: cannot split public changeset | |
78 (see 'hg help phases' for details) | |
79 [255] | |
80 | |
81 $ hg phase --draft -f -r 'all()' | |
82 | |
83 Cannot split while working directory is dirty | |
84 | |
85 $ touch dirty | |
86 $ hg add dirty | |
87 $ hg split . | |
88 abort: uncommitted changes | |
89 [255] | |
90 $ hg forget dirty | |
91 $ rm dirty | |
92 | |
93 Split a head | |
94 | |
95 $ cp -R . ../b | |
96 $ cp -R . ../c | |
97 | |
98 $ hg bookmark r3 | |
99 | |
100 $ hg split 'all()' | |
101 abort: cannot split multiple revisions | |
102 [255] | |
103 | |
104 $ runsplit() { | |
105 > cat > $TESTTMP/messages <<EOF | |
106 > split 1 | |
107 > -- | |
108 > split 2 | |
109 > -- | |
110 > split 3 | |
111 > EOF | |
112 > cat <<EOF | hg split "$@" | |
113 > y | |
114 > y | |
115 > y | |
116 > y | |
117 > y | |
118 > y | |
119 > EOF | |
120 > } | |
121 | |
122 $ HGEDITOR=false runsplit | |
123 diff --git a/a b/a | |
124 1 hunks, 1 lines changed | |
125 examine changes to 'a'? [Ynesfdaq?] y | |
126 | |
127 @@ -5,1 +5,1 @@ 4 | |
128 -5 | |
129 +55 | |
130 record this change to 'a'? [Ynesfdaq?] y | |
131 | |
132 transaction abort! | |
133 rollback completed | |
134 abort: edit failed: false exited with status 1 | |
135 [255] | |
136 $ hg status | |
137 | |
35479
8d05705bde0a
test-split: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
35455
diff
changeset
|
138 $ HGEDITOR="\"$PYTHON\" $TESTTMP/editor.py" |
35455 | 139 $ runsplit |
140 diff --git a/a b/a | |
141 1 hunks, 1 lines changed | |
142 examine changes to 'a'? [Ynesfdaq?] y | |
143 | |
144 @@ -5,1 +5,1 @@ 4 | |
145 -5 | |
146 +55 | |
147 record this change to 'a'? [Ynesfdaq?] y | |
148 | |
149 EDITOR: HG: Splitting 1df0d5c5a3ab. Write commit message for the first split changeset. | |
150 EDITOR: a2 | |
151 EDITOR: | |
152 EDITOR: | |
153 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
154 EDITOR: HG: Leave message empty to abort commit. | |
155 EDITOR: HG: -- | |
156 EDITOR: HG: user: test | |
157 EDITOR: HG: branch 'default' | |
158 EDITOR: HG: changed a | |
159 created new head | |
160 diff --git a/a b/a | |
161 1 hunks, 1 lines changed | |
162 examine changes to 'a'? [Ynesfdaq?] y | |
163 | |
164 @@ -3,1 +3,1 @@ 2 | |
165 -3 | |
166 +33 | |
167 record this change to 'a'? [Ynesfdaq?] y | |
168 | |
169 EDITOR: HG: Splitting 1df0d5c5a3ab. So far it has been split into: | |
170 EDITOR: HG: - e704349bd21b: split 1 | |
171 EDITOR: HG: Write commit message for the next split changeset. | |
172 EDITOR: a2 | |
173 EDITOR: | |
174 EDITOR: | |
175 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
176 EDITOR: HG: Leave message empty to abort commit. | |
177 EDITOR: HG: -- | |
178 EDITOR: HG: user: test | |
179 EDITOR: HG: branch 'default' | |
180 EDITOR: HG: changed a | |
181 diff --git a/a b/a | |
182 1 hunks, 1 lines changed | |
183 examine changes to 'a'? [Ynesfdaq?] y | |
184 | |
185 @@ -1,1 +1,1 @@ | |
186 -1 | |
187 +11 | |
188 record this change to 'a'? [Ynesfdaq?] y | |
189 | |
190 EDITOR: HG: Splitting 1df0d5c5a3ab. So far it has been split into: | |
191 EDITOR: HG: - e704349bd21b: split 1 | |
192 EDITOR: HG: - a09ad58faae3: split 2 | |
193 EDITOR: HG: Write commit message for the next split changeset. | |
194 EDITOR: a2 | |
195 EDITOR: | |
196 EDITOR: | |
197 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
198 EDITOR: HG: Leave message empty to abort commit. | |
199 EDITOR: HG: -- | |
200 EDITOR: HG: user: test | |
201 EDITOR: HG: branch 'default' | |
202 EDITOR: HG: changed a | |
35479
8d05705bde0a
test-split: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
35455
diff
changeset
|
203 saved backup bundle to $TESTTMP/a/.hg/strip-backup/1df0d5c5a3ab-8341b760-split.hg (obsstore-off !) |
35455 | 204 |
205 #if obsstore-off | |
206 $ hg bookmark | |
207 r1 0:a61bcde8c529 | |
208 r2 3:00eebaf8d2e2 | |
209 * r3 3:00eebaf8d2e2 | |
210 $ hg glog -p | |
211 @ 3:00eebaf8d2e2 split 3 r2 r3 | |
212 | diff --git a/a b/a | |
213 | --- a/a | |
214 | +++ b/a | |
215 | @@ -1,1 +1,1 @@ | |
216 | -1 | |
217 | +11 | |
218 | | |
219 o 2:a09ad58faae3 split 2 | |
220 | diff --git a/a b/a | |
221 | --- a/a | |
222 | +++ b/a | |
223 | @@ -3,1 +3,1 @@ | |
224 | -3 | |
225 | +33 | |
226 | | |
227 o 1:e704349bd21b split 1 | |
228 | diff --git a/a b/a | |
229 | --- a/a | |
230 | +++ b/a | |
231 | @@ -5,1 +5,1 @@ | |
232 | -5 | |
233 | +55 | |
234 | | |
235 o 0:a61bcde8c529 a1 r1 | |
236 diff --git a/a b/a | |
237 new file mode 100644 | |
238 --- /dev/null | |
239 +++ b/a | |
240 @@ -0,0 +1,5 @@ | |
241 +1 | |
242 +2 | |
243 +3 | |
244 +4 | |
245 +5 | |
246 | |
247 #else | |
248 $ hg bookmark | |
249 r1 0:a61bcde8c529 | |
250 r2 4:00eebaf8d2e2 | |
251 * r3 4:00eebaf8d2e2 | |
252 $ hg glog | |
253 @ 4:00eebaf8d2e2 split 3 r2 r3 | |
254 | | |
255 o 3:a09ad58faae3 split 2 | |
256 | | |
257 o 2:e704349bd21b split 1 | |
258 | | |
259 o 0:a61bcde8c529 a1 r1 | |
260 | |
261 #endif | |
262 | |
263 Split a head while working parent is not that head | |
264 | |
265 $ cd $TESTTMP/b | |
266 | |
267 $ hg up 0 -q | |
268 $ hg bookmark r3 | |
269 | |
270 $ runsplit tip >/dev/null | |
271 | |
272 #if obsstore-off | |
273 $ hg bookmark | |
274 r1 0:a61bcde8c529 | |
275 r2 3:00eebaf8d2e2 | |
276 * r3 0:a61bcde8c529 | |
277 $ hg glog | |
278 o 3:00eebaf8d2e2 split 3 r2 | |
279 | | |
280 o 2:a09ad58faae3 split 2 | |
281 | | |
282 o 1:e704349bd21b split 1 | |
283 | | |
284 @ 0:a61bcde8c529 a1 r1 r3 | |
285 | |
286 #else | |
287 $ hg bookmark | |
288 r1 0:a61bcde8c529 | |
289 r2 4:00eebaf8d2e2 | |
290 * r3 0:a61bcde8c529 | |
291 $ hg glog | |
292 o 4:00eebaf8d2e2 split 3 r2 | |
293 | | |
294 o 3:a09ad58faae3 split 2 | |
295 | | |
296 o 2:e704349bd21b split 1 | |
297 | | |
298 @ 0:a61bcde8c529 a1 r1 r3 | |
299 | |
300 #endif | |
301 | |
302 Split a non-head | |
303 | |
304 $ cd $TESTTMP/c | |
305 $ echo d > d | |
306 $ hg ci -m d1 -A d | |
307 $ hg bookmark -i d1 | |
308 $ echo 2 >> d | |
309 $ hg ci -m d2 | |
310 $ echo 3 >> d | |
311 $ hg ci -m d3 | |
312 $ hg bookmark -i d3 | |
313 $ hg up '.^' -q | |
314 $ hg bookmark d2 | |
315 $ cp -R . ../d | |
316 | |
317 $ runsplit -r 1 | grep rebasing | |
318 rebasing 2:b5c5ea414030 "d1" (d1) | |
319 rebasing 3:f4a0a8d004cc "d2" (d2) | |
320 rebasing 4:777940761eba "d3" (d3) | |
321 #if obsstore-off | |
322 $ hg bookmark | |
323 d1 4:c4b449ef030e | |
324 * d2 5:c9dd00ab36a3 | |
325 d3 6:19f476bc865c | |
326 r1 0:a61bcde8c529 | |
327 r2 3:00eebaf8d2e2 | |
328 $ hg glog -p | |
329 o 6:19f476bc865c d3 d3 | |
330 | diff --git a/d b/d | |
331 | --- a/d | |
332 | +++ b/d | |
333 | @@ -2,0 +3,1 @@ | |
334 | +3 | |
335 | | |
336 @ 5:c9dd00ab36a3 d2 d2 | |
337 | diff --git a/d b/d | |
338 | --- a/d | |
339 | +++ b/d | |
340 | @@ -1,0 +2,1 @@ | |
341 | +2 | |
342 | | |
343 o 4:c4b449ef030e d1 d1 | |
344 | diff --git a/d b/d | |
345 | new file mode 100644 | |
346 | --- /dev/null | |
347 | +++ b/d | |
348 | @@ -0,0 +1,1 @@ | |
349 | +d | |
350 | | |
351 o 3:00eebaf8d2e2 split 3 r2 | |
352 | diff --git a/a b/a | |
353 | --- a/a | |
354 | +++ b/a | |
355 | @@ -1,1 +1,1 @@ | |
356 | -1 | |
357 | +11 | |
358 | | |
359 o 2:a09ad58faae3 split 2 | |
360 | diff --git a/a b/a | |
361 | --- a/a | |
362 | +++ b/a | |
363 | @@ -3,1 +3,1 @@ | |
364 | -3 | |
365 | +33 | |
366 | | |
367 o 1:e704349bd21b split 1 | |
368 | diff --git a/a b/a | |
369 | --- a/a | |
370 | +++ b/a | |
371 | @@ -5,1 +5,1 @@ | |
372 | -5 | |
373 | +55 | |
374 | | |
375 o 0:a61bcde8c529 a1 r1 | |
376 diff --git a/a b/a | |
377 new file mode 100644 | |
378 --- /dev/null | |
379 +++ b/a | |
380 @@ -0,0 +1,5 @@ | |
381 +1 | |
382 +2 | |
383 +3 | |
384 +4 | |
385 +5 | |
386 | |
387 #else | |
388 $ hg bookmark | |
389 d1 8:c4b449ef030e | |
390 * d2 9:c9dd00ab36a3 | |
391 d3 10:19f476bc865c | |
392 r1 0:a61bcde8c529 | |
393 r2 7:00eebaf8d2e2 | |
394 $ hg glog | |
395 o 10:19f476bc865c d3 d3 | |
396 | | |
397 @ 9:c9dd00ab36a3 d2 d2 | |
398 | | |
399 o 8:c4b449ef030e d1 d1 | |
400 | | |
401 o 7:00eebaf8d2e2 split 3 r2 | |
402 | | |
403 o 6:a09ad58faae3 split 2 | |
404 | | |
405 o 5:e704349bd21b split 1 | |
406 | | |
407 o 0:a61bcde8c529 a1 r1 | |
408 | |
409 #endif | |
410 | |
411 Split a non-head without rebase | |
412 | |
413 $ cd $TESTTMP/d | |
414 #if obsstore-off | |
415 $ runsplit -r 1 --no-rebase | |
416 abort: cannot split changeset with children without rebase | |
417 [255] | |
418 #else | |
419 $ runsplit -r 1 --no-rebase >/dev/null | |
35709
1a09dad8b85a
evolution: report new unstable changesets
Martin von Zweigbergk <martinvonz@google.com>
parents:
35508
diff
changeset
|
420 3 new orphan changesets |
35455 | 421 $ hg bookmark |
422 d1 2:b5c5ea414030 | |
423 * d2 3:f4a0a8d004cc | |
424 d3 4:777940761eba | |
425 r1 0:a61bcde8c529 | |
426 r2 7:00eebaf8d2e2 | |
427 | |
428 $ hg glog | |
429 o 7:00eebaf8d2e2 split 3 r2 | |
430 | | |
431 o 6:a09ad58faae3 split 2 | |
432 | | |
433 o 5:e704349bd21b split 1 | |
434 | | |
35508
9b3f95d9783d
graphlog: add another graph node type, unstable, using character "*" (BC)
Anton Shestakov <av6@dwimlabs.net>
parents:
35479
diff
changeset
|
435 | * 4:777940761eba d3 d3 |
35455 | 436 | | |
437 | @ 3:f4a0a8d004cc d2 d2 | |
438 | | | |
35508
9b3f95d9783d
graphlog: add another graph node type, unstable, using character "*" (BC)
Anton Shestakov <av6@dwimlabs.net>
parents:
35479
diff
changeset
|
439 | * 2:b5c5ea414030 d1 d1 |
35455 | 440 | | |
441 | x 1:1df0d5c5a3ab a2 | |
442 |/ | |
443 o 0:a61bcde8c529 a1 r1 | |
444 | |
445 #endif | |
446 | |
447 Split a non-head with obsoleted descendants | |
448 | |
449 #if obsstore-on | |
450 $ hg init $TESTTMP/e | |
451 $ cd $TESTTMP/e | |
452 $ hg debugdrawdag <<'EOS' | |
453 > H I J | |
454 > | | | | |
455 > F G1 G2 # amend: G1 -> G2 | |
456 > | | / # prune: F | |
457 > C D E | |
458 > \|/ | |
459 > B | |
460 > | | |
461 > A | |
462 > EOS | |
35709
1a09dad8b85a
evolution: report new unstable changesets
Martin von Zweigbergk <martinvonz@google.com>
parents:
35508
diff
changeset
|
463 2 new orphan changesets |
35455 | 464 $ eval `hg tags -T '{tag}={node}\n'` |
465 $ rm .hg/localtags | |
466 $ hg split $B --config experimental.evolution=createmarkers | |
467 abort: split would leave orphaned changesets behind | |
468 [255] | |
469 $ cat > $TESTTMP/messages <<EOF | |
470 > Split B | |
471 > EOF | |
472 $ cat <<EOF | hg split $B | |
473 > y | |
474 > y | |
475 > EOF | |
476 diff --git a/B b/B | |
477 new file mode 100644 | |
478 examine changes to 'B'? [Ynesfdaq?] y | |
479 | |
480 @@ -0,0 +1,1 @@ | |
481 +B | |
482 \ No newline at end of file | |
483 record this change to 'B'? [Ynesfdaq?] y | |
484 | |
485 EDITOR: HG: Splitting 112478962961. Write commit message for the first split changeset. | |
486 EDITOR: B | |
487 EDITOR: | |
488 EDITOR: | |
489 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
490 EDITOR: HG: Leave message empty to abort commit. | |
491 EDITOR: HG: -- | |
492 EDITOR: HG: user: test | |
493 EDITOR: HG: branch 'default' | |
494 EDITOR: HG: added B | |
495 created new head | |
496 rebasing 2:26805aba1e60 "C" | |
497 rebasing 3:be0ef73c17ad "D" | |
498 rebasing 4:49cb92066bfd "E" | |
499 rebasing 7:97a6268cc7ef "G2" | |
500 rebasing 10:e2f1e425c0db "J" | |
501 $ hg glog -r 'sort(all(), topo)' | |
502 o 16:556c085f8b52 J | |
503 | | |
504 o 15:8761f6c9123f G2 | |
505 | | |
506 o 14:a7aeffe59b65 E | |
507 | | |
508 | o 13:e1e914ede9ab D | |
509 |/ | |
510 | o 12:01947e9b98aa C | |
511 |/ | |
512 o 11:0947baa74d47 Split B | |
513 | | |
35508
9b3f95d9783d
graphlog: add another graph node type, unstable, using character "*" (BC)
Anton Shestakov <av6@dwimlabs.net>
parents:
35479
diff
changeset
|
514 | * 9:88ede1d5ee13 I |
35455 | 515 | | |
516 | x 6:af8cbf225b7b G1 | |
517 | | | |
518 | x 3:be0ef73c17ad D | |
519 | | | |
35508
9b3f95d9783d
graphlog: add another graph node type, unstable, using character "*" (BC)
Anton Shestakov <av6@dwimlabs.net>
parents:
35479
diff
changeset
|
520 | | * 8:74863e5b5074 H |
35455 | 521 | | | |
522 | | x 5:ee481a2a1e69 F | |
523 | | | | |
524 | | x 2:26805aba1e60 C | |
525 | |/ | |
526 | x 1:112478962961 B | |
527 |/ | |
528 o 0:426bada5c675 A | |
529 | |
530 #endif |