| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 hook_dir = os.path.join(self.checkout_path, '.git', 'hooks') | 320 hook_dir = os.path.join(self.checkout_path, '.git', 'hooks') |
| 321 if not os.path.isdir(hook_dir): | 321 if not os.path.isdir(hook_dir): |
| 322 return | 322 return |
| 323 for f in os.listdir(hook_dir): | 323 for f in os.listdir(hook_dir): |
| 324 if not f.endswith('.sample') and not f.endswith('.disabled'): | 324 if not f.endswith('.sample') and not f.endswith('.disabled'): |
| 325 disabled_hook_path = os.path.join(hook_dir, f + '.disabled') | 325 disabled_hook_path = os.path.join(hook_dir, f + '.disabled') |
| 326 if os.path.exists(disabled_hook_path): | 326 if os.path.exists(disabled_hook_path): |
| 327 os.remove(disabled_hook_path) | 327 os.remove(disabled_hook_path) |
| 328 os.rename(os.path.join(hook_dir, f), disabled_hook_path) | 328 os.rename(os.path.join(hook_dir, f), disabled_hook_path) |
| 329 | 329 |
| 330 def _maybe_break_locks(self, options): | |
| 331 """This removes all .lock files from this repo's .git directory, if the | |
| 332 user passed the --break_repo_locks command line flag. | |
| 333 | |
| 334 In particular, this will cleanup index.lock files, as well as ref lock | |
| 335 files. | |
| 336 """ | |
| 337 if options.break_repo_locks: | |
| 338 git_dir = os.path.join(self.checkout_path, '.git') | |
| 339 for path, _, filenames in os.walk(git_dir): | |
| 340 for filename in filenames: | |
| 341 if filename.endswith('.lock'): | |
| 342 to_break = os.path.join(path, filename) | |
| 343 self.Print('breaking lock: %s' % (to_break,)) | |
| 344 try: | |
| 345 os.remove(to_break) | |
| 346 except OSError as ex: | |
| 347 self.Print('FAILED to break lock: %s: %s' % (to_break, ex)) | |
| 348 raise | |
| 349 | |
| 350 | |
| 351 def update(self, options, args, file_list): | 330 def update(self, options, args, file_list): |
| 352 """Runs git to update or transparently checkout the working copy. | 331 """Runs git to update or transparently checkout the working copy. |
| 353 | 332 |
| 354 All updated files will be appended to file_list. | 333 All updated files will be appended to file_list. |
| 355 | 334 |
| 356 Raises: | 335 Raises: |
| 357 Error: if can't get URL for relative path. | 336 Error: if can't get URL for relative path. |
| 358 """ | 337 """ |
| 359 if args: | 338 if args: |
| 360 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) | 339 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 # Make the output a little prettier. It's nice to have some whitespace | 426 # Make the output a little prettier. It's nice to have some whitespace |
| 448 # between projects when cloning. | 427 # between projects when cloning. |
| 449 self.Print('') | 428 self.Print('') |
| 450 return self._Capture(['rev-parse', '--verify', 'HEAD']) | 429 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
| 451 | 430 |
| 452 if not managed: | 431 if not managed: |
| 453 self._UpdateBranchHeads(options, fetch=False) | 432 self._UpdateBranchHeads(options, fetch=False) |
| 454 self.Print('________ unmanaged solution; skipping %s' % self.relpath) | 433 self.Print('________ unmanaged solution; skipping %s' % self.relpath) |
| 455 return self._Capture(['rev-parse', '--verify', 'HEAD']) | 434 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
| 456 | 435 |
| 457 self._maybe_break_locks(options) | |
| 458 | |
| 459 if mirror: | 436 if mirror: |
| 460 self._UpdateMirror(mirror, options) | 437 self._UpdateMirror(mirror, options) |
| 461 | 438 |
| 462 # See if the url has changed (the unittests use git://foo for the url, let | 439 # See if the url has changed (the unittests use git://foo for the url, let |
| 463 # that through). | 440 # that through). |
| 464 current_url = self._Capture(['config', 'remote.%s.url' % self.remote]) | 441 current_url = self._Capture(['config', 'remote.%s.url' % self.remote]) |
| 465 return_early = False | 442 return_early = False |
| 466 # TODO(maruel): Delete url != 'git://foo' since it's just to make the | 443 # TODO(maruel): Delete url != 'git://foo' since it's just to make the |
| 467 # unit test pass. (and update the comment above) | 444 # unit test pass. (and update the comment above) |
| 468 # Skip url auto-correction if remote.origin.gclient-auto-fix-url is set. | 445 # Skip url auto-correction if remote.origin.gclient-auto-fix-url is set. |
| (...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 new_command.append('--force') | 1690 new_command.append('--force') |
| 1714 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1691 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1715 new_command.extend(('--accept', 'theirs-conflict')) | 1692 new_command.extend(('--accept', 'theirs-conflict')) |
| 1716 elif options.manually_grab_svn_rev: | 1693 elif options.manually_grab_svn_rev: |
| 1717 new_command.append('--force') | 1694 new_command.append('--force') |
| 1718 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1695 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1719 new_command.extend(('--accept', 'postpone')) | 1696 new_command.extend(('--accept', 'postpone')) |
| 1720 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1697 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1721 new_command.extend(('--accept', 'postpone')) | 1698 new_command.extend(('--accept', 'postpone')) |
| 1722 return new_command | 1699 return new_command |
| OLD | NEW |