Add a --nohooks to gclient to update/sync/revert without calling the hooks

BUG=16856

Patch from Fabien Tassin <fta@sofaraway.org>.


git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@21655 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
evan@chromium.org 17 years ago
parent 644aa0cfaa
commit 67820efbf0

@ -37,8 +37,9 @@ Files
Hooks Hooks
.gclient and DEPS files may optionally contain a list named "hooks" to .gclient and DEPS files may optionally contain a list named "hooks" to
allow custom actions to be performed based on files that have changed in the allow custom actions to be performed based on files that have changed in the
working copy as a result of a "sync"/"update" or "revert" operation. Hooks working copy as a result of a "sync"/"update" or "revert" operation. This
can also be run based on what files have been modified in the working copy could be prevented by using --nohooks (hooks run by default). Hooks can also
be run based on what files have been modified in the working copy
with the "runhooks" operation. If any of these operation are run with with the "runhooks" operation. If any of these operation are run with
--force, all known hooks will run regardless of the state of the working --force, all known hooks will run regardless of the state of the working
copy. copy.
@ -119,13 +120,15 @@ If --revision is specified, then the given revision is used in place
of the latest, either for a single solution or for all solutions. of the latest, either for a single solution or for all solutions.
Unless the --force option is provided, solutions and modules whose Unless the --force option is provided, solutions and modules whose
local revision matches the one to update (i.e., they have not changed local revision matches the one to update (i.e., they have not changed
in the repository) are *not* modified. in the repository) are *not* modified. Unless --nohooks is provided,
the hooks are run.
This a synonym for 'gclient %(alias)s' This a synonym for 'gclient %(alias)s'
usage: gclient %(cmd)s [options] [--] [svn update options/args] usage: gclient %(cmd)s [options] [--] [svn update options/args]
Valid options: Valid options:
--force : force update even for unchanged modules --force : force update even for unchanged modules
--nohooks : don't run the hooks after the update is complete
--revision REV : update/checkout all solutions with specified revision --revision REV : update/checkout all solutions with specified revision
--revision SOLUTION@REV : update given solution to specified revision --revision SOLUTION@REV : update given solution to specified revision
--deps PLATFORM(S) : sync deps for the given platform(s), or 'all' --deps PLATFORM(S) : sync deps for the given platform(s), or 'all'
@ -205,6 +208,7 @@ usage: status [options] [--] [svn diff args/options]
Valid options: Valid options:
--verbose : output additional diagnostics --verbose : output additional diagnostics
--nohooks : don't run the hooks after the update is complete
""", """,
"sync": GENERIC_UPDATE_USAGE_TEXT % {"cmd": "sync", "alias": "update"}, "sync": GENERIC_UPDATE_USAGE_TEXT % {"cmd": "sync", "alias": "update"},
"update": GENERIC_UPDATE_USAGE_TEXT % {"cmd": "update", "alias": "sync"}, "update": GENERIC_UPDATE_USAGE_TEXT % {"cmd": "update", "alias": "sync"},
@ -1238,6 +1242,10 @@ class GClient(object):
if not command in ('update', 'revert', 'runhooks'): if not command in ('update', 'revert', 'runhooks'):
return return
# Hooks only run when --nohooks is not specified
if self._options.nohooks:
return
# Get any hooks from the .gclient file. # Get any hooks from the .gclient file.
hooks = self.GetVar("hooks", []) hooks = self.GetVar("hooks", [])
# Add any hooks found in DEPS files. # Add any hooks found in DEPS files.
@ -1720,6 +1728,9 @@ def Main(argv):
option_parser.add_option("", "--force", action="store_true", default=False, option_parser.add_option("", "--force", action="store_true", default=False,
help=("(update/sync only) force update even " help=("(update/sync only) force update even "
"for modules which haven't changed")) "for modules which haven't changed"))
option_parser.add_option("", "--nohooks", action="store_true", default=False,
help=("(update/sync/revert only) prevent the hooks from "
"running"))
option_parser.add_option("", "--revision", action="append", dest="revisions", option_parser.add_option("", "--revision", action="append", dest="revisions",
metavar="REV", default=[], metavar="REV", default=[],
help=("(update/sync only) sync to a specific " help=("(update/sync only) sync to a specific "

@ -80,13 +80,14 @@ class GclientTestCase(GClientBaseTestCase):
def __init__(self, test_case, verbose=False, spec=None, def __init__(self, test_case, verbose=False, spec=None,
config_filename='a_file_name', config_filename='a_file_name',
entries_filename='a_entry_file_name', entries_filename='a_entry_file_name',
deps_file='a_deps_file_name', force=False): deps_file='a_deps_file_name', force=False, nohooks=False):
self.verbose = verbose self.verbose = verbose
self.spec = spec self.spec = spec
self.config_filename = config_filename self.config_filename = config_filename
self.entries_filename = entries_filename self.entries_filename = entries_filename
self.deps_file = deps_file self.deps_file = deps_file
self.force = force self.force = force
self.nohooks = nohooks
self.revisions = [] self.revisions = []
self.manually_grab_svn_rev = True self.manually_grab_svn_rev = True
self.deps_os = None self.deps_os = None
@ -1007,6 +1008,7 @@ class SCMWrapperTestCase(GClientBaseTestCase):
self.manually_grab_svn_rev = True self.manually_grab_svn_rev = True
self.deps_os = None self.deps_os = None
self.force = False self.force = False
self.nohooks = False
def setUp(self): def setUp(self):
GClientBaseTestCase.setUp(self) GClientBaseTestCase.setUp(self)
@ -1137,6 +1139,7 @@ class SCMWrapperTestCase(GClientBaseTestCase):
options = self.Options(verbose=True) options = self.Options(verbose=True)
base_path = os.path.join(self.root_dir, self.relpath) base_path = os.path.join(self.root_dir, self.relpath)
options.force = True options.force = True
options.nohooks = False
file_info = { file_info = {
'Repository Root': 'blah', 'Repository Root': 'blah',
'URL': self.url, 'URL': self.url,

Loading…
Cancel
Save