summaryrefslogtreecommitdiffstats
path: root/subcmds/forall.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-02-16 01:43:31 -0500
committerMike Frysinger <vapier@google.com>2021-02-22 22:51:07 +0000
commit6a2400a4d097b6e510dc9b8ec06283517b9ca3ad (patch)
tree55ad212633615a1d0ea1bb3f5c294f495bd223a7 /subcmds/forall.py
parentc5bbea8db364b88558acc434be16ec82c04737e5 (diff)
downloadgit-repo-6a2400a4d097b6e510dc9b8ec06283517b9ca3ad.tar.gz
command: unify --job option & default values
Extend the Command class to support adding the --jobs option to the parser if the command declares it supports running in parallel. Also pull the default value used for the number of local jobs into the command module so local commands can share it. Change-Id: I22b0f8d2cf69875013cec657b8e6c4385549ccac Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297024 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Chris Mcdonald <cjmcdonald@google.com>
Diffstat (limited to 'subcmds/forall.py')
-rw-r--r--subcmds/forall.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/subcmds/forall.py b/subcmds/forall.py
index ef11851b..d871b3ea 100644
--- a/subcmds/forall.py
+++ b/subcmds/forall.py
@@ -21,7 +21,7 @@ import sys
21import subprocess 21import subprocess
22 22
23from color import Coloring 23from color import Coloring
24from command import Command, MirrorSafeCommand 24from command import DEFAULT_LOCAL_JOBS, Command, MirrorSafeCommand
25import platform_utils 25import platform_utils
26 26
27_CAN_COLOR = [ 27_CAN_COLOR = [
@@ -113,8 +113,11 @@ terminal and are not redirected.
113If -e is used, when a command exits unsuccessfully, '%prog' will abort 113If -e is used, when a command exits unsuccessfully, '%prog' will abort
114without iterating through the remaining projects. 114without iterating through the remaining projects.
115""" 115"""
116 PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
116 117
117 def _Options(self, p): 118 def _Options(self, p):
119 super()._Options(p)
120
118 def cmd(option, opt_str, value, parser): 121 def cmd(option, opt_str, value, parser):
119 setattr(parser.values, option.dest, list(parser.rargs)) 122 setattr(parser.values, option.dest, list(parser.rargs))
120 while parser.rargs: 123 while parser.rargs:
@@ -148,9 +151,6 @@ without iterating through the remaining projects.
148 g.add_option('-v', '--verbose', 151 g.add_option('-v', '--verbose',
149 dest='verbose', action='store_true', 152 dest='verbose', action='store_true',
150 help='Show command error messages') 153 help='Show command error messages')
151 g.add_option('-j', '--jobs',
152 dest='jobs', action='store', type='int', default=1,
153 help='number of commands to execute simultaneously')
154 154
155 def WantPager(self, opt): 155 def WantPager(self, opt):
156 return opt.project_header and opt.jobs == 1 156 return opt.project_header and opt.jobs == 1