Mercurial > hg-onsub
comparison onsub.py @ 18:d920e3425db5
Added parameter to filter the type of subrepo to loop through.
Added tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 29 Mar 2012 16:18:57 -0700 |
parents | 5ea3f7533ec5 |
children | 132e522fda32 |
comparison
equal
deleted
inserted
replaced
17:5ea3f7533ec5 | 18:d920e3425db5 |
---|---|
61 onerr = util.Abort | 61 onerr = util.Abort |
62 maxdepth = opts.get('max_depth') | 62 maxdepth = opts.get('max_depth') |
63 precmd = None | 63 precmd = None |
64 postcmd = None | 64 postcmd = None |
65 includeroot = opts.get('root_repo') | 65 includeroot = opts.get('root_repo') |
66 repotypefilter = opts.get('type') | |
66 | 67 |
67 def execCmd(sub, cmd, kind): | 68 def execCmd(sub, cmd, kind): |
68 """if sub == None, cmd is executed inside repo; else, inside sub. | 69 """if sub == None, cmd is executed inside repo; else, inside sub. |
69 If cmd == None, do nothing. If cmd == '', do only the print0 (if needed). | 70 If cmd == None, do nothing. If cmd == '', do only the print0 (if needed). |
70 Else, do either print0 or the debugging message, then execute the command. | 71 Else, do either print0 or the debugging message, then execute the command. |
89 HG_SUBURL=sub._path, | 90 HG_SUBURL=sub._path, |
90 HG_SUBSTATE=sub._state[1], | 91 HG_SUBSTATE=sub._state[1], |
91 HG_REPO=repo.root, | 92 HG_REPO=repo.root, |
92 HG_SUBTYPE=kind) | 93 HG_SUBTYPE=kind) |
93 cmdwd = os.path.join(repo.root, relpath) | 94 cmdwd = os.path.join(repo.root, relpath) |
94 if cmd != None: | 95 if cmd != None and (repotypefilter == '' or repotypefilter == kind): |
95 if print0: | 96 if print0: |
96 ui.write(relpath, "\0") | 97 ui.write(relpath, "\0") |
97 if cmd != '': | 98 if cmd != '': |
98 if not print0: ui.note(_("executing '%s' in %s\n") % (cmd, relpath)) | 99 if not print0: ui.note(_("executing '%s' in %s\n") % (cmd, relpath)) |
99 util.system(cmd, environ=envargdict, cwd=cmdwd, onerr=onerr, | 100 util.system(cmd, environ=envargdict, cwd=cmdwd, onerr=onerr, |
182 _('include root repository in traversal')), | 183 _('include root repository in traversal')), |
183 ('', 'max-depth', -1, | 184 ('', 'max-depth', -1, |
184 _('limit recursion to N levels (negative for no limit)'), 'N'), | 185 _('limit recursion to N levels (negative for no limit)'), 'N'), |
185 ('', 'ignore-errors', None, | 186 ('', 'ignore-errors', None, |
186 _('continue execution despite errors')), | 187 _('continue execution despite errors')), |
188 ('t', 'type', '', | |
189 _('the type of repo to filter'), 'TYPE'), | |
187 ('0', 'print0', None, | 190 ('0', 'print0', None, |
188 _('end subrepository names with NUL, for use with xargs'))], | 191 _('end subrepository names with NUL, for use with xargs'))], |
189 _('[-b] [-0] [--ignore-errors] CMD [POST-CMD]')) | 192 _('[-b] [-0] [-t TYPE] [--ignore-errors] CMD [POST-CMD]')) |
190 } | 193 } |