Mercurial > hg-onsub
annotate test-onsub.t @ 17:5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Updated test.
Added a test for mixed subrepo cases.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 27 Mar 2012 16:53:23 -0700 |
parents | 34aa014b5989 |
children | d920e3425db5 |
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 | |
14 | 9 hg onsub [-b] [-0] [--ignore-errors] CMD [POST-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 |
14 | 17 If a POST-CMD is specified, this will be executed after all |
18 subrepositories below the current subrepository has been visited. This | |
19 corresponds to a post-order traversal of the tree. | |
20 | |
21 It is an error to specify a POST-CMD together with the --breadth-first | |
22 flag. | |
23 | |
7
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
5
diff
changeset
|
24 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
|
25 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
|
26 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
|
27 can be useful in combination with "hg status --print0". |
0 | 28 |
29 The command has access to the following environment variables: | |
30 | |
31 "HG_REPO": | |
32 Absolute path to the top-level repository in which the onsub command | |
33 was executed. | |
34 | |
35 "HG_SUBPATH": | |
36 Relative path to the current subrepository from the top-level | |
37 repository. | |
38 | |
39 "HG_SUBURL": | |
40 URL for the current subrepository as specified in the containing | |
41 repository's ".hgsub" file. | |
42 | |
43 "HG_SUBSTATE": | |
44 State of the current subrepository as specified in the containing | |
45 repository's ".hgsubstate" file. | |
46 | |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
14
diff
changeset
|
47 "HG_SUBTYPE": |
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
14
diff
changeset
|
48 The type of the current subrepository (hg, git or svn). |
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
14
diff
changeset
|
49 |
0 | 50 options: |
51 | |
12
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
52 -b --breadth-first use breadth-first traversal |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
53 -p --post-order use post-order depth-first traversal |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
54 --root-repo include root repository in traversal |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
55 --max-depth N limit recursion to N levels (negative for no limit) |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
56 (default: -1) |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
57 --ignore-errors continue execution despite errors |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
58 -0 --print0 end subrepository names with NUL, for use with xargs |
0 | 59 |
13
b10dd4461b52
More test updates for Mercurial 2.1
Martin Geisler <mg@aragost.com>
parents:
12
diff
changeset
|
60 use "hg -v help onsub" to show more info |
0 | 61 |
62 Create some nicely nested subrepositories: | |
63 | |
64 $ hg init | |
65 $ for d in a b; do hg init $d; echo "$d = $d" >> .hgsub; done | |
66 $ hg add .hgsub | |
67 | |
68 $ cd a | |
69 | |
70 $ for d in x y; do hg init $d; echo "$d = $d" >> .hgsub; done | |
71 $ hg add .hgsub | |
72 | |
73 $ cd y | |
74 $ for d in r s t; do hg init $d; echo "$d = $d" >> .hgsub; done | |
75 $ hg add .hgsub | |
76 $ cd .. | |
77 | |
78 $ cd .. | |
79 | |
80 $ cd b | |
81 $ for d in u v; do hg init $d; echo "$d = $d" >> .hgsub; done | |
82 $ hg add .hgsub | |
83 $ cd .. | |
84 | |
11
4cb3f28590fd
tests compatible with Mercurial 2.1
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
85 $ hg commit -m init -S |
0 | 86 committing subrepository a |
87 committing subrepository a/x | |
88 committing subrepository a/y | |
89 committing subrepository a/y/r | |
90 committing subrepository a/y/s | |
91 committing subrepository a/y/t | |
92 committing subrepository b | |
93 committing subrepository b/u | |
94 committing subrepository b/v | |
95 | |
12
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
96 The default depth-first pre-order traversal: |
0 | 97 |
98 $ hg onsub 'echo $HG_SUBPATH' | |
99 a | |
100 a/x | |
101 a/y | |
102 a/y/r | |
103 a/y/s | |
104 a/y/t | |
105 b | |
106 b/u | |
107 b/v | |
108 | |
12
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
109 Traversal including the root repository: |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
110 |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
111 $ hg onsub 'echo $HG_SUBPATH' --root-repo |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
112 . |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
113 a |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
114 a/x |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
115 a/y |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
116 a/y/r |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
117 a/y/s |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
118 a/y/t |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
119 b |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
120 b/u |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
121 b/v |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
122 |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
123 Depth-first post-order traversal: |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
124 |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
125 $ hg onsub 'echo $HG_SUBPATH' --post-order |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
126 a/x |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
127 a/y/r |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
128 a/y/s |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
129 a/y/t |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
130 a/y |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
131 a |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
132 b/u |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
133 b/v |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
134 b |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
135 |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
136 Depth-first pre- and post-order traversal: |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
137 |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
138 $ hg onsub 'echo pre $HG_SUBPATH' 'echo post $HG_SUBPATH' |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
139 pre a |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
140 pre a/x |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
141 post a/x |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
142 pre a/y |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
143 pre a/y/r |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
144 post a/y/r |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
145 pre a/y/s |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
146 post a/y/s |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
147 pre a/y/t |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
148 post a/y/t |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
149 post a/y |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
150 post a |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
151 pre b |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
152 pre b/u |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
153 post b/u |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
154 pre b/v |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
155 post b/v |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
156 post b |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
157 |
0 | 158 Breadth-first traversal: |
159 | |
160 $ hg onsub 'echo $HG_SUBPATH' --breadth-first | |
161 a | |
162 b | |
163 a/x | |
164 a/y | |
165 b/u | |
166 b/v | |
167 a/y/r | |
168 a/y/s | |
169 a/y/t | |
170 | |
8
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
171 Limit depth of traversal: |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
172 $ 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
|
173 a |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
174 b |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
175 $ 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
|
176 a |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
177 a/x |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
178 a/y |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
179 b |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
180 b/u |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
181 b/v |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
182 $ 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
|
183 a |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
184 b |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
185 a/x |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
186 a/y |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
187 b/u |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
188 b/v |
12
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
189 $ hg onsub --max-depth 1 -b --root-repo 'echo $HG_SUBPATH' |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
190 . |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
191 a |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
192 b |
8
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
193 |
0 | 194 Test aborting: |
195 | |
196 $ hg onsub -v 'test $HG_SUBPATH != "a/y/r"' | |
197 executing 'test $HG_SUBPATH != "a/y/r"' in a | |
198 executing 'test $HG_SUBPATH != "a/y/r"' in a/x | |
199 executing 'test $HG_SUBPATH != "a/y/r"' in a/y | |
200 executing 'test $HG_SUBPATH != "a/y/r"' in a/y/r | |
201 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
|
202 [255] |
0 | 203 |
3 | 204 Test aborting: |
205 | |
206 $ hg onsub -v --ignore-errors false | |
207 executing 'false' in a | |
208 executing 'false' in a/x | |
209 executing 'false' in a/y | |
210 executing 'false' in a/y/r | |
211 executing 'false' in a/y/s | |
212 executing 'false' in a/y/t | |
213 executing 'false' in b | |
214 executing 'false' in b/u | |
215 executing 'false' in b/v | |
216 | |
0 | 217 Test --print0: |
218 | |
219 $ mv a 'with spaces' | |
220 $ echo 'with spaces = with spaces' > .hgsub | |
221 $ echo 'b = b' >> .hgsub | |
222 $ hg commit -m rename | |
223 committing subrepository with spaces | |
224 $ hg onsub -0 | xargs -n 1 -0 | |
225 b | |
226 b/u | |
227 b/v | |
228 with spaces | |
229 with spaces/x | |
230 with spaces/y | |
231 with spaces/y/r | |
232 with spaces/y/s | |
233 with spaces/y/t |