Mercurial > hg-onsub
annotate test-onsub.t @ 8:ecc4fd16555d
Add --max-depth option to limit depth of recursion.
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Sun, 24 Apr 2011 11:09:36 -0400 |
parents | a2ad7553ba79 |
children | 4cb3f28590fd |
rev | line source |
---|---|
0 | 1 Load extension: |
2 | |
3 $ echo "[extensions]" >> $HGRCPATH | |
4 $ echo "onsub = $TESTDIR/onsub.py" >> $HGRCPATH | |
5 | |
6 Check help formatting: | |
7 | |
8 $ hg help onsub | |
3 | 9 hg onsub [-b] [-0] [--ignore-errors] CMD |
0 | 10 |
11 execute a command in each subrepository | |
12 | |
7
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
5
diff
changeset
|
13 Executes CMD with the current working directory set to the root of each |
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
5
diff
changeset
|
14 subrepository. By default, execution stops if CMD returns a non-zero exit |
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
5
diff
changeset
|
15 code. Use --ignore-errors to override this. |
0 | 16 |
7
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
5
diff
changeset
|
17 Use --verbose/-v to print the command being run and the subrepo name for |
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
5
diff
changeset
|
18 each run of CMD in a subrepo. Alternately, use --print0/-0 to print just |
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
5
diff
changeset
|
19 the subrepo name followed by a NUL character instead of a newline. This |
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
5
diff
changeset
|
20 can be useful in combination with "hg status --print0". |
0 | 21 |
22 The command has access to the following environment variables: | |
23 | |
24 "HG_REPO": | |
25 Absolute path to the top-level repository in which the onsub command | |
26 was executed. | |
27 | |
28 "HG_SUBPATH": | |
29 Relative path to the current subrepository from the top-level | |
30 repository. | |
31 | |
32 "HG_SUBURL": | |
33 URL for the current subrepository as specified in the containing | |
34 repository's ".hgsub" file. | |
35 | |
36 "HG_SUBSTATE": | |
37 State of the current subrepository as specified in the containing | |
38 repository's ".hgsubstate" file. | |
39 | |
40 options: | |
41 | |
42 -b --breadth-first use breadth-first traversal | |
8
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
43 --max-depth N limit recursion to N levels (negative for no limit) |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
44 (default: -1) |
3 | 45 --ignore-errors continue execution despite errors |
0 | 46 -0 --print0 end subrepository names with NUL, for use with xargs |
47 | |
48 use "hg -v help onsub" to show global options | |
49 | |
50 Create some nicely nested subrepositories: | |
51 | |
52 $ hg init | |
53 $ for d in a b; do hg init $d; echo "$d = $d" >> .hgsub; done | |
54 $ hg add .hgsub | |
55 | |
56 $ cd a | |
57 | |
58 $ for d in x y; do hg init $d; echo "$d = $d" >> .hgsub; done | |
59 $ hg add .hgsub | |
60 | |
61 $ cd y | |
62 $ for d in r s t; do hg init $d; echo "$d = $d" >> .hgsub; done | |
63 $ hg add .hgsub | |
64 $ cd .. | |
65 | |
66 $ cd .. | |
67 | |
68 $ cd b | |
69 $ for d in u v; do hg init $d; echo "$d = $d" >> .hgsub; done | |
70 $ hg add .hgsub | |
71 $ cd .. | |
72 | |
73 $ hg commit -m init | |
74 committing subrepository a | |
75 committing subrepository a/x | |
76 committing subrepository a/y | |
77 committing subrepository a/y/r | |
78 committing subrepository a/y/s | |
79 committing subrepository a/y/t | |
80 committing subrepository b | |
81 committing subrepository b/u | |
82 committing subrepository b/v | |
83 | |
84 The default depth-first traversal: | |
85 | |
86 $ hg onsub 'echo $HG_SUBPATH' | |
87 a | |
88 a/x | |
89 a/y | |
90 a/y/r | |
91 a/y/s | |
92 a/y/t | |
93 b | |
94 b/u | |
95 b/v | |
96 | |
97 Breadth-first traversal: | |
98 | |
99 $ hg onsub 'echo $HG_SUBPATH' --breadth-first | |
100 a | |
101 b | |
102 a/x | |
103 a/y | |
104 b/u | |
105 b/v | |
106 a/y/r | |
107 a/y/s | |
108 a/y/t | |
109 | |
8
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
110 Limit depth of traversal: |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
111 $ hg onsub --max-depth 1 'echo $HG_SUBPATH' |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
112 a |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
113 b |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
114 $ hg onsub --max-depth 2 'echo $HG_SUBPATH' |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
115 a |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
116 a/x |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
117 a/y |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
118 b |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
119 b/u |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
120 b/v |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
121 $ hg onsub --max-depth 2 -b 'echo $HG_SUBPATH' |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
122 a |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
123 b |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
124 a/x |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
125 a/y |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
126 b/u |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
127 b/v |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
128 |
0 | 129 Test aborting: |
130 | |
131 $ hg onsub -v 'test $HG_SUBPATH != "a/y/r"' | |
132 executing 'test $HG_SUBPATH != "a/y/r"' in a | |
133 executing 'test $HG_SUBPATH != "a/y/r"' in a/x | |
134 executing 'test $HG_SUBPATH != "a/y/r"' in a/y | |
135 executing 'test $HG_SUBPATH != "a/y/r"' in a/y/r | |
136 abort: terminated onsub in a/y/r: test exited with status 1 | |
5
73658c424c7b
Adapt to new run-tests.py output
Martin Geisler <mg@aragost.com>
parents:
3
diff
changeset
|
137 [255] |
0 | 138 |
3 | 139 Test aborting: |
140 | |
141 $ hg onsub -v --ignore-errors false | |
142 executing 'false' in a | |
143 executing 'false' in a/x | |
144 executing 'false' in a/y | |
145 executing 'false' in a/y/r | |
146 executing 'false' in a/y/s | |
147 executing 'false' in a/y/t | |
148 executing 'false' in b | |
149 executing 'false' in b/u | |
150 executing 'false' in b/v | |
151 | |
0 | 152 Test --print0: |
153 | |
154 $ mv a 'with spaces' | |
155 $ echo 'with spaces = with spaces' > .hgsub | |
156 $ echo 'b = b' >> .hgsub | |
157 $ hg commit -m rename | |
158 committing subrepository with spaces | |
159 $ hg onsub -0 | xargs -n 1 -0 | |
160 b | |
161 b/u | |
162 b/v | |
163 with spaces | |
164 with spaces/x | |
165 with spaces/y | |
166 with spaces/y/r | |
167 with spaces/y/s | |
168 with spaces/y/t |