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 |
330 def update(self, options, args, file_list): | 351 def update(self, options, args, file_list): |
331 """Runs git to update or transparently checkout the working copy. | 352 """Runs git to update or transparently checkout the working copy. |
332 | 353 |
333 All updated files will be appended to file_list. | 354 All updated files will be appended to file_list. |
334 | 355 |
335 Raises: | 356 Raises: |
336 Error: if can't get URL for relative path. | 357 Error: if can't get URL for relative path. |
337 """ | 358 """ |
338 if args: | 359 if args: |
339 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) | 360 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 # Make the output a little prettier. It's nice to have some whitespace | 447 # Make the output a little prettier. It's nice to have some whitespace |
427 # between projects when cloning. | 448 # between projects when cloning. |
428 self.Print('') | 449 self.Print('') |
429 return self._Capture(['rev-parse', '--verify', 'HEAD']) | 450 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
430 | 451 |
431 if not managed: | 452 if not managed: |
432 self._UpdateBranchHeads(options, fetch=False) | 453 self._UpdateBranchHeads(options, fetch=False) |
433 self.Print('________ unmanaged solution; skipping %s' % self.relpath) | 454 self.Print('________ unmanaged solution; skipping %s' % self.relpath) |
434 return self._Capture(['rev-parse', '--verify', 'HEAD']) | 455 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
435 | 456 |
| 457 self._maybe_break_locks(options) |
| 458 |
436 if mirror: | 459 if mirror: |
437 self._UpdateMirror(mirror, options) | 460 self._UpdateMirror(mirror, options) |
438 | 461 |
439 # See if the url has changed (the unittests use git://foo for the url, let | 462 # See if the url has changed (the unittests use git://foo for the url, let |
440 # that through). | 463 # that through). |
441 current_url = self._Capture(['config', 'remote.%s.url' % self.remote]) | 464 current_url = self._Capture(['config', 'remote.%s.url' % self.remote]) |
442 return_early = False | 465 return_early = False |
443 # TODO(maruel): Delete url != 'git://foo' since it's just to make the | 466 # TODO(maruel): Delete url != 'git://foo' since it's just to make the |
444 # unit test pass. (and update the comment above) | 467 # unit test pass. (and update the comment above) |
445 # Skip url auto-correction if remote.origin.gclient-auto-fix-url is set. | 468 # 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... |
1690 new_command.append('--force') | 1713 new_command.append('--force') |
1691 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1714 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1692 new_command.extend(('--accept', 'theirs-conflict')) | 1715 new_command.extend(('--accept', 'theirs-conflict')) |
1693 elif options.manually_grab_svn_rev: | 1716 elif options.manually_grab_svn_rev: |
1694 new_command.append('--force') | 1717 new_command.append('--force') |
1695 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1718 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1696 new_command.extend(('--accept', 'postpone')) | 1719 new_command.extend(('--accept', 'postpone')) |
1697 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1720 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1698 new_command.extend(('--accept', 'postpone')) | 1721 new_command.extend(('--accept', 'postpone')) |
1699 return new_command | 1722 return new_command |
OLD | NEW |