summaryrefslogtreecommitdiffstats
path: root/command.py
diff options
context:
space:
mode:
Diffstat (limited to 'command.py')
-rw-r--r--command.py34
1 files changed, 29 insertions, 5 deletions
diff --git a/command.py b/command.py
index 9b1220dc..b972a0be 100644
--- a/command.py
+++ b/command.py
@@ -15,7 +15,6 @@
15import multiprocessing 15import multiprocessing
16import os 16import os
17import optparse 17import optparse
18import platform
19import re 18import re
20import sys 19import sys
21 20
@@ -25,6 +24,10 @@ from error import InvalidProjectGroupsError
25import progress 24import progress
26 25
27 26
27# Are we generating man-pages?
28GENERATE_MANPAGES = os.environ.get('_REPO_GENERATE_MANPAGES_') == ' indeed! '
29
30
28# Number of projects to submit to a single worker process at a time. 31# Number of projects to submit to a single worker process at a time.
29# This number represents a tradeoff between the overhead of IPC and finer 32# This number represents a tradeoff between the overhead of IPC and finer
30# grained opportunity for parallelism. This particular value was chosen by 33# grained opportunity for parallelism. This particular value was chosen by
@@ -43,15 +46,32 @@ class Command(object):
43 """Base class for any command line action in repo. 46 """Base class for any command line action in repo.
44 """ 47 """
45 48
46 common = False 49 # Singleton for all commands to track overall repo command execution and
50 # provide event summary to callers. Only used by sync subcommand currently.
51 #
52 # NB: This is being replaced by git trace2 events. See git_trace2_event_log.
47 event_log = EventLog() 53 event_log = EventLog()
48 manifest = None 54
49 _optparse = None 55 # Whether this command is a "common" one, i.e. whether the user would commonly
56 # use it or it's a more uncommon command. This is used by the help command to
57 # show short-vs-full summaries.
58 COMMON = False
50 59
51 # Whether this command supports running in parallel. If greater than 0, 60 # Whether this command supports running in parallel. If greater than 0,
52 # it is the number of parallel jobs to default to. 61 # it is the number of parallel jobs to default to.
53 PARALLEL_JOBS = None 62 PARALLEL_JOBS = None
54 63
64 def __init__(self, repodir=None, client=None, manifest=None, gitc_manifest=None,
65 git_event_log=None):
66 self.repodir = repodir
67 self.client = client
68 self.manifest = manifest
69 self.gitc_manifest = gitc_manifest
70 self.git_event_log = git_event_log
71
72 # Cache for the OptionParser property.
73 self._optparse = None
74
55 def WantPager(self, _opt): 75 def WantPager(self, _opt):
56 return False 76 return False
57 77
@@ -106,10 +126,14 @@ class Command(object):
106 help='only show errors') 126 help='only show errors')
107 127
108 if self.PARALLEL_JOBS is not None: 128 if self.PARALLEL_JOBS is not None:
129 default = 'based on number of CPU cores'
130 if not GENERATE_MANPAGES:
131 # Only include active cpu count if we aren't generating man pages.
132 default = f'%default; {default}'
109 p.add_option( 133 p.add_option(
110 '-j', '--jobs', 134 '-j', '--jobs',
111 type=int, default=self.PARALLEL_JOBS, 135 type=int, default=self.PARALLEL_JOBS,
112 help='number of jobs to run in parallel (default: %s)' % self.PARALLEL_JOBS) 136 help=f'number of jobs to run in parallel (default: {default})')
113 137
114 def _Options(self, p): 138 def _Options(self, p):
115 """Initialize the option parser with subcommand-specific options.""" 139 """Initialize the option parser with subcommand-specific options."""