##// END OF EJS Templates
generate-working-copy-states: accept depth arguments on command line...
Martin von Zweigbergk -
r23447:815e76a4 default
parent child Browse files
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 import sys
32 import sys
3 import os
33 import os
4
34
@@ -21,25 +51,27 b' def generatestates(maxchangesets, parent'
21 parentcontents + [content]):
51 parentcontents + [content]):
22 yield combination
52 yield combination
23
53
24 # sort to make sure we have stable output
54 # retrieve the command line arguments
25 combinations = sorted(generatestates(2, []))
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
60 # sort to make sure we have stable output
28 target = sys.argv[1]
61 combinations = sorted(generatestates(maxchangesets, []))
29
62
30 # compute file content
63 # compute file content
31 content = []
64 content = []
32 for filename, [base, parent, wcc] in combinations:
65 for filename, states in combinations:
33 if target == 'filelist':
66 if target == 'filelist':
34 print filename
67 print filename
35 elif target == 'base':
68 elif target == 'state':
36 content.append((filename, base))
69 if depth == 'wc':
37 elif target == 'parent':
70 # Make sure there is content so the file gets written and can be
38 content.append((filename, parent))
71 # tracked. It will be deleted outside of this script.
39 elif target == 'wc':
72 content.append((filename, states[maxchangesets] or 'TOBEDELETED'))
40 # Make sure there is content so the file gets written and can be
73 else:
41 # tracked. It will be deleted outside of this script.
74 content.append((filename, states[int(depth) - 1]))
42 content.append((filename, wcc or 'TOBEDELETED'))
43 else:
75 else:
44 print >> sys.stderr, "unknown target:", target
76 print >> sys.stderr, "unknown target:", target
45 sys.exit(1)
77 sys.exit(1)
@@ -430,7 +430,7 b' Write the python script to disk'
430
430
431 check list of planned files
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 content1_content1_content1-tracked
434 content1_content1_content1-tracked
435 content1_content1_content1-untracked
435 content1_content1_content1-untracked
436 content1_content1_content3-tracked
436 content1_content1_content3-tracked
@@ -485,7 +485,7 b' Generate appropriate repo state'
485
485
486 Generate base changeset
486 Generate base changeset
487
487
488 $ python $TESTDIR/generate-working-copy-states.py base
488 $ python $TESTDIR/generate-working-copy-states.py state 2 1
489 $ hg addremove --similarity 0
489 $ hg addremove --similarity 0
490 adding content1_content1_content1-tracked
490 adding content1_content1_content1-tracked
491 adding content1_content1_content1-untracked
491 adding content1_content1_content1-untracked
@@ -557,7 +557,7 b' Generate base changeset'
557
557
558 Create parent changeset
558 Create parent changeset
559
559
560 $ python $TESTDIR/generate-working-copy-states.py parent
560 $ python $TESTDIR/generate-working-copy-states.py state 2 2
561 $ hg addremove --similarity 0
561 $ hg addremove --similarity 0
562 removing content1_missing_content1-tracked
562 removing content1_missing_content1-tracked
563 removing content1_missing_content1-untracked
563 removing content1_missing_content1-untracked
@@ -621,7 +621,7 b' Create parent changeset'
621
621
622 Setup working directory
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 $ hg addremove --similarity 0
625 $ hg addremove --similarity 0
626 adding content1_missing_content1-tracked
626 adding content1_missing_content1-tracked
627 adding content1_missing_content1-untracked
627 adding content1_missing_content1-untracked
@@ -838,7 +838,7 b' Test revert to parent content with expli'
838 revert all files individually and check the output
838 revert all files individually and check the output
839 (output is expected to be different than in the --all case)
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 > echo '### revert for:' $file;
842 > echo '### revert for:' $file;
843 > hg revert $file;
843 > hg revert $file;
844 > echo
844 > echo
@@ -931,7 +931,7 b' Test revert to "base" content with expli'
931 revert all files individually and check the output
931 revert all files individually and check the output
932 (output is expected to be different than in the --all case)
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 > echo '### revert for:' $file;
935 > echo '### revert for:' $file;
936 > hg revert $file --rev 'desc(base)';
936 > hg revert $file --rev 'desc(base)';
937 > echo
937 > echo
@@ -5,7 +5,7 b' combined correctly with the dirstate sta'
5
5
6 First commit
6 First commit
7
7
8 $ python $TESTDIR/generate-working-copy-states.py base
8 $ python $TESTDIR/generate-working-copy-states.py state 2 1
9 $ hg addremove --similarity 0
9 $ hg addremove --similarity 0
10 adding content1_content1_content1-tracked
10 adding content1_content1_content1-tracked
11 adding content1_content1_content1-untracked
11 adding content1_content1_content1-untracked
@@ -31,7 +31,7 b' First commit'
31
31
32 Second commit
32 Second commit
33
33
34 $ python $TESTDIR/generate-working-copy-states.py parent
34 $ python $TESTDIR/generate-working-copy-states.py state 2 2
35 $ hg addremove --similarity 0
35 $ hg addremove --similarity 0
36 removing content1_missing_content1-tracked
36 removing content1_missing_content1-tracked
37 removing content1_missing_content1-untracked
37 removing content1_missing_content1-untracked
@@ -49,7 +49,7 b' Second commit'
49
49
50 Working copy
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 $ hg addremove --similarity 0
53 $ hg addremove --similarity 0
54 adding content1_missing_content1-tracked
54 adding content1_missing_content1-tracked
55 adding content1_missing_content1-untracked
55 adding content1_missing_content1-untracked
General Comments 0
You need to be logged in to leave comments. Login now