summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2020-02-06 00:04:21 -0500
committerMike Frysinger <vapier@google.com>2020-02-12 11:46:30 +0000
commitf700ac79c3437b248f7add9cd1f53a44785d04f9 (patch)
tree0acaff20fc01a8b17e23b9baa2f8c447cfdd85a6
parent6f1c626a9b38af3cec15df8975bd26dd267bb07e (diff)
downloadgit-repo-f700ac79c3437b248f7add9cd1f53a44785d04f9.tar.gz
repo: move parser init out of module scope
We import the wrapper on the fly, so minimize how much code we run in module scope. It's pointless/wasted when importing. Change-Id: I4a71c2030325d0a639585671cd7ebe8f22687ecd Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254072 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net> Reviewed-by: Mike Frysinger <vapier@google.com>
-rwxr-xr-xrepo150
1 files changed, 68 insertions, 82 deletions
diff --git a/repo b/repo
index 01d5c46d..7bf48023 100755
--- a/repo
+++ b/repo
@@ -204,88 +204,73 @@ gpg_dir = os.path.join(home_dot_repo, 'gnupg')
204extra_args = [] 204extra_args = []
205init_optparse = optparse.OptionParser(usage="repo init -u url [options]") 205init_optparse = optparse.OptionParser(usage="repo init -u url [options]")
206 206
207# Logging 207def _InitParser():
208group = init_optparse.add_option_group('Logging options') 208 """Setup the init subcommand parser."""
209group.add_option('-q', '--quiet', 209 # Logging.
210 dest="quiet", action="store_true", default=False, 210 group = init_optparse.add_option_group('Logging options')
211 help="be quiet") 211 group.add_option('-q', '--quiet',
212 212 action='store_true', default=False,
213# Manifest 213 help='be quiet')
214group = init_optparse.add_option_group('Manifest options') 214
215group.add_option('-u', '--manifest-url', 215 # Manifest.
216 dest='manifest_url', 216 group = init_optparse.add_option_group('Manifest options')
217 help='manifest repository location', metavar='URL') 217 group.add_option('-u', '--manifest-url',
218group.add_option('-b', '--manifest-branch', 218 help='manifest repository location', metavar='URL')
219 dest='manifest_branch', 219 group.add_option('-b', '--manifest-branch',
220 help='manifest branch or revision', metavar='REVISION') 220 help='manifest branch or revision', metavar='REVISION')
221group.add_option('-m', '--manifest-name', 221 group.add_option('-m', '--manifest-name',
222 dest='manifest_name', 222 help='initial manifest file', metavar='NAME.xml')
223 help='initial manifest file', metavar='NAME.xml') 223 group.add_option('--current-branch',
224group.add_option('--current-branch', 224 dest='current_branch_only', action='store_true',
225 dest='current_branch_only', action='store_true', 225 help='fetch only current manifest branch from server')
226 help='fetch only current manifest branch from server') 226 group.add_option('--mirror', action='store_true',
227group.add_option('--mirror', 227 help='create a replica of the remote repositories '
228 dest='mirror', action='store_true', 228 'rather than a client working directory')
229 help='create a replica of the remote repositories ' 229 group.add_option('--reference',
230 'rather than a client working directory') 230 help='location of mirror directory', metavar='DIR')
231group.add_option('--reference', 231 group.add_option('--dissociate', action='store_true',
232 dest='reference', 232 help='dissociate from reference mirrors after clone')
233 help='location of mirror directory', metavar='DIR') 233 group.add_option('--depth', type='int', default=None,
234group.add_option('--dissociate', 234 help='create a shallow clone with given depth; '
235 dest='dissociate', action='store_true', 235 'see git clone')
236 help='dissociate from reference mirrors after clone') 236 group.add_option('--partial-clone', action='store_true',
237group.add_option('--depth', type='int', default=None, 237 help='perform partial clone (https://git-scm.com/'
238 dest='depth', 238 'docs/gitrepository-layout#_code_partialclone_code)')
239 help='create a shallow clone with given depth; see git clone') 239 group.add_option('--clone-filter', action='store', default='blob:none',
240group.add_option('--partial-clone', action='store_true', 240 help='filter for use with --partial-clone '
241 dest='partial_clone', 241 '[default: %default]')
242 help='perform partial clone (https://git-scm.com/' 242 group.add_option('--archive', action='store_true',
243 'docs/gitrepository-layout#_code_partialclone_code)') 243 help='checkout an archive instead of a git repository for '
244group.add_option('--clone-filter', action='store', default='blob:none', 244 'each project. See git archive.')
245 dest='clone_filter', 245 group.add_option('--submodules', action='store_true',
246 help='filter for use with --partial-clone [default: %default]') 246 help='sync any submodules associated with the manifest repo')
247group.add_option('--archive', 247 group.add_option('-g', '--groups', default='default',
248 dest='archive', action='store_true', 248 help='restrict manifest projects to ones with specified '
249 help='checkout an archive instead of a git repository for ' 249 'group(s) [default|all|G1,G2,G3|G4,-G5,-G6]',
250 'each project. See git archive.') 250 metavar='GROUP')
251group.add_option('--submodules', 251 group.add_option('-p', '--platform', default='auto',
252 dest='submodules', action='store_true', 252 help='restrict manifest projects to ones with a specified '
253 help='sync any submodules associated with the manifest repo') 253 'platform group [auto|all|none|linux|darwin|...]',
254group.add_option('-g', '--groups', 254 metavar='PLATFORM')
255 dest='groups', default='default', 255 group.add_option('--no-clone-bundle', action='store_true',
256 help='restrict manifest projects to ones with specified ' 256 help='disable use of /clone.bundle on HTTP/HTTPS')
257 'group(s) [default|all|G1,G2,G3|G4,-G5,-G6]', 257 group.add_option('--no-tags', action='store_true',
258 metavar='GROUP') 258 help="don't fetch tags in the manifest")
259group.add_option('-p', '--platform', 259
260 dest='platform', default="auto", 260 # Tool.
261 help='restrict manifest projects to ones with a specified ' 261 group = init_optparse.add_option_group('repo Version options')
262 'platform group [auto|all|none|linux|darwin|...]', 262 group.add_option('--repo-url', metavar='URL',
263 metavar='PLATFORM') 263 help='repo repository location ($REPO_URL)')
264group.add_option('--no-clone-bundle', 264 group.add_option('--repo-branch', metavar='REVISION',
265 dest='no_clone_bundle', action='store_true', 265 help='repo branch or revision ($REPO_REV)')
266 help='disable use of /clone.bundle on HTTP/HTTPS') 266 group.add_option('--no-repo-verify', action='store_true',
267group.add_option('--no-tags', 267 help='do not verify repo source code')
268 dest='no_tags', action='store_true', 268
269 help="don't fetch tags in the manifest") 269 # Other.
270 270 group = init_optparse.add_option_group('Other options')
271 271 group.add_option('--config-name',
272# Tool 272 action='store_true', default=False,
273group = init_optparse.add_option_group('repo Version options') 273 help='Always prompt for name/e-mail')
274group.add_option('--repo-url',
275 dest='repo_url',
276 help='repo repository location ($REPO_URL)', metavar='URL')
277group.add_option('--repo-branch',
278 dest='repo_branch',
279 help='repo branch or revision ($REPO_REV)', metavar='REVISION')
280group.add_option('--no-repo-verify',
281 dest='no_repo_verify', action='store_true',
282 help='do not verify repo source code')
283
284# Other
285group = init_optparse.add_option_group('Other options')
286group.add_option('--config-name',
287 dest='config_name', action="store_true", default=False,
288 help='Always prompt for name/e-mail')
289 274
290 275
291def _GitcInitOptions(init_optparse_arg): 276def _GitcInitOptions(init_optparse_arg):
@@ -931,6 +916,7 @@ def main(orig_args):
931 'command from the corresponding client under /gitc/', 916 'command from the corresponding client under /gitc/',
932 file=sys.stderr) 917 file=sys.stderr)
933 sys.exit(1) 918 sys.exit(1)
919 _InitParser()
934 if not repo_main: 920 if not repo_main:
935 if opt.help: 921 if opt.help:
936 _Usage() 922 _Usage()