Martin Geisler  committed a2184bb

Implement --ignore-errors.

  • Participants
  • Parent commits cd0c93e

Comments (0)

Files changed (2)

         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)]
             ui.write(relpath, "\0")
             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,
-                    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):
          [('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'))

File test-onsub.t

 Check help formatting:
   $ hg help onsub
-  hg onsub [-b] [-0] CMD
+  hg onsub [-b] [-0] [--ignore-errors] CMD
   execute a command in each subrepository
    -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
   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'