From 6a2400a4d097b6e510dc9b8ec06283517b9ca3ad Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 16 Feb 2021 01:43:31 -0500 Subject: 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 Reviewed-by: Chris Mcdonald --- subcmds/branches.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'subcmds/branches.py') diff --git a/subcmds/branches.py b/subcmds/branches.py index 20f51693..9665e85f 100644 --- a/subcmds/branches.py +++ b/subcmds/branches.py @@ -16,7 +16,7 @@ import itertools import multiprocessing import sys from color import Coloring -from command import Command +from command import Command, DEFAULT_LOCAL_JOBS # Number of projects to submit to a single worker process at a time. # This number represents a tradeoff between the overhead of IPC and finer @@ -103,17 +103,7 @@ the branch appears in, or does not appear in. If no project list is shown, then the branch appears in all projects. """ - - def _Options(self, p): - """Add flags to CLI parser for this subcommand.""" - default_jobs = min(multiprocessing.cpu_count(), 8) - p.add_option( - '-j', - '--jobs', - type=int, - default=default_jobs, - help='Number of worker processes to spawn ' - '(default: %s)' % default_jobs) + PARALLEL_JOBS = DEFAULT_LOCAL_JOBS def Execute(self, opt, args): projects = self.GetProjects(args) -- cgit v1.2.3-54-g00ecf