Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1174)

Unified Diff: recipes.py

Issue 2839353003: [recipes.py] move remote arg parsing to its module (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_engine/remote.py ('k') | unittests/remote_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipes.py
diff --git a/recipes.py b/recipes.py
index 090c7d02d48c0a71304eca3adfa07367ee4ec69d..15d6786dc9812f3adca2481ded1a6e0bf1465409 100755
--- a/recipes.py
+++ b/recipes.py
@@ -220,12 +220,6 @@ def run(config_file, package_deps, args):
ret, args.output_result_json, stream_engine, engine_flags)
-def remote(args):
- from recipe_engine import remote
-
- return remote.main(args)
-
-
class ProjectOverrideAction(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
p = values.split('=', 2)
@@ -351,7 +345,10 @@ def add_common_args(parser):
with open(value) as fd:
return jsonpb.ParseDict(json.load(fd), arguments_pb2.Arguments())
- parser.set_defaults(operational_args=arguments_pb2.Arguments())
+ parser.set_defaults(
+ operational_args=arguments_pb2.Arguments(),
+ bare_command=False, # don't call postprocess_func, don't use package_deps
dnj 2017/04/27 16:38:40 add a TODO here, remove this when "remote" command
+ )
parser.add_argument(
'--operational-args-path',
@@ -362,14 +359,16 @@ def add_common_args(parser):
'be integrated into the runtime parameters.')
def post_process_args(parser, args):
- if args.command == 'remote':
- # TODO(iannucci): this is a hack; remote doesn't behave like ANY other
- # commands. A way to solve this will be to allow --package to take
- # a remote repo and then simply remove the remote subcommand entirely.
- return
-
- if not args.package:
- parser.error('%s requires --package' % args.command)
+ if args.bare_command:
+ # TODO(iannucci): this is gross, and only for the remote subcommand;
+ # remote doesn't behave like ANY other commands. A way to solve this will
+ # be to allow --package to take a remote repo and then simply remove the
+ # remote subcommand entirely.
+ if args.package is not None:
+ parser.error('%s forbids --package' % args.command)
+ else:
+ if not args.package:
+ parser.error('%s requires --package' % args.command)
return post_process_args
@@ -381,7 +380,8 @@ def main():
common_postprocess_func = add_common_args(parser)
from recipe_engine import fetch, lint_test, bundle, depgraph, autoroll
- to_add = [fetch, lint_test, bundle, depgraph, autoroll]
+ from recipe_engine import remote
dnj 2017/04/27 16:38:40 Since you're adding a lot of optional flags, can w
+ to_add = [fetch, lint_test, bundle, depgraph, autoroll, remote]
subp = parser.add_subparsers()
for module in to_add:
@@ -464,33 +464,6 @@ def main():
'issue=12345. The property value will be decoded as JSON, but if '
'this decoding fails the value will be interpreted as a string.')
-
- remote_p = subp.add_parser(
- 'remote',
- description='Invoke a recipe command from specified repo and revision')
- remote_p.set_defaults(command='remote')
- remote_p.add_argument(
- '--repository', required=True,
- help='URL of a git repository to fetch')
- remote_p.add_argument(
- '--revision',
- help=(
- 'Git commit hash to check out; defaults to latest revision on master'
- ' (refs/heads/master)'
- ))
- remote_p.add_argument(
- '--workdir',
- type=os.path.abspath,
- help='The working directory of repo checkout')
- remote_p.add_argument(
- '--use-gitiles', action='store_true',
- help='Use Gitiles-specific way to fetch repo (potentially cheaper for '
- 'large repos)')
- remote_p.add_argument(
- 'remote_args', nargs='*',
- help='Arguments to pass to fetched repo\'s recipes.py')
-
-
refs_p = subp.add_parser(
'refs',
description='List places referencing given recipe module(s).')
@@ -606,10 +579,8 @@ def main():
def _real_main(args):
from recipe_engine import package
- # Commands which do not require config_file, package_deps, and other objects
- # initialized later.
- if args.command == 'remote':
- return remote(args)
+ if args.bare_command:
+ return args.func(None, args)
config_file = args.package
repo_root = package.InfraRepoConfig().from_recipes_cfg(args.package.path)
« no previous file with comments | « recipe_engine/remote.py ('k') | unittests/remote_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698