Mercurial > hg-onsub
comparison test-onsub.t @ 0:e49f3bbfec4d
Initial version.
author | Martin Geisler <mg@aragost.com> |
---|---|
date | Mon, 06 Sep 2010 12:09:47 +0200 |
parents | |
children | a2184bbf38e6 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e49f3bbfec4d |
---|---|
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 | |
9 hg onsub [-b] [-0] CMD | |
10 | |
11 execute a command in each subrepository | |
12 | |
13 The command is executed with the current working directory set to the root | |
14 of each subrepository. By default, execution stops if the command returns | |
15 a non-zero exit code. Use --ignore-errors to override this. | |
16 | |
17 Use --verbose/-v to print the name of each subrepo before the command is | |
18 executed, use --print0/-0 to terminate this line with a NUL character | |
19 instead of a newline. This can for instance be useful in combination with | |
20 "hg status --print0". | |
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 | |
43 -0 --print0 end subrepository names with NUL, for use with xargs | |
44 | |
45 use "hg -v help onsub" to show global options | |
46 | |
47 Create some nicely nested subrepositories: | |
48 | |
49 $ hg init | |
50 $ for d in a b; do hg init $d; echo "$d = $d" >> .hgsub; done | |
51 $ hg add .hgsub | |
52 | |
53 $ cd a | |
54 | |
55 $ for d in x y; do hg init $d; echo "$d = $d" >> .hgsub; done | |
56 $ hg add .hgsub | |
57 | |
58 $ cd y | |
59 $ for d in r s t; do hg init $d; echo "$d = $d" >> .hgsub; done | |
60 $ hg add .hgsub | |
61 $ cd .. | |
62 | |
63 $ cd .. | |
64 | |
65 $ cd b | |
66 $ for d in u v; do hg init $d; echo "$d = $d" >> .hgsub; done | |
67 $ hg add .hgsub | |
68 $ cd .. | |
69 | |
70 $ hg commit -m init | |
71 committing subrepository a | |
72 committing subrepository a/x | |
73 committing subrepository a/y | |
74 committing subrepository a/y/r | |
75 committing subrepository a/y/s | |
76 committing subrepository a/y/t | |
77 committing subrepository b | |
78 committing subrepository b/u | |
79 committing subrepository b/v | |
80 | |
81 The default depth-first traversal: | |
82 | |
83 $ hg onsub 'echo $HG_SUBPATH' | |
84 a | |
85 a/x | |
86 a/y | |
87 a/y/r | |
88 a/y/s | |
89 a/y/t | |
90 b | |
91 b/u | |
92 b/v | |
93 | |
94 Breadth-first traversal: | |
95 | |
96 $ hg onsub 'echo $HG_SUBPATH' --breadth-first | |
97 a | |
98 b | |
99 a/x | |
100 a/y | |
101 b/u | |
102 b/v | |
103 a/y/r | |
104 a/y/s | |
105 a/y/t | |
106 | |
107 Test aborting: | |
108 | |
109 $ hg onsub -v 'test $HG_SUBPATH != "a/y/r"' | |
110 executing 'test $HG_SUBPATH != "a/y/r"' in a | |
111 executing 'test $HG_SUBPATH != "a/y/r"' in a/x | |
112 executing 'test $HG_SUBPATH != "a/y/r"' in a/y | |
113 executing 'test $HG_SUBPATH != "a/y/r"' in a/y/r | |
114 abort: terminated onsub in a/y/r: test exited with status 1 | |
115 | |
116 Test --print0: | |
117 | |
118 $ mv a 'with spaces' | |
119 $ echo 'with spaces = with spaces' > .hgsub | |
120 $ echo 'b = b' >> .hgsub | |
121 $ hg commit -m rename | |
122 committing subrepository with spaces | |
123 $ hg onsub -0 | xargs -n 1 -0 | |
124 b | |
125 b/u | |
126 b/v | |
127 with spaces | |
128 with spaces/x | |
129 with spaces/y | |
130 with spaces/y/r | |
131 with spaces/y/s | |
132 with spaces/y/t |