Mercurial > hg-onsub
diff onsub.py @ 3:a2184bbf38e6
Implement --ignore-errors.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Mon, 06 Sep 2010 12:35:30 +0200 |
parents | e49f3bbfec4d |
children | aa0c2e9f5f59 |
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')) }