Mercurial > hg-onsub
changeset 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 | 30bdbd5f6173 |
files | onsub.py test-onsub-mixed.t test-onsub.t |
diffstat | 3 files changed, 28 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/onsub.py Tue Mar 27 16:53:23 2012 -0700 +++ b/onsub.py Thu Mar 29 16:18:57 2012 -0700 @@ -63,6 +63,7 @@ precmd = None postcmd = None includeroot = opts.get('root_repo') + repotypefilter = opts.get('type') def execCmd(sub, cmd, kind): """if sub == None, cmd is executed inside repo; else, inside sub. @@ -91,7 +92,7 @@ HG_REPO=repo.root, HG_SUBTYPE=kind) cmdwd = os.path.join(repo.root, relpath) - if cmd != None: + if cmd != None and (repotypefilter == '' or repotypefilter == kind): if print0: ui.write(relpath, "\0") if cmd != '': @@ -184,7 +185,9 @@ _('limit recursion to N levels (negative for no limit)'), 'N'), ('', 'ignore-errors', None, _('continue execution despite errors')), + ('t', 'type', '', + _('the type of repo to filter'), 'TYPE'), ('0', 'print0', None, _('end subrepository names with NUL, for use with xargs'))], - _('[-b] [-0] [--ignore-errors] CMD [POST-CMD]')) + _('[-b] [-0] [-t TYPE] [--ignore-errors] CMD [POST-CMD]')) }
--- a/test-onsub-mixed.t Tue Mar 27 16:53:23 2012 -0700 +++ b/test-onsub-mixed.t Thu Mar 29 16:18:57 2012 -0700 @@ -54,3 +54,24 @@ b = hg git-i = git +Test the type filter + + $ hg onsub 'echo $HG_SUBPATH' -t hg + a + b + + $ hg onsub 'echo $HG_SUBPATH' -t git + a/git-j + git-i + +Test the type filter including the root repository + + $ hg onsub 'echo $HG_SUBPATH' -t hg --root-repo + . + a + b + + $ hg onsub 'echo $HG_SUBPATH' -t git --root-repo + a/git-j + git-i +
--- a/test-onsub.t Tue Mar 27 16:53:23 2012 -0700 +++ b/test-onsub.t Thu Mar 29 16:18:57 2012 -0700 @@ -6,7 +6,7 @@ Check help formatting: $ hg help onsub - hg onsub [-b] [-0] [--ignore-errors] CMD [POST-CMD] + hg onsub [-b] [-0] [-t TYPE] [--ignore-errors] CMD [POST-CMD] execute a command in each subrepository @@ -55,6 +55,7 @@ --max-depth N limit recursion to N levels (negative for no limit) (default: -1) --ignore-errors continue execution despite errors + -t --type TYPE the type of repo to filter -0 --print0 end subrepository names with NUL, for use with xargs use "hg -v help onsub" to show more info