Mercurial > hg-onsub
annotate test-onsub.t @ 22:f21f26513968 default tip
Update for Mercurial 4.8.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 03 Nov 2018 23:38:48 -0700 |
parents | d920e3425db5 |
children |
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 | |
18
d920e3425db5
Added parameter to filter the type of subrepo to loop through.
Ludovic Chabant <ludovic@chabant.com>
parents:
17
diff
changeset
|
9 hg onsub [-b] [-0] [-t TYPE] [--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 |
18
d920e3425db5
Added parameter to filter the type of subrepo to loop through.
Ludovic Chabant <ludovic@chabant.com>
parents:
17
diff
changeset
|
58 -t --type TYPE the type of repo to filter |
12
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
59 -0 --print0 end subrepository names with NUL, for use with xargs |
0 | 60 |
13
b10dd4461b52
More test updates for Mercurial 2.1
Martin Geisler <mg@aragost.com>
parents:
12
diff
changeset
|
61 use "hg -v help onsub" to show more info |
0 | 62 |
63 Create some nicely nested subrepositories: | |
64 | |
65 $ hg init | |
66 $ for d in a b; do hg init $d; echo "$d = $d" >> .hgsub; done | |
67 $ hg add .hgsub | |
68 | |
69 $ cd a | |
70 | |
71 $ for d in x y; do hg init $d; echo "$d = $d" >> .hgsub; done | |
72 $ hg add .hgsub | |
73 | |
74 $ cd y | |
75 $ for d in r s t; do hg init $d; echo "$d = $d" >> .hgsub; done | |
76 $ hg add .hgsub | |
77 $ cd .. | |
78 | |
79 $ cd .. | |
80 | |
81 $ cd b | |
82 $ for d in u v; do hg init $d; echo "$d = $d" >> .hgsub; done | |
83 $ hg add .hgsub | |
84 $ cd .. | |
85 | |
11
4cb3f28590fd
tests compatible with Mercurial 2.1
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
86 $ hg commit -m init -S |
0 | 87 committing subrepository a |
88 committing subrepository a/x | |
89 committing subrepository a/y | |
90 committing subrepository a/y/r | |
91 committing subrepository a/y/s | |
92 committing subrepository a/y/t | |
93 committing subrepository b | |
94 committing subrepository b/u | |
95 committing subrepository b/v | |
96 | |
12
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
97 The default depth-first pre-order traversal: |
0 | 98 |
99 $ hg onsub 'echo $HG_SUBPATH' | |
100 a | |
101 a/x | |
102 a/y | |
103 a/y/r | |
104 a/y/s | |
105 a/y/t | |
106 b | |
107 b/u | |
108 b/v | |
109 | |
12
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
110 Traversal including the root repository: |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
111 |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
112 $ hg onsub 'echo $HG_SUBPATH' --root-repo |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
113 . |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
114 a |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
115 a/x |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
116 a/y |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
117 a/y/r |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
118 a/y/s |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
119 a/y/t |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
120 b |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
121 b/u |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
122 b/v |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
123 |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
124 Depth-first post-order traversal: |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
125 |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
126 $ hg onsub 'echo $HG_SUBPATH' --post-order |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
127 a/x |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
128 a/y/r |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
129 a/y/s |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
130 a/y/t |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
131 a/y |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
132 a |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
133 b/u |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
134 b/v |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
135 b |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
136 |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
137 Depth-first pre- and post-order traversal: |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
138 |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
139 $ 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
|
140 pre a |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
141 pre a/x |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
142 post a/x |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
143 pre a/y |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
144 pre a/y/r |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
145 post a/y/r |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
146 pre a/y/s |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
147 post a/y/s |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
148 pre a/y/t |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
149 post a/y/t |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
150 post a/y |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
151 post a |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
152 pre b |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
153 pre b/u |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
154 post b/u |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
155 pre b/v |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
156 post b/v |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
157 post b |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
158 |
0 | 159 Breadth-first traversal: |
160 | |
161 $ hg onsub 'echo $HG_SUBPATH' --breadth-first | |
162 a | |
163 b | |
164 a/x | |
165 a/y | |
166 b/u | |
167 b/v | |
168 a/y/r | |
169 a/y/s | |
170 a/y/t | |
171 | |
8
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
172 Limit depth of traversal: |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
173 $ 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
|
174 a |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
175 b |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
176 $ 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
|
177 a |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
178 a/x |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
179 a/y |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
180 b |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
181 b/u |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
182 b/v |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
183 $ 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
|
184 a |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
185 b |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
186 a/x |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
187 a/y |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
188 b/u |
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
189 b/v |
12
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
190 $ 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
|
191 . |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
192 a |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
11
diff
changeset
|
193 b |
8
ecc4fd16555d
Add --max-depth option to limit depth of recursion.
Greg Ward <greg@gerg.ca>
parents:
7
diff
changeset
|
194 |
0 | 195 Test aborting: |
196 | |
197 $ hg onsub -v 'test $HG_SUBPATH != "a/y/r"' | |
198 executing 'test $HG_SUBPATH != "a/y/r"' in a | |
199 executing 'test $HG_SUBPATH != "a/y/r"' in a/x | |
200 executing 'test $HG_SUBPATH != "a/y/r"' in a/y | |
201 executing 'test $HG_SUBPATH != "a/y/r"' in a/y/r | |
202 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
|
203 [255] |
0 | 204 |
3 | 205 Test aborting: |
206 | |
207 $ hg onsub -v --ignore-errors false | |
208 executing 'false' in a | |
209 executing 'false' in a/x | |
210 executing 'false' in a/y | |
211 executing 'false' in a/y/r | |
212 executing 'false' in a/y/s | |
213 executing 'false' in a/y/t | |
214 executing 'false' in b | |
215 executing 'false' in b/u | |
216 executing 'false' in b/v | |
217 | |
0 | 218 Test --print0: |
219 | |
220 $ mv a 'with spaces' | |
221 $ echo 'with spaces = with spaces' > .hgsub | |
222 $ echo 'b = b' >> .hgsub | |
223 $ hg commit -m rename | |
224 committing subrepository with spaces | |
225 $ hg onsub -0 | xargs -n 1 -0 | |
226 b | |
227 b/u | |
228 b/v | |
229 with spaces | |
230 with spaces/x | |
231 with spaces/y | |
232 with spaces/y/r | |
233 with spaces/y/s | |
234 with spaces/y/t |