Mercurial > hg-onsub
annotate onsub.py @ 21:003eee5497e0
* Hotfixed onsub for use with mercurial 4.1+
author | Matthias Muenzner <matthias.muenzner@jkaref.com> |
---|---|
date | Mon, 08 May 2017 20:03:41 +0200 |
parents | 132e522fda32 |
children | f21f26513968 |
rev | line source |
---|---|
6 | 1 # onsub.py - execute commands recursively on subrepositories |
2 # | |
3 # Copyright 2010, 2011 aragost Trifork | |
4 # | |
5 # This software may be used and distributed according to the terms of | |
6 # the GNU General Public License version 2 or any later version. | |
0 | 7 |
8 import os | |
9 from mercurial.i18n import _ | |
20 | 10 from mercurial import extensions, subrepo, util, cmdutil |
11 | |
12 cmdtable = {} | |
13 command = cmdutil.command(cmdtable) | |
0 | 14 |
15 """execute a command in each subrepository""" | |
16 | |
20 | 17 @command("onsub", |
18 [('b', 'breadth-first', None, | |
19 _('use breadth-first traversal')), | |
20 ('p', 'post-order', None, | |
21 _('use post-order depth-first traversal')), | |
22 ('', 'root-repo', None, | |
23 _('include root repository in traversal')), | |
24 ('', 'max-depth', -1, | |
25 _('limit recursion to N levels (negative for no limit)'), 'N'), | |
26 ('', 'ignore-errors', None, | |
27 _('continue execution despite errors')), | |
28 ('t', 'type', '', | |
29 _('the type of repo to filter'), 'TYPE'), | |
30 ('0', 'print0', None, | |
31 _('end subrepository names with NUL, for use with xargs'))], | |
32 _('[-b] [-0] [-t TYPE] [--ignore-errors] CMD [POST-CMD]')) | |
0 | 33 def onsub(ui, repo, *args, **opts): |
34 """execute a command in each subrepository | |
35 | |
7
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
6
diff
changeset
|
36 Executes CMD with the current working directory set to the root of |
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
6
diff
changeset
|
37 each subrepository. By default, execution stops if CMD returns a |
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
6
diff
changeset
|
38 non-zero exit code. Use --ignore-errors to override this. |
0 | 39 |
14 | 40 If a POST-CMD is specified, this will be executed after all |
41 subrepositories below the current subrepository has been visited. | |
42 This corresponds to a post-order traversal of the tree. | |
43 | |
44 It is an error to specify a POST-CMD together with the | |
45 --breadth-first flag. | |
46 | |
7
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
6
diff
changeset
|
47 Use --verbose/-v to print the command being run and the subrepo |
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
6
diff
changeset
|
48 name for each run of CMD in a subrepo. Alternately, use |
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
6
diff
changeset
|
49 --print0/-0 to print just the subrepo name followed by a NUL |
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
6
diff
changeset
|
50 character instead of a newline. This can be useful in combination |
a2ad7553ba79
Improve help text (in particular, clarify meaning of --print0).
Greg Ward <greg@gerg.ca>
parents:
6
diff
changeset
|
51 with :hg:`status --print0`. |
0 | 52 |
53 The command has access to the following environment variables: | |
54 | |
55 ``HG_REPO``: | |
56 Absolute path to the top-level repository in which the onsub | |
57 command was executed. | |
58 | |
59 ``HG_SUBPATH``: | |
60 Relative path to the current subrepository from the top-level | |
61 repository. | |
62 | |
63 ``HG_SUBURL``: | |
64 URL for the current subrepository as specified in the | |
65 containing repository's ``.hgsub`` file. | |
66 | |
67 ``HG_SUBSTATE``: | |
68 State of the current subrepository as specified in the | |
69 containing repository's ``.hgsubstate`` file. | |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
70 |
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
71 ``HG_SUBTYPE``: |
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
72 The type of the current subrepository (hg, git or svn). |
0 | 73 """ |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
74 |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
75 # function level "constants" - these won't be modified by the nested functions |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
76 print0 = opts.get('print0') |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
77 if opts.get('ignore_errors'): |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
78 onerr = None |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
79 else: |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
80 onerr = util.Abort |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
81 maxdepth = opts.get('max_depth') |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
82 precmd = None |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
83 postcmd = None |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
84 includeroot = opts.get('root_repo') |
18
d920e3425db5
Added parameter to filter the type of subrepo to loop through.
Ludovic Chabant <ludovic@chabant.com>
parents:
17
diff
changeset
|
85 repotypefilter = opts.get('type') |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
86 |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
87 def execCmd(sub, cmd, kind): |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
88 """if sub == None, cmd is executed inside repo; else, inside sub. |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
89 If cmd == None, do nothing. If cmd == '', do only the print0 (if needed). |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
90 Else, do either print0 or the debugging message, then execute the command. |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
91 kind is the type of the (sub)repo. |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
92 """ |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
93 if sub == None: |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
94 envargdict = dict(HG_SUBPATH='.', |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
95 HG_SUBURL='.', |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
96 HG_SUBSTATE=repo['.'].hex(), |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
97 HG_REPO=repo.root, |
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
98 HG_SUBTYPE=kind) |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
99 relpath = '.' |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
100 cmdwd = repo.root |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
101 else: |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
102 # subrepo.relpath was renamed to subrepo.subrelpath in |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
103 # 18b5b6392fcf. |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
104 if hasattr(subrepo, 'relpath'): |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
105 relpath = subrepo.relpath(sub) |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
106 else: |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
107 relpath = subrepo.subrelpath(sub) |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
108 envargdict = dict(HG_SUBPATH=relpath, |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
109 HG_SUBURL=sub._path, |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
110 HG_SUBSTATE=sub._state[1], |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
111 HG_REPO=repo.root, |
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
112 HG_SUBTYPE=kind) |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
113 cmdwd = os.path.join(repo.root, relpath) |
18
d920e3425db5
Added parameter to filter the type of subrepo to loop through.
Ludovic Chabant <ludovic@chabant.com>
parents:
17
diff
changeset
|
114 if cmd != None and (repotypefilter == '' or repotypefilter == kind): |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
115 if print0: |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
116 ui.write(relpath, "\0") |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
117 if cmd != '': |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
118 if not print0: ui.note(_("executing '%s' in %s\n") % (cmd, relpath)) |
21
003eee5497e0
* Hotfixed onsub for use with mercurial 4.1+
Matthias Muenzner <matthias.muenzner@jkaref.com>
parents:
20
diff
changeset
|
119 rc = util.system(cmd, environ=envargdict, cwd=cmdwd) |
003eee5497e0
* Hotfixed onsub for use with mercurial 4.1+
Matthias Muenzner <matthias.muenzner@jkaref.com>
parents:
20
diff
changeset
|
120 if rc: |
003eee5497e0
* Hotfixed onsub for use with mercurial 4.1+
Matthias Muenzner <matthias.muenzner@jkaref.com>
parents:
20
diff
changeset
|
121 errprefix=_('terminated onsub in %s') % relpath |
003eee5497e0
* Hotfixed onsub for use with mercurial 4.1+
Matthias Muenzner <matthias.muenzner@jkaref.com>
parents:
20
diff
changeset
|
122 errmsg = '%s: %s' % (errprefix, errmsg) |
003eee5497e0
* Hotfixed onsub for use with mercurial 4.1+
Matthias Muenzner <matthias.muenzner@jkaref.com>
parents:
20
diff
changeset
|
123 try: |
003eee5497e0
* Hotfixed onsub for use with mercurial 4.1+
Matthias Muenzner <matthias.muenzner@jkaref.com>
parents:
20
diff
changeset
|
124 onerr.warn(errmsg + '\n') |
003eee5497e0
* Hotfixed onsub for use with mercurial 4.1+
Matthias Muenzner <matthias.muenzner@jkaref.com>
parents:
20
diff
changeset
|
125 except AttributeError: |
003eee5497e0
* Hotfixed onsub for use with mercurial 4.1+
Matthias Muenzner <matthias.muenzner@jkaref.com>
parents:
20
diff
changeset
|
126 raise onerr(errmsg) |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
127 |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
128 def bfs(): |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
129 """execute precmd in repo.root and in each subrepository, breadth-first""" |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
130 if includeroot: |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
131 execCmd(None, precmd, 'hg') |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
132 ctx = repo['.'] |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
133 work = [(1, ctx.sub(subpath), ctx.substate[subpath][2]) for subpath in sorted(ctx.substate)] |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
134 while work: |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
135 (depth, sub, kind) = work.pop(0) |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
136 if depth > maxdepth >= 0: |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
137 continue |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
138 execCmd(sub, precmd, kind) |
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
139 if kind == 'hg': |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
140 rev = sub._state[1] |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
141 ctx = sub._repo[rev] |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
142 w = [(depth + 1, ctx.sub(subpath), ctx.substate[subpath][2]) |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
143 for subpath in sorted(ctx.substate)] |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
144 work.extend(w) |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
145 |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
146 def dfs(): |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
147 """execute pre-/postcmd in repo.root and in each subrepository, depth-first""" |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
148 |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
149 def dfs_rek(depth, sub, kind): |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
150 if depth > maxdepth >= 0: |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
151 return |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
152 execCmd(sub, precmd, kind) |
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
153 if kind == 'hg': |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
154 rev = sub._state[1] |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
155 ctx = sub._repo[rev] |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
156 for subpath in sorted(ctx.substate): |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
157 dfs_rek(depth+1, ctx.sub(subpath), ctx.substate[subpath][2]) |
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
158 execCmd(sub, postcmd, kind) |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
159 |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
160 ctx = repo['.'] |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
161 work = [(ctx.sub(subpath), ctx.substate[subpath][2]) for subpath in sorted(ctx.substate)] |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
162 if includeroot: |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
163 execCmd(None, precmd, 'hg') |
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
164 for (sub, kind) in work: |
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
165 dfs_rek(1, sub, kind) |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
166 if includeroot: |
17
5ea3f7533ec5
Exposed new environment variable with the subrepo type.
Ludovic Chabant <ludovic@chabant.com>
parents:
16
diff
changeset
|
167 execCmd(None, postcmd, 'hg') |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
168 |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
169 ### start of main function part ### |
12
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
170 if len(args) == 2: |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
171 precmd = args[0] |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
172 postcmd = args[1] |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
173 if opts.get('breadth_first') or opts.get('post_order'): |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
174 raise util.Abort(_("onsub: '-b' and '-p' imply the use of only one command")) |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
175 elif len(args) == 1: |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
176 if opts.get('post_order'): |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
177 precmd = None |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
178 postcmd = args[0] |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
179 else: |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
180 precmd = args[0] |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
181 postcmd = None |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
182 elif len(args) == 0: |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
183 # cmd == '' means only do print0 |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
184 if opts.get('post_order'): |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
185 precmd = None |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
186 postcmd = '' |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
187 else: |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
188 precmd = '' |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
189 postcmd = None |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
190 else: |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
191 raise util.Abort(_("onsub: at most 2 command arguments required")) |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
192 if opts.get('post_order') and opts.get('breadth_first'): |
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
193 raise util.Abort(_("onsub: '-b' and '-p' are mutually exclusive")) |
0 | 194 |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
195 if opts.get('breadth_first'): |
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
196 bfs() |
12
90b54c4fe4fe
onsub extension: pre and post order
jakob krainz <jakob@hawo-net.de>
parents:
8
diff
changeset
|
197 else: |
16
44feac64ecfe
refactoring: disentangled breadth-first and depth-first search; made functions nested
jakob krainz <jakob@hawo-net.de>
parents:
14
diff
changeset
|
198 dfs() |