Mercurial > hg-onsub
comparison 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 |
comparison
equal
deleted
inserted
replaced
2:cd0c93eba765 | 3:a2184bbf38e6 |
---|---|
35 ``HG_SUBSTATE``: | 35 ``HG_SUBSTATE``: |
36 State of the current subrepository as specified in the | 36 State of the current subrepository as specified in the |
37 containing repository's ``.hgsubstate`` file. | 37 containing repository's ``.hgsubstate`` file. |
38 """ | 38 """ |
39 cmd = ' '.join(args) | 39 cmd = ' '.join(args) |
40 foreach(ui, repo, cmd, not opts.get('breadth_first'), opts.get('print0')) | 40 foreach(ui, repo, cmd, not opts.get('breadth_first'), opts.get('print0'), |
41 opts.get('ignore_errors')) | |
41 | 42 |
42 def foreach(ui, repo, cmd, depthfirst, print0): | 43 def foreach(ui, repo, cmd, depthfirst, print0, ignoreerrors): |
43 """execute cmd in repo.root and in each subrepository""" | 44 """execute cmd in repo.root and in each subrepository""" |
44 ctx = repo['.'] | 45 ctx = repo['.'] |
45 work = [ctx.sub(subpath) for subpath in sorted(ctx.substate)] | 46 work = [ctx.sub(subpath) for subpath in sorted(ctx.substate)] |
46 if depthfirst: | 47 if depthfirst: |
47 work.reverse() | 48 work.reverse() |
55 relpath = subrepo.relpath(sub) | 56 relpath = subrepo.relpath(sub) |
56 if print0: | 57 if print0: |
57 ui.write(relpath, "\0") | 58 ui.write(relpath, "\0") |
58 else: | 59 else: |
59 ui.note(_("executing '%s' in %s\n") % (cmd, relpath)) | 60 ui.note(_("executing '%s' in %s\n") % (cmd, relpath)) |
61 if ignoreerrors: | |
62 onerr = None | |
63 else: | |
64 onerr = util.Abort | |
60 util.system(cmd, environ=dict(HG_SUBPATH=relpath, | 65 util.system(cmd, environ=dict(HG_SUBPATH=relpath, |
61 HG_SUBURL=sub._path, | 66 HG_SUBURL=sub._path, |
62 HG_SUBSTATE=sub._state[1], | 67 HG_SUBSTATE=sub._state[1], |
63 HG_REPO=repo.root), | 68 HG_REPO=repo.root), |
64 cwd=os.path.join(repo.root, relpath), onerr=util.Abort, | 69 cwd=os.path.join(repo.root, relpath), |
70 onerr=onerr, | |
65 errprefix=_('terminated onsub in %s') % relpath) | 71 errprefix=_('terminated onsub in %s') % relpath) |
66 | 72 |
67 if isinstance(sub, subrepo.hgsubrepo): | 73 if isinstance(sub, subrepo.hgsubrepo): |
68 rev = sub._state[1] | 74 rev = sub._state[1] |
69 ctx = sub._repo[rev] | 75 ctx = sub._repo[rev] |
75 cmdtable = { | 81 cmdtable = { |
76 "onsub": | 82 "onsub": |
77 (onsub, | 83 (onsub, |
78 [('b', 'breadth-first', None, | 84 [('b', 'breadth-first', None, |
79 _('use breadth-first traversal')), | 85 _('use breadth-first traversal')), |
86 ('', 'ignore-errors', None, | |
87 _('continue execution despite errors')), | |
80 ('0', 'print0', None, | 88 ('0', 'print0', None, |
81 _('end subrepository names with NUL, for use with xargs'))], | 89 _('end subrepository names with NUL, for use with xargs'))], |
82 _('[-b] [-0] CMD')) | 90 _('[-b] [-0] [--ignore-errors] CMD')) |
83 } | 91 } |