Mercurial > hg-onsub
annotate test-onsub.t @ 7:a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Sun, 24 Apr 2011 10:07:03 -0400 |
parents | 73658c424c7b |
children | ecc4fd16555d |
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 | |
3 | 43 --ignore-errors continue execution despite errors |
0 | 44 -0 --print0 end subrepository names with NUL, for use with xargs |
45 | |
46 use "hg -v help onsub" to show global options | |
47 | |
48 Create some nicely nested subrepositories: | |
49 | |
50 $ hg init | |
51 $ for d in a b; do hg init $d; echo "$d = $d" >> .hgsub; done | |
52 $ hg add .hgsub | |
53 | |
54 $ cd a | |
55 | |
56 $ for d in x y; do hg init $d; echo "$d = $d" >> .hgsub; done | |
57 $ hg add .hgsub | |
58 | |
59 $ cd y | |
60 $ for d in r s t; do hg init $d; echo "$d = $d" >> .hgsub; done | |
61 $ hg add .hgsub | |
62 $ cd .. | |
63 | |
64 $ cd .. | |
65 | |
66 $ cd b | |
67 $ for d in u v; do hg init $d; echo "$d = $d" >> .hgsub; done | |
68 $ hg add .hgsub | |
69 $ cd .. | |
70 | |
71 $ hg commit -m init | |
72 committing subrepository a | |
73 committing subrepository a/x | |
74 committing subrepository a/y | |
75 committing subrepository a/y/r | |
76 committing subrepository a/y/s | |
77 committing subrepository a/y/t | |
78 committing subrepository b | |
79 committing subrepository b/u | |
80 committing subrepository b/v | |
81 | |
82 The default depth-first traversal: | |
83 | |
84 $ hg onsub 'echo $HG_SUBPATH' | |
85 a | |
86 a/x | |
87 a/y | |
88 a/y/r | |
89 a/y/s | |
90 a/y/t | |
91 b | |
92 b/u | |
93 b/v | |
94 | |
95 Breadth-first traversal: | |
96 | |
97 $ hg onsub 'echo $HG_SUBPATH' --breadth-first | |
98 a | |
99 b | |
100 a/x | |
101 a/y | |
102 b/u | |
103 b/v | |
104 a/y/r | |
105 a/y/s | |
106 a/y/t | |
107 | |
108 Test aborting: | |
109 | |
110 $ hg onsub -v 'test $HG_SUBPATH != "a/y/r"' | |
111 executing 'test $HG_SUBPATH != "a/y/r"' in a | |
112 executing 'test $HG_SUBPATH != "a/y/r"' in a/x | |
113 executing 'test $HG_SUBPATH != "a/y/r"' in a/y | |
114 executing 'test $HG_SUBPATH != "a/y/r"' in a/y/r | |
115 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
|
116 [255] |
0 | 117 |
3 | 118 Test aborting: |
119 | |
120 $ hg onsub -v --ignore-errors false | |
121 executing 'false' in a | |
122 executing 'false' in a/x | |
123 executing 'false' in a/y | |
124 executing 'false' in a/y/r | |
125 executing 'false' in a/y/s | |
126 executing 'false' in a/y/t | |
127 executing 'false' in b | |
128 executing 'false' in b/u | |
129 executing 'false' in b/v | |
130 | |
0 | 131 Test --print0: |
132 | |
133 $ mv a 'with spaces' | |
134 $ echo 'with spaces = with spaces' > .hgsub | |
135 $ echo 'b = b' >> .hgsub | |
136 $ hg commit -m rename | |
137 committing subrepository with spaces | |
138 $ hg onsub -0 | xargs -n 1 -0 | |
139 b | |
140 b/u | |
141 b/v | |
142 with spaces | |
143 with spaces/x | |
144 with spaces/y | |
145 with spaces/y/r | |
146 with spaces/y/s | |
147 with spaces/y/t |