From 67820efbf08a92efa103fda75890c0228018fdd4 Mon Sep 17 00:00:00 2001 From: "evan@chromium.org" Date: Mon, 27 Jul 2009 17:23:00 +0000 Subject: [PATCH] Add a --nohooks to gclient to update/sync/revert without calling the hooks BUG=16856 Patch from Fabien Tassin . git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@21655 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient.py | 17 ++++++++++++++--- tests/gclient_test.py | 5 ++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/gclient.py b/gclient.py index 9413cd11a..9dbfcedf9 100755 --- a/gclient.py +++ b/gclient.py @@ -37,8 +37,9 @@ Files Hooks .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 - working copy as a result of a "sync"/"update" or "revert" operation. Hooks - can also be run based on what files have been modified in the working copy + working copy as a result of a "sync"/"update" or "revert" operation. This + 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 --force, all known hooks will run regardless of the state of the working 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. Unless the --force option is provided, solutions and modules whose 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' usage: gclient %(cmd)s [options] [--] [svn update options/args] Valid options: --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 SOLUTION@REV : update given solution to specified revision --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: --verbose : output additional diagnostics + --nohooks : don't run the hooks after the update is complete """, "sync": GENERIC_UPDATE_USAGE_TEXT % {"cmd": "sync", "alias": "update"}, "update": GENERIC_UPDATE_USAGE_TEXT % {"cmd": "update", "alias": "sync"}, @@ -1238,6 +1242,10 @@ class GClient(object): if not command in ('update', 'revert', 'runhooks'): return + # Hooks only run when --nohooks is not specified + if self._options.nohooks: + return + # Get any hooks from the .gclient file. hooks = self.GetVar("hooks", []) # Add any hooks found in DEPS files. @@ -1720,6 +1728,9 @@ def Main(argv): option_parser.add_option("", "--force", action="store_true", default=False, help=("(update/sync only) force update even " "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", metavar="REV", default=[], help=("(update/sync only) sync to a specific " diff --git a/tests/gclient_test.py b/tests/gclient_test.py index 89d6d5dfe..539ea0c02 100644 --- a/tests/gclient_test.py +++ b/tests/gclient_test.py @@ -80,13 +80,14 @@ class GclientTestCase(GClientBaseTestCase): def __init__(self, test_case, verbose=False, spec=None, config_filename='a_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.spec = spec self.config_filename = config_filename self.entries_filename = entries_filename self.deps_file = deps_file self.force = force + self.nohooks = nohooks self.revisions = [] self.manually_grab_svn_rev = True self.deps_os = None @@ -1007,6 +1008,7 @@ class SCMWrapperTestCase(GClientBaseTestCase): self.manually_grab_svn_rev = True self.deps_os = None self.force = False + self.nohooks = False def setUp(self): GClientBaseTestCase.setUp(self) @@ -1137,6 +1139,7 @@ class SCMWrapperTestCase(GClientBaseTestCase): options = self.Options(verbose=True) base_path = os.path.join(self.root_dir, self.relpath) options.force = True + options.nohooks = False file_info = { 'Repository Root': 'blah', 'URL': self.url,