diff options
Diffstat (limited to 'command.py')
| -rw-r--r-- | command.py | 34 |
1 files changed, 29 insertions, 5 deletions
| @@ -15,7 +15,6 @@ | |||
| 15 | import multiprocessing | 15 | import multiprocessing |
| 16 | import os | 16 | import os |
| 17 | import optparse | 17 | import optparse |
| 18 | import platform | ||
| 19 | import re | 18 | import re |
| 20 | import sys | 19 | import sys |
| 21 | 20 | ||
| @@ -25,6 +24,10 @@ from error import InvalidProjectGroupsError | |||
| 25 | import progress | 24 | import progress |
| 26 | 25 | ||
| 27 | 26 | ||
| 27 | # Are we generating man-pages? | ||
| 28 | GENERATE_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.""" |
