Show More
@@ -0,0 +1,50 b'' | |||
|
1 | # generate proper file state to test working copy behavior | |
|
2 | import sys | |
|
3 | import os | |
|
4 | ||
|
5 | # build the combination of possible states | |
|
6 | combination = [] | |
|
7 | for base in [None, 'content1']: | |
|
8 | for parent in set([None, 'content2']) | set([base]): | |
|
9 | for wcc in set([None, 'content3']) | set([base, parent]): | |
|
10 | for tracked in (False, True): | |
|
11 | def statestring(content): | |
|
12 | return content is None and 'missing' or content | |
|
13 | trackedstring = tracked and 'tracked' or 'untracked' | |
|
14 | filename = "%s_%s_%s-%s" % (statestring(base), | |
|
15 | statestring(parent), | |
|
16 | statestring(wcc), | |
|
17 | trackedstring) | |
|
18 | combination.append((filename, base, parent, wcc)) | |
|
19 | ||
|
20 | # make sure we have stable output | |
|
21 | combination.sort() | |
|
22 | ||
|
23 | # retrieve the state we must generate | |
|
24 | target = sys.argv[1] | |
|
25 | ||
|
26 | # compute file content | |
|
27 | content = [] | |
|
28 | for filename, base, parent, wcc in combination: | |
|
29 | if target == 'filelist': | |
|
30 | print filename | |
|
31 | elif target == 'base': | |
|
32 | content.append((filename, base)) | |
|
33 | elif target == 'parent': | |
|
34 | content.append((filename, parent)) | |
|
35 | elif target == 'wc': | |
|
36 | # Make sure there is content so the file gets written and can be | |
|
37 | # tracked. It will be deleted outside of this script. | |
|
38 | content.append((filename, wcc or 'TOBEDELETED')) | |
|
39 | else: | |
|
40 | print >> sys.stderr, "unknown target:", target | |
|
41 | sys.exit(1) | |
|
42 | ||
|
43 | # write actual content | |
|
44 | for filename, data in content: | |
|
45 | if data is not None: | |
|
46 | f = open(filename, 'w') | |
|
47 | f.write(data + '\n') | |
|
48 | f.close() | |
|
49 | elif os.path.exists(filename): | |
|
50 | os.remove(filename) |
@@ -422,62 +422,9 b' Special cases from merge and rename are ' | |||
|
422 | 422 | Write the python script to disk |
|
423 | 423 | ------------------------------- |
|
424 | 424 | |
|
425 | $ cat << EOF > gen-revert-cases.py | |
|
426 | > # generate proper file state to test revert behavior | |
|
427 | > import sys | |
|
428 | > import os | |
|
429 | > | |
|
430 | > # build the combination of possible states | |
|
431 | > combination = [] | |
|
432 | > for base in [None, 'content1']: | |
|
433 | > for parent in set([None, 'content2']) | set([base]): | |
|
434 | > for wcc in set([None, 'content3']) | set([base, parent]): | |
|
435 | > for tracked in (False, True): | |
|
436 | > def statestring(content): | |
|
437 | > return content is None and 'missing' or content | |
|
438 | > trackedstring = tracked and 'tracked' or 'untracked' | |
|
439 | > filename = "%s_%s_%s-%s" % (statestring(base), | |
|
440 | > statestring(parent), | |
|
441 | > statestring(wcc), | |
|
442 | > trackedstring) | |
|
443 | > combination.append((filename, base, parent, wcc)) | |
|
444 | > | |
|
445 | > # make sure we have stable output | |
|
446 | > combination.sort() | |
|
447 | > | |
|
448 | > # retrieve the state we must generate | |
|
449 | > target = sys.argv[1] | |
|
450 | > | |
|
451 | > # compute file content | |
|
452 | > content = [] | |
|
453 | > for filename, base, parent, wcc in combination: | |
|
454 | > if target == 'filelist': | |
|
455 | > print filename | |
|
456 | > elif target == 'base': | |
|
457 | > content.append((filename, base)) | |
|
458 | > elif target == 'parent': | |
|
459 | > content.append((filename, parent)) | |
|
460 | > elif target == 'wc': | |
|
461 | > # Make sure there is content so the file gets written and can be | |
|
462 | > # tracked. It will be deleted outside of this script. | |
|
463 | > content.append((filename, wcc or 'TOBEDELETED')) | |
|
464 | > else: | |
|
465 | > print >> sys.stderr, "unknown target:", target | |
|
466 | > sys.exit(1) | |
|
467 | > | |
|
468 | > # write actual content | |
|
469 | > for filename, data in content: | |
|
470 | > if data is not None: | |
|
471 | > f = open(filename, 'w') | |
|
472 | > f.write(data + '\n') | |
|
473 | > f.close() | |
|
474 | > elif os.path.exists(filename): | |
|
475 | > os.remove(filename) | |
|
476 | > EOF | |
|
477 | ||
|
478 | 425 | check list of planned files |
|
479 | 426 | |
|
480 |
$ python |
|
|
427 | $ python $TESTDIR/generate-working-copy-states.py filelist | |
|
481 | 428 | content1_content1_content1-tracked |
|
482 | 429 | content1_content1_content1-untracked |
|
483 | 430 | content1_content1_content3-tracked |
@@ -532,7 +479,7 b' Generate appropriate repo state' | |||
|
532 | 479 | |
|
533 | 480 | Generate base changeset |
|
534 | 481 | |
|
535 |
$ python |
|
|
482 | $ python $TESTDIR/generate-working-copy-states.py base | |
|
536 | 483 | $ hg addremove --similarity 0 |
|
537 | 484 | adding content1_content1_content1-tracked |
|
538 | 485 | adding content1_content1_content1-untracked |
@@ -604,7 +551,7 b' Generate base changeset' | |||
|
604 | 551 | |
|
605 | 552 | Create parent changeset |
|
606 | 553 | |
|
607 |
$ python |
|
|
554 | $ python $TESTDIR/generate-working-copy-states.py parent | |
|
608 | 555 | $ hg addremove --similarity 0 |
|
609 | 556 | removing content1_missing_content1-tracked |
|
610 | 557 | removing content1_missing_content1-untracked |
@@ -668,7 +615,7 b' Create parent changeset' | |||
|
668 | 615 | |
|
669 | 616 | Setup working directory |
|
670 | 617 | |
|
671 |
$ python |
|
|
618 | $ python $TESTDIR/generate-working-copy-states.py wc | |
|
672 | 619 | $ hg addremove --similarity 0 |
|
673 | 620 | adding content1_missing_content1-tracked |
|
674 | 621 | adding content1_missing_content1-untracked |
@@ -885,7 +832,7 b' Test revert to parent content with expli' | |||
|
885 | 832 | revert all files individually and check the output |
|
886 | 833 | (output is expected to be different than in the --all case) |
|
887 | 834 | |
|
888 |
$ for file in `python |
|
|
835 | $ for file in `python $TESTDIR/generate-working-copy-states.py filelist`; do | |
|
889 | 836 | > echo '### revert for:' $file; |
|
890 | 837 | > hg revert $file; |
|
891 | 838 | > echo |
@@ -978,7 +925,7 b' Test revert to "base" content with expli' | |||
|
978 | 925 | revert all files individually and check the output |
|
979 | 926 | (output is expected to be different than in the --all case) |
|
980 | 927 | |
|
981 |
$ for file in `python |
|
|
928 | $ for file in `python $TESTDIR/generate-working-copy-states.py filelist`; do | |
|
982 | 929 | > echo '### revert for:' $file; |
|
983 | 930 | > hg revert $file --rev 'desc(base)'; |
|
984 | 931 | > echo |
General Comments 0
You need to be logged in to leave comments.
Login now