Mercurial > hg-onsub
changeset 3:a2184bbf38e6
Implement --ignore-errors.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Mon, 06 Sep 2010 12:35:30 +0200 |
parents | cd0c93eba765 |
children | aa0c2e9f5f59 |
files | onsub.py test-onsub.t |
diffstat | 2 files changed, 27 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/onsub.py Mon Sep 06 12:21:02 2010 +0200 +++ b/onsub.py Mon Sep 06 12:35:30 2010 +0200 @@ -37,9 +37,10 @@ containing repository's ``.hgsubstate`` file. """ cmd = ' '.join(args) - foreach(ui, repo, cmd, not opts.get('breadth_first'), opts.get('print0')) + foreach(ui, repo, cmd, not opts.get('breadth_first'), opts.get('print0'), + opts.get('ignore_errors')) -def foreach(ui, repo, cmd, depthfirst, print0): +def foreach(ui, repo, cmd, depthfirst, print0, ignoreerrors): """execute cmd in repo.root and in each subrepository""" ctx = repo['.'] work = [ctx.sub(subpath) for subpath in sorted(ctx.substate)] @@ -57,11 +58,16 @@ ui.write(relpath, "\0") else: ui.note(_("executing '%s' in %s\n") % (cmd, relpath)) + if ignoreerrors: + onerr = None + else: + onerr = util.Abort util.system(cmd, environ=dict(HG_SUBPATH=relpath, HG_SUBURL=sub._path, HG_SUBSTATE=sub._state[1], HG_REPO=repo.root), - cwd=os.path.join(repo.root, relpath), onerr=util.Abort, + cwd=os.path.join(repo.root, relpath), + onerr=onerr, errprefix=_('terminated onsub in %s') % relpath) if isinstance(sub, subrepo.hgsubrepo): @@ -77,7 +83,9 @@ (onsub, [('b', 'breadth-first', None, _('use breadth-first traversal')), + ('', 'ignore-errors', None, + _('continue execution despite errors')), ('0', 'print0', None, _('end subrepository names with NUL, for use with xargs'))], - _('[-b] [-0] CMD')) + _('[-b] [-0] [--ignore-errors] CMD')) }
--- a/test-onsub.t Mon Sep 06 12:21:02 2010 +0200 +++ b/test-onsub.t Mon Sep 06 12:35:30 2010 +0200 @@ -6,7 +6,7 @@ Check help formatting: $ hg help onsub - hg onsub [-b] [-0] CMD + hg onsub [-b] [-0] [--ignore-errors] CMD execute a command in each subrepository @@ -40,6 +40,7 @@ options: -b --breadth-first use breadth-first traversal + --ignore-errors continue execution despite errors -0 --print0 end subrepository names with NUL, for use with xargs use "hg -v help onsub" to show global options @@ -113,6 +114,19 @@ executing 'test $HG_SUBPATH != "a/y/r"' in a/y/r abort: terminated onsub in a/y/r: test exited with status 1 +Test aborting: + + $ hg onsub -v --ignore-errors false + executing 'false' in a + executing 'false' in a/x + executing 'false' in a/y + executing 'false' in a/y/r + executing 'false' in a/y/s + executing 'false' in a/y/t + executing 'false' in b + executing 'false' in b/u + executing 'false' in b/v + Test --print0: $ mv a 'with spaces'