Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Gclient-specific SCM-specific operations.""" | 5 """Gclient-specific SCM-specific operations.""" |
| 6 | 6 |
| 7 from __future__ import print_function | 7 from __future__ import print_function |
| 8 | 8 |
| 9 import errno | 9 import errno |
| 10 import logging | 10 import logging |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 self._UpdateBranchHeads(options, fetch=False) | 301 self._UpdateBranchHeads(options, fetch=False) |
| 302 | 302 |
| 303 cfg = gclient_utils.DefaultIndexPackConfig(self.url) | 303 cfg = gclient_utils.DefaultIndexPackConfig(self.url) |
| 304 fetch_cmd = cfg + ['fetch', self.remote, '--prune'] | 304 fetch_cmd = cfg + ['fetch', self.remote, '--prune'] |
| 305 self._Run(fetch_cmd + quiet, options, retry=True) | 305 self._Run(fetch_cmd + quiet, options, retry=True) |
| 306 self._Run(['reset', '--hard', revision] + quiet, options) | 306 self._Run(['reset', '--hard', revision] + quiet, options) |
| 307 if file_list is not None: | 307 if file_list is not None: |
| 308 files = self._Capture(['ls-files']).splitlines() | 308 files = self._Capture(['ls-files']).splitlines() |
| 309 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 309 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
| 310 | 310 |
| 311 def _DisableHooks(self): | |
| 312 hook_dir = os.path.join(self.checkout_path, '.git', 'hooks') | |
| 313 if not os.path.isdir(hook_dir): | |
| 314 return | |
| 315 for f in os.listdir(hook_dir): | |
| 316 if not f.endswith('.sample') and not f.endswith('.disabled'): | |
| 317 os.rename(os.path.join(hook_dir, f), | |
| 318 os.path.join(hook_dir, f + '.disabled')) | |
| 319 | |
| 311 def update(self, options, args, file_list): | 320 def update(self, options, args, file_list): |
| 312 """Runs git to update or transparently checkout the working copy. | 321 """Runs git to update or transparently checkout the working copy. |
| 313 | 322 |
| 314 All updated files will be appended to file_list. | 323 All updated files will be appended to file_list. |
| 315 | 324 |
| 316 Raises: | 325 Raises: |
| 317 Error: if can't get URL for relative path. | 326 Error: if can't get URL for relative path. |
| 318 """ | 327 """ |
| 319 if args: | 328 if args: |
| 320 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) | 329 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) |
| 321 | 330 |
| 322 self._CheckMinVersion("1.6.6") | 331 self._CheckMinVersion("1.6.6") |
| 323 | 332 |
| 333 self._DisableHooks() | |
|
iannucci
2014/06/19 23:31:42
Will this still run for unmanaged repos? If so, do
szager1
2014/06/20 00:49:39
I changed it to only run on managed repos.
| |
| 334 | |
| 324 # If a dependency is not pinned, track the default remote branch. | 335 # If a dependency is not pinned, track the default remote branch. |
| 325 default_rev = 'refs/remotes/%s/master' % self.remote | 336 default_rev = 'refs/remotes/%s/master' % self.remote |
| 326 url, deps_revision = gclient_utils.SplitUrlRevision(self.url) | 337 url, deps_revision = gclient_utils.SplitUrlRevision(self.url) |
| 327 rev_str = "" | 338 rev_str = "" |
| 328 revision = deps_revision | 339 revision = deps_revision |
| 329 managed = True | 340 managed = True |
| 330 if options.revision: | 341 if options.revision: |
| 331 # Override the revision number. | 342 # Override the revision number. |
| 332 revision = str(options.revision) | 343 revision = str(options.revision) |
| 333 if revision == 'unmanaged': | 344 if revision == 'unmanaged': |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 789 | 800 |
| 790 Once we've cloned the repo, we checkout a working branch if the specified | 801 Once we've cloned the repo, we checkout a working branch if the specified |
| 791 revision is a branch head. If it is a tag or a specific commit, then we | 802 revision is a branch head. If it is a tag or a specific commit, then we |
| 792 leave HEAD detached as it makes future updates simpler -- in this case the | 803 leave HEAD detached as it makes future updates simpler -- in this case the |
| 793 user should first create a new branch or switch to an existing branch before | 804 user should first create a new branch or switch to an existing branch before |
| 794 making changes in the repo.""" | 805 making changes in the repo.""" |
| 795 if not options.verbose: | 806 if not options.verbose: |
| 796 # git clone doesn't seem to insert a newline properly before printing | 807 # git clone doesn't seem to insert a newline properly before printing |
| 797 # to stdout | 808 # to stdout |
| 798 self.Print('') | 809 self.Print('') |
| 799 template_path = os.path.join( | |
| 800 os.path.dirname(THIS_FILE_PATH), 'git-templates') | |
| 801 cfg = gclient_utils.DefaultIndexPackConfig(url) | 810 cfg = gclient_utils.DefaultIndexPackConfig(url) |
| 802 clone_cmd = cfg + [ | 811 clone_cmd = cfg + ['clone', '--no-checkout', '--progress'] |
| 803 'clone', '--no-checkout', '--progress', '--template=%s' % template_path] | |
| 804 if self.cache_dir: | 812 if self.cache_dir: |
| 805 clone_cmd.append('--shared') | 813 clone_cmd.append('--shared') |
| 806 if options.verbose: | 814 if options.verbose: |
| 807 clone_cmd.append('--verbose') | 815 clone_cmd.append('--verbose') |
| 808 clone_cmd.append(url) | 816 clone_cmd.append(url) |
| 809 # If the parent directory does not exist, Git clone on Windows will not | 817 # If the parent directory does not exist, Git clone on Windows will not |
| 810 # create it, so we need to do it manually. | 818 # create it, so we need to do it manually. |
| 811 parent_dir = os.path.dirname(self.checkout_path) | 819 parent_dir = os.path.dirname(self.checkout_path) |
| 812 gclient_utils.safe_makedirs(parent_dir) | 820 gclient_utils.safe_makedirs(parent_dir) |
| 813 tmp_dir = tempfile.mkdtemp( | 821 tmp_dir = tempfile.mkdtemp( |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1489 new_command.append('--force') | 1497 new_command.append('--force') |
| 1490 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1498 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1491 new_command.extend(('--accept', 'theirs-conflict')) | 1499 new_command.extend(('--accept', 'theirs-conflict')) |
| 1492 elif options.manually_grab_svn_rev: | 1500 elif options.manually_grab_svn_rev: |
| 1493 new_command.append('--force') | 1501 new_command.append('--force') |
| 1494 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1502 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1495 new_command.extend(('--accept', 'postpone')) | 1503 new_command.extend(('--accept', 'postpone')) |
| 1496 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1504 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1497 new_command.extend(('--accept', 'postpone')) | 1505 new_command.extend(('--accept', 'postpone')) |
| 1498 return new_command | 1506 return new_command |
| OLD | NEW |