Show More
@@ -1,4 +1,34 b'' | |||
|
1 | # generate proper file state to test working copy behavior | |
|
1 | # Helper script used for generating history and working copy files and content. | |
|
2 | # The file's name corresponds to its history. The number of changesets can | |
|
3 | # be specified on the command line. With 2 changesets, files with names like | |
|
4 | # content1_content2_content1-untracked are generated. The first two filename | |
|
5 | # segments describe the contents in the two changesets. The third segment | |
|
6 | # ("content1-untracked") describes the state in the working copy, i.e. | |
|
7 | # the file has content "content1" and is untracked (since it was previously | |
|
8 | # tracked, it has been forgotten). | |
|
9 | # | |
|
10 | # This script generates the filenames and their content, but it's up to the | |
|
11 | # caller to tell hg about the state. | |
|
12 | # | |
|
13 | # There are two subcommands: | |
|
14 | # filelist <numchangesets> | |
|
15 | # state <numchangesets> (<changeset>|wc) | |
|
16 | # | |
|
17 | # Typical usage: | |
|
18 | # | |
|
19 | # $ python $TESTDIR/generate-working-copy-states.py state 2 1 | |
|
20 | # $ hg addremove --similarity 0 | |
|
21 | # $ hg commit -m 'first' | |
|
22 | # | |
|
23 | # $ python $TESTDIR/generate-working-copy-states.py state 2 1 | |
|
24 | # $ hg addremove --similarity 0 | |
|
25 | # $ hg commit -m 'second' | |
|
26 | # | |
|
27 | # $ python $TESTDIR/generate-working-copy-states.py state 2 wc | |
|
28 | # $ hg addremove --similarity 0 | |
|
29 | # $ hg forget *_*_*-untracked | |
|
30 | # $ rm *_*_missing-* | |
|
31 | ||
|
2 | 32 | import sys |
|
3 | 33 | import os |
|
4 | 34 | |
@@ -21,25 +51,27 b' def generatestates(maxchangesets, parent' | |||
|
21 | 51 | parentcontents + [content]): |
|
22 | 52 | yield combination |
|
23 | 53 | |
|
24 | # sort to make sure we have stable output | |
|
25 | combinations = sorted(generatestates(2, [])) | |
|
54 | # retrieve the command line arguments | |
|
55 | target = sys.argv[1] | |
|
56 | maxchangesets = int(sys.argv[2]) | |
|
57 | if target == 'state': | |
|
58 | depth = sys.argv[3] | |
|
26 | 59 | |
|
27 | # retrieve the state we must generate | |
|
28 | target = sys.argv[1] | |
|
60 | # sort to make sure we have stable output | |
|
61 | combinations = sorted(generatestates(maxchangesets, [])) | |
|
29 | 62 | |
|
30 | 63 | # compute file content |
|
31 | 64 | content = [] |
|
32 |
for filename, |
|
|
65 | for filename, states in combinations: | |
|
33 | 66 | if target == 'filelist': |
|
34 | 67 | print filename |
|
35 |
elif target == ' |
|
|
36 | content.append((filename, base)) | |
|
37 | elif target == 'parent': | |
|
38 | content.append((filename, parent)) | |
|
39 | elif target == 'wc': | |
|
40 | # Make sure there is content so the file gets written and can be | |
|
41 | # tracked. It will be deleted outside of this script. | |
|
42 | content.append((filename, wcc or 'TOBEDELETED')) | |
|
68 | elif target == 'state': | |
|
69 | if depth == 'wc': | |
|
70 | # Make sure there is content so the file gets written and can be | |
|
71 | # tracked. It will be deleted outside of this script. | |
|
72 | content.append((filename, states[maxchangesets] or 'TOBEDELETED')) | |
|
73 | else: | |
|
74 | content.append((filename, states[int(depth) - 1])) | |
|
43 | 75 | else: |
|
44 | 76 | print >> sys.stderr, "unknown target:", target |
|
45 | 77 | sys.exit(1) |
@@ -430,7 +430,7 b' Write the python script to disk' | |||
|
430 | 430 | |
|
431 | 431 | check list of planned files |
|
432 | 432 | |
|
433 | $ python $TESTDIR/generate-working-copy-states.py filelist | |
|
433 | $ python $TESTDIR/generate-working-copy-states.py filelist 2 | |
|
434 | 434 | content1_content1_content1-tracked |
|
435 | 435 | content1_content1_content1-untracked |
|
436 | 436 | content1_content1_content3-tracked |
@@ -485,7 +485,7 b' Generate appropriate repo state' | |||
|
485 | 485 | |
|
486 | 486 | Generate base changeset |
|
487 | 487 | |
|
488 |
$ python $TESTDIR/generate-working-copy-states.py |
|
|
488 | $ python $TESTDIR/generate-working-copy-states.py state 2 1 | |
|
489 | 489 | $ hg addremove --similarity 0 |
|
490 | 490 | adding content1_content1_content1-tracked |
|
491 | 491 | adding content1_content1_content1-untracked |
@@ -557,7 +557,7 b' Generate base changeset' | |||
|
557 | 557 | |
|
558 | 558 | Create parent changeset |
|
559 | 559 | |
|
560 |
$ python $TESTDIR/generate-working-copy-states.py |
|
|
560 | $ python $TESTDIR/generate-working-copy-states.py state 2 2 | |
|
561 | 561 | $ hg addremove --similarity 0 |
|
562 | 562 | removing content1_missing_content1-tracked |
|
563 | 563 | removing content1_missing_content1-untracked |
@@ -621,7 +621,7 b' Create parent changeset' | |||
|
621 | 621 | |
|
622 | 622 | Setup working directory |
|
623 | 623 | |
|
624 | $ python $TESTDIR/generate-working-copy-states.py wc | |
|
624 | $ python $TESTDIR/generate-working-copy-states.py state 2 wc | |
|
625 | 625 | $ hg addremove --similarity 0 |
|
626 | 626 | adding content1_missing_content1-tracked |
|
627 | 627 | adding content1_missing_content1-untracked |
@@ -838,7 +838,7 b' Test revert to parent content with expli' | |||
|
838 | 838 | revert all files individually and check the output |
|
839 | 839 | (output is expected to be different than in the --all case) |
|
840 | 840 | |
|
841 | $ for file in `python $TESTDIR/generate-working-copy-states.py filelist`; do | |
|
841 | $ for file in `python $TESTDIR/generate-working-copy-states.py filelist 2`; do | |
|
842 | 842 | > echo '### revert for:' $file; |
|
843 | 843 | > hg revert $file; |
|
844 | 844 | > echo |
@@ -931,7 +931,7 b' Test revert to "base" content with expli' | |||
|
931 | 931 | revert all files individually and check the output |
|
932 | 932 | (output is expected to be different than in the --all case) |
|
933 | 933 | |
|
934 | $ for file in `python $TESTDIR/generate-working-copy-states.py filelist`; do | |
|
934 | $ for file in `python $TESTDIR/generate-working-copy-states.py filelist 2`; do | |
|
935 | 935 | > echo '### revert for:' $file; |
|
936 | 936 | > hg revert $file --rev 'desc(base)'; |
|
937 | 937 | > echo |
@@ -5,7 +5,7 b' combined correctly with the dirstate sta' | |||
|
5 | 5 | |
|
6 | 6 | First commit |
|
7 | 7 | |
|
8 |
$ python $TESTDIR/generate-working-copy-states.py |
|
|
8 | $ python $TESTDIR/generate-working-copy-states.py state 2 1 | |
|
9 | 9 | $ hg addremove --similarity 0 |
|
10 | 10 | adding content1_content1_content1-tracked |
|
11 | 11 | adding content1_content1_content1-untracked |
@@ -31,7 +31,7 b' First commit' | |||
|
31 | 31 | |
|
32 | 32 | Second commit |
|
33 | 33 | |
|
34 |
$ python $TESTDIR/generate-working-copy-states.py |
|
|
34 | $ python $TESTDIR/generate-working-copy-states.py state 2 2 | |
|
35 | 35 | $ hg addremove --similarity 0 |
|
36 | 36 | removing content1_missing_content1-tracked |
|
37 | 37 | removing content1_missing_content1-untracked |
@@ -49,7 +49,7 b' Second commit' | |||
|
49 | 49 | |
|
50 | 50 | Working copy |
|
51 | 51 | |
|
52 | $ python $TESTDIR/generate-working-copy-states.py wc | |
|
52 | $ python $TESTDIR/generate-working-copy-states.py state 2 wc | |
|
53 | 53 | $ hg addremove --similarity 0 |
|
54 | 54 | adding content1_missing_content1-tracked |
|
55 | 55 | adding content1_missing_content1-untracked |
General Comments 0
You need to be logged in to leave comments.
Login now