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

Unified Diff: fetch.py

Issue 14087013: Support "--nohooks" on fetch (Closed) Base URL: git@github.com:jankeromnes/depot_tools@master
Patch Set: Created 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fetch.py
diff --git a/fetch.py b/fetch.py
index aca0f88d60945c16fb49d9d79051e3553a2e6009..2c01a105320ec5626a18799e8aec510f20130a1b 100755
--- a/fetch.py
+++ b/fetch.py
@@ -43,9 +43,10 @@ class Checkout(object):
|root|: the directory into which the checkout will be performed, as returned
by the recipe. This is a relative path from |base|.
"""
- def __init__(self, dryrun, spec, root):
+ def __init__(self, dryrun, nohooks, spec, root):
self.base = os.getcwd()
self.dryrun = dryrun
+ self.nohooks = nohooks
self.spec = spec
self.root = root
@@ -97,8 +98,8 @@ class SvnCheckout(Checkout):
class GclientGitCheckout(GclientCheckout, GitCheckout):
- def __init__(self, dryrun, spec, root):
- super(GclientGitCheckout, self).__init__(dryrun, spec, root)
+ def __init__(self, dryrun, nohooks, spec, root):
+ super(GclientGitCheckout, self).__init__(dryrun, nohooks, spec, root)
assert 'solutions' in self.spec
keys = ['solutions', 'target_os', 'target_os_only']
gclient_spec = '\n'.join('%s = %s' % (key, self.spec[key])
@@ -114,7 +115,11 @@ class GclientGitCheckout(GclientCheckout, GitCheckout):
# Configure and do the gclient checkout.
self.run_gclient('config', '--spec', self.spec['gclient_spec'])
- self.run_gclient('sync')
+
+ if self.nohooks:
+ self.run_gclient('sync', '--nohooks')
+ else:
+ self.run_gclient('sync')
# Configure git.
wd = os.path.join(self.base, self.root)
@@ -129,8 +134,8 @@ class GclientGitCheckout(GclientCheckout, GitCheckout):
class GclientGitSvnCheckout(GclientGitCheckout, SvnCheckout):
- def __init__(self, dryrun, spec, root):
- super(GclientGitSvnCheckout, self).__init__(dryrun, spec, root)
+ def __init__(self, dryrun, nohooks, spec, root):
+ super(GclientGitSvnCheckout, self).__init__(dryrun, nohooks, spec, root)
assert 'svn_url' in self.spec
assert 'svn_branch' in self.spec
assert 'svn_ref' in self.spec
@@ -173,12 +178,12 @@ CHECKOUT_TYPE_MAP = {
}
-def CheckoutFactory(type_name, dryrun, spec, root):
+def CheckoutFactory(type_name, dryrun, nohooks, spec, root):
"""Factory to build Checkout class instances."""
class_ = CHECKOUT_TYPE_MAP.get(type_name)
if not class_:
raise KeyError('unrecognized checkout type: %s' % type_name)
- return class_(dryrun, spec, root)
+ return class_(dryrun, nohooks, spec, root)
#################################################
@@ -191,7 +196,7 @@ def usage(msg=None):
print (
"""
-usage: %s [-n|--dry-run] <recipe> [--property=value [--property2=value2 ...]]
+usage: %s [-n|--dry-run] [--nohooks] <recipe> [--property=value [--property2=value2 ...]]
""" % os.path.basename(sys.argv[0]))
sys.exit(bool(msg))
@@ -208,6 +213,11 @@ def handle_args(argv):
dryrun = True
argv.pop(1)
+ nohooks = False
+ if argv[1] == '--nohooks':
+ nohooks = True
+ argv.pop(1)
agable 2013/04/17 17:10:40 I'm going to do a full rewrite of the fetch and re
+
def looks_like_arg(arg):
return arg.startswith('--') and arg.count('=') == 1
@@ -217,7 +227,7 @@ def handle_args(argv):
recipe = argv[1]
props = argv[2:]
- return dryrun, recipe, props
+ return dryrun, nohooks, recipe, props
def run_recipe_fetch(recipe, props, aliased=False):
@@ -242,7 +252,7 @@ def run_recipe_fetch(recipe, props, aliased=False):
return spec, root
-def run(dryrun, spec, root):
+def run(dryrun, nohooks, spec, root):
"""Perform a checkout with the given type and configuration.
Args:
@@ -255,7 +265,8 @@ def run(dryrun, spec, root):
checkout_type = spec['type']
checkout_spec = spec['%s_spec' % checkout_type]
try:
- checkout = CheckoutFactory(checkout_type, dryrun, checkout_spec, root)
+ checkout = CheckoutFactory(
+ checkout_type, dryrun, nohooks, checkout_spec, root)
except KeyError:
return 1
if checkout.exists():
@@ -269,9 +280,9 @@ def run(dryrun, spec, root):
def main():
- dryrun, recipe, props = handle_args(sys.argv)
+ dryrun, nohooks, recipe, props = handle_args(sys.argv)
spec, root = run_recipe_fetch(recipe, props)
- return run(dryrun, spec, root)
+ return run(dryrun, nohooks, spec, root)
if __name__ == '__main__':
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698