summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-07-26 15:59:20 -0400
committerMike Frysinger <vapier@google.com>2021-07-31 11:39:35 +0000
commitdf8b1cba47fc29d045efceec8cbb43b9182acbbb (patch)
treea22e54c9a800d083720b74123590a4fedf42f9f0
parent9122bfc3a80367ed303e8e2d3b3b3d7a8851c904 (diff)
downloadgit-repo-df8b1cba47fc29d045efceec8cbb43b9182acbbb.tar.gz
man: make output system independent
The current help output might change based on the number of CPU cores available (since it reflects the dynamic --jobs logic). This is good for users running repo locally, but not good for shipping static man pages. Hook the help output to have it generate the same output all the time. Change-Id: I3098ceddc0ad914b0b8e3b25d660b5a264cb41ee Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/312882 Reviewed-by: Roger Shimizu <rosh@debian.org> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
-rw-r--r--command.py10
-rw-r--r--man/repo-abandon.13
-rw-r--r--man/repo-branches.13
-rw-r--r--man/repo-checkout.13
-rw-r--r--man/repo-diff.13
-rw-r--r--man/repo-forall.13
-rw-r--r--man/repo-grep.13
-rw-r--r--man/repo-prune.13
-rw-r--r--man/repo-smartsync.13
-rw-r--r--man/repo-start.13
-rw-r--r--man/repo-status.13
-rw-r--r--man/repo-sync.13
-rw-r--r--man/repo-upload.13
-rwxr-xr-xrelease/update-manpages5
14 files changed, 38 insertions, 13 deletions
diff --git a/command.py b/command.py
index 4087cab5..b972a0be 100644
--- a/command.py
+++ b/command.py
@@ -24,6 +24,10 @@ from error import InvalidProjectGroupsError
24import progress 24import progress
25 25
26 26
27# Are we generating man-pages?
28GENERATE_MANPAGES = os.environ.get('_REPO_GENERATE_MANPAGES_') == ' indeed! '
29
30
27# 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.
28# 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
29# grained opportunity for parallelism. This particular value was chosen by 33# grained opportunity for parallelism. This particular value was chosen by
@@ -122,10 +126,14 @@ class Command(object):
122 help='only show errors') 126 help='only show errors')
123 127
124 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}'
125 p.add_option( 133 p.add_option(
126 '-j', '--jobs', 134 '-j', '--jobs',
127 type=int, default=self.PARALLEL_JOBS, 135 type=int, default=self.PARALLEL_JOBS,
128 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})')
129 137
130 def _Options(self, p): 138 def _Options(self, p):
131 """Initialize the option parser with subcommand-specific options.""" 139 """Initialize the option parser with subcommand-specific options."""
diff --git a/man/repo-abandon.1 b/man/repo-abandon.1
index fb3160c3..b3c0422f 100644
--- a/man/repo-abandon.1
+++ b/man/repo-abandon.1
@@ -20,7 +20,8 @@ It is equivalent to "git branch \fB\-D\fR <branchname>".
20show this help message and exit 20show this help message and exit
21.TP 21.TP
22\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR 22\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR
23number of jobs to run in parallel (default: 4) 23number of jobs to run in parallel (default: based on
24number of CPU cores)
24.TP 25.TP
25\fB\-\-all\fR 26\fB\-\-all\fR
26delete all branches in all projects 27delete all branches in all projects
diff --git a/man/repo-branches.1 b/man/repo-branches.1
index 0080e467..7fe0b02d 100644
--- a/man/repo-branches.1
+++ b/man/repo-branches.1
@@ -46,7 +46,8 @@ is shown, then the branch appears in all projects.
46show this help message and exit 46show this help message and exit
47.TP 47.TP
48\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR 48\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR
49number of jobs to run in parallel (default: 4) 49number of jobs to run in parallel (default: based on
50number of CPU cores)
50.SS Logging options: 51.SS Logging options:
51.TP 52.TP
52\fB\-v\fR, \fB\-\-verbose\fR 53\fB\-v\fR, \fB\-\-verbose\fR
diff --git a/man/repo-checkout.1 b/man/repo-checkout.1
index 882b4baf..6dd3e6ca 100644
--- a/man/repo-checkout.1
+++ b/man/repo-checkout.1
@@ -15,7 +15,8 @@ Checkout a branch for development
15show this help message and exit 15show this help message and exit
16.TP 16.TP
17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR 17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR
18number of jobs to run in parallel (default: 4) 18number of jobs to run in parallel (default: based on
19number of CPU cores)
19.SS Logging options: 20.SS Logging options:
20.TP 21.TP
21\fB\-v\fR, \fB\-\-verbose\fR 22\fB\-v\fR, \fB\-\-verbose\fR
diff --git a/man/repo-diff.1 b/man/repo-diff.1
index aff36d24..890f8d22 100644
--- a/man/repo-diff.1
+++ b/man/repo-diff.1
@@ -19,7 +19,8 @@ to the Unix 'patch' command.
19show this help message and exit 19show this help message and exit
20.TP 20.TP
21\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR 21\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR
22number of jobs to run in parallel (default: 4) 22number of jobs to run in parallel (default: based on
23number of CPU cores)
23.TP 24.TP
24\fB\-u\fR, \fB\-\-absolute\fR 25\fB\-u\fR, \fB\-\-absolute\fR
25paths are relative to the repository root 26paths are relative to the repository root
diff --git a/man/repo-forall.1 b/man/repo-forall.1
index 194f4d20..eb2ad57b 100644
--- a/man/repo-forall.1
+++ b/man/repo-forall.1
@@ -17,7 +17,8 @@ repo forall \fB\-r\fR str1 [str2] ... \fB\-c\fR <command> [<arg>...]
17show this help message and exit 17show this help message and exit
18.TP 18.TP
19\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR 19\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR
20number of jobs to run in parallel (default: 4) 20number of jobs to run in parallel (default: based on
21number of CPU cores)
21.TP 22.TP
22\fB\-r\fR, \fB\-\-regex\fR 23\fB\-r\fR, \fB\-\-regex\fR
23execute the command only on projects matching regex or 24execute the command only on projects matching regex or
diff --git a/man/repo-grep.1 b/man/repo-grep.1
index fb515a7b..be410588 100644
--- a/man/repo-grep.1
+++ b/man/repo-grep.1
@@ -15,7 +15,8 @@ Print lines matching a pattern
15show this help message and exit 15show this help message and exit
16.TP 16.TP
17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR 17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR
18number of jobs to run in parallel (default: 4) 18number of jobs to run in parallel (default: based on
19number of CPU cores)
19.SS Logging options: 20.SS Logging options:
20.TP 21.TP
21\fB\-\-verbose\fR 22\fB\-\-verbose\fR
diff --git a/man/repo-prune.1 b/man/repo-prune.1
index 2479542c..bd68a373 100644
--- a/man/repo-prune.1
+++ b/man/repo-prune.1
@@ -15,7 +15,8 @@ Prune (delete) already merged topics
15show this help message and exit 15show this help message and exit
16.TP 16.TP
17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR 17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR
18number of jobs to run in parallel (default: 4) 18number of jobs to run in parallel (default: based on
19number of CPU cores)
19.SS Logging options: 20.SS Logging options:
20.TP 21.TP
21\fB\-v\fR, \fB\-\-verbose\fR 22\fB\-v\fR, \fB\-\-verbose\fR
diff --git a/man/repo-smartsync.1 b/man/repo-smartsync.1
index ad98b479..5d939117 100644
--- a/man/repo-smartsync.1
+++ b/man/repo-smartsync.1
@@ -15,7 +15,8 @@ Update working tree to the latest known good revision
15show this help message and exit 15show this help message and exit
16.TP 16.TP
17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR 17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR
18number of jobs to run in parallel (default: 1) 18number of jobs to run in parallel (default: based on
19number of CPU cores)
19.TP 20.TP
20\fB\-\-jobs\-network\fR=\fI\,JOBS\/\fR 21\fB\-\-jobs\-network\fR=\fI\,JOBS\/\fR
21number of network jobs to run in parallel (defaults to 22number of network jobs to run in parallel (defaults to
diff --git a/man/repo-start.1 b/man/repo-start.1
index cda3739f..b00a31f4 100644
--- a/man/repo-start.1
+++ b/man/repo-start.1
@@ -15,7 +15,8 @@ Start a new branch for development
15show this help message and exit 15show this help message and exit
16.TP 16.TP
17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR 17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR
18number of jobs to run in parallel (default: 4) 18number of jobs to run in parallel (default: based on
19number of CPU cores)
19.TP 20.TP
20\fB\-\-all\fR 21\fB\-\-all\fR
21begin branch in all projects 22begin branch in all projects
diff --git a/man/repo-status.1 b/man/repo-status.1
index 6037ae1a..fbae2c5d 100644
--- a/man/repo-status.1
+++ b/man/repo-status.1
@@ -15,7 +15,8 @@ Show the working tree status
15show this help message and exit 15show this help message and exit
16.TP 16.TP
17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR 17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR
18number of jobs to run in parallel (default: 4) 18number of jobs to run in parallel (default: based on
19number of CPU cores)
19.TP 20.TP
20\fB\-o\fR, \fB\-\-orphans\fR 21\fB\-o\fR, \fB\-\-orphans\fR
21include objects in working directory outside of repo 22include objects in working directory outside of repo
diff --git a/man/repo-sync.1 b/man/repo-sync.1
index 70f7c207..c87c9701 100644
--- a/man/repo-sync.1
+++ b/man/repo-sync.1
@@ -15,7 +15,8 @@ Update working tree to the latest revision
15show this help message and exit 15show this help message and exit
16.TP 16.TP
17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR 17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR
18number of jobs to run in parallel (default: 1) 18number of jobs to run in parallel (default: based on
19number of CPU cores)
19.TP 20.TP
20\fB\-\-jobs\-network\fR=\fI\,JOBS\/\fR 21\fB\-\-jobs\-network\fR=\fI\,JOBS\/\fR
21number of network jobs to run in parallel (defaults to 22number of network jobs to run in parallel (defaults to
diff --git a/man/repo-upload.1 b/man/repo-upload.1
index 6deed047..36a0daca 100644
--- a/man/repo-upload.1
+++ b/man/repo-upload.1
@@ -15,7 +15,8 @@ Upload changes for code review
15show this help message and exit 15show this help message and exit
16.TP 16.TP
17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR 17\fB\-j\fR JOBS, \fB\-\-jobs\fR=\fI\,JOBS\/\fR
18number of jobs to run in parallel (default: 4) 18number of jobs to run in parallel (default: based on
19number of CPU cores)
19.TP 20.TP
20\fB\-t\fR 21\fB\-t\fR
21send local branch name to Gerrit Code Review 22send local branch name to Gerrit Code Review
diff --git a/release/update-manpages b/release/update-manpages
index f841f306..6ef3ec11 100755
--- a/release/update-manpages
+++ b/release/update-manpages
@@ -47,6 +47,11 @@ def main(argv):
47 if not shutil.which('help2man'): 47 if not shutil.which('help2man'):
48 sys.exit('Please install help2man to continue.') 48 sys.exit('Please install help2man to continue.')
49 49
50 # Let repo know we're generating man pages so it can avoid some dynamic
51 # behavior (like probing active number of CPUs). We use a weird name &
52 # value to make it less likely for users to set this var themselves.
53 os.environ['_REPO_GENERATE_MANPAGES_'] = ' indeed! '
54
50 # "repo branch" is an alias for "repo branches". 55 # "repo branch" is an alias for "repo branches".
51 del subcmds.all_commands['branch'] 56 del subcmds.all_commands['branch']
52 (MANDIR / 'repo-branch.1').write_text('.so man1/repo-branches.1') 57 (MANDIR / 'repo-branch.1').write_text('.so man1/repo-branches.1')