Remove hooks until Windows performance issues are sorted.

R=iannucci@chromium.org,hinoka@chromium.org
BUG=

Review URL: https://codereview.chromium.org/348703002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@278717 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_scm.py b/gclient_scm.py
index 67d6867..a9a3019 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -308,6 +308,15 @@
       files = self._Capture(['ls-files']).splitlines()
       file_list.extend([os.path.join(self.checkout_path, f) for f in files])
 
+  def _DisableHooks(self):
+    hook_dir = os.path.join(self.checkout_path, '.git', 'hooks')
+    if not os.path.isdir(hook_dir):
+      return
+    for f in os.listdir(hook_dir):
+      if not f.endswith('.sample') and not f.endswith('.disabled'):
+        os.rename(os.path.join(hook_dir, f),
+                  os.path.join(hook_dir, f + '.disabled'))
+
   def update(self, options, args, file_list):
     """Runs git to update or transparently checkout the working copy.
 
@@ -338,6 +347,9 @@
     if not revision:
       revision = default_rev
 
+    if managed:
+      self._DisableHooks()
+
     if gclient_utils.IsDateRevision(revision):
       # Date-revisions only work on git-repositories if the reflog hasn't
       # expired yet. Use rev-list to get the corresponding revision.
@@ -796,11 +808,8 @@
       # git clone doesn't seem to insert a newline properly before printing
       # to stdout
       self.Print('')
-    template_path = os.path.join(
-        os.path.dirname(THIS_FILE_PATH), 'git-templates')
     cfg = gclient_utils.DefaultIndexPackConfig(url)
-    clone_cmd = cfg + [
-        'clone', '--no-checkout', '--progress', '--template=%s' % template_path]
+    clone_cmd = cfg + ['clone', '--no-checkout', '--progress']
     if self.cache_dir:
       clone_cmd.append('--shared')
     if options.verbose:
diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py
index 55bc9c3..e91b48c 100755
--- a/tests/gclient_scm_test.py
+++ b/tests/gclient_scm_test.py
@@ -1322,6 +1322,8 @@
   def testUpdateNoDotGit(self):
     options = self.Options()
 
+    gclient_scm.os.path.isdir(
+        os.path.join(self.base_path, '.git', 'hooks')).AndReturn(False)
     gclient_scm.os.path.exists(self.base_path).AndReturn(True)
     gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
     gclient_scm.os.path.exists(os.path.join(self.base_path, '.git')
@@ -1350,6 +1352,8 @@
   def testUpdateConflict(self):
     options = self.Options()
 
+    gclient_scm.os.path.isdir(
+        os.path.join(self.base_path, '.git', 'hooks')).AndReturn(False)
     gclient_scm.os.path.exists(self.base_path).AndReturn(True)
     gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
     gclient_scm.os.path.exists(os.path.join(self.base_path, '.git')