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
|
|
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
|
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
|
|
116
|
3
|
117 Test aborting:
|
|
118
|
|
119 $ hg onsub -v --ignore-errors false
|
|
120 executing 'false' in a
|
|
121 executing 'false' in a/x
|
|
122 executing 'false' in a/y
|
|
123 executing 'false' in a/y/r
|
|
124 executing 'false' in a/y/s
|
|
125 executing 'false' in a/y/t
|
|
126 executing 'false' in b
|
|
127 executing 'false' in b/u
|
|
128 executing 'false' in b/v
|
|
129
|
0
|
130 Test --print0:
|
|
131
|
|
132 $ mv a 'with spaces'
|
|
133 $ echo 'with spaces = with spaces' > .hgsub
|
|
134 $ echo 'b = b' >> .hgsub
|
|
135 $ hg commit -m rename
|
|
136 committing subrepository with spaces
|
|
137 $ hg onsub -0 | xargs -n 1 -0
|
|
138 b
|
|
139 b/u
|
|
140 b/v
|
|
141 with spaces
|
|
142 with spaces/x
|
|
143 with spaces/y
|
|
144 with spaces/y/r
|
|
145 with spaces/y/s
|
|
146 with spaces/y/t
|