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 import logging | 7 import logging |
8 import os | 8 import os |
9 import posixpath | 9 import posixpath |
10 import re | 10 import re |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
648 print('') | 648 print('') |
649 | 649 |
650 clone_cmd = ['clone', '--progress'] | 650 clone_cmd = ['clone', '--progress'] |
651 if revision.startswith('refs/heads/'): | 651 if revision.startswith('refs/heads/'): |
652 clone_cmd.extend(['-b', revision.replace('refs/heads/', '')]) | 652 clone_cmd.extend(['-b', revision.replace('refs/heads/', '')]) |
653 detach_head = False | 653 detach_head = False |
654 else: | 654 else: |
655 detach_head = True | 655 detach_head = True |
656 if options.verbose: | 656 if options.verbose: |
657 clone_cmd.append('--verbose') | 657 clone_cmd.append('--verbose') |
658 if options.with_branch_heads: | |
659 clone_cmd.extend(['--config', 'remote.origin.fetch=+refs/branch-heads/*:' | |
660 'refs/remotes/branch-heads/*']) | |
658 clone_cmd.extend([url, self.checkout_path]) | 661 clone_cmd.extend([url, self.checkout_path]) |
659 | 662 |
660 # If the parent directory does not exist, Git clone on Windows will not | 663 # If the parent directory does not exist, Git clone on Windows will not |
661 # create it, so we need to do it manually. | 664 # create it, so we need to do it manually. |
662 parent_dir = os.path.dirname(self.checkout_path) | 665 parent_dir = os.path.dirname(self.checkout_path) |
663 if not os.path.exists(parent_dir): | 666 if not os.path.exists(parent_dir): |
664 gclient_utils.safe_makedirs(parent_dir) | 667 gclient_utils.safe_makedirs(parent_dir) |
665 | 668 |
666 percent_re = re.compile('.* ([0-9]{1,2})% .*') | 669 percent_re = re.compile('.* ([0-9]{1,2})% .*') |
667 def _GitFilter(line): | 670 def _GitFilter(line): |
668 # git uses an escape sequence to clear the line; elide it. | 671 # git uses an escape sequence to clear the line; elide it. |
669 esc = line.find(unichr(033)) | 672 esc = line.find(unichr(033)) |
670 if esc > -1: | 673 if esc > -1: |
671 line = line[:esc] | 674 line = line[:esc] |
672 match = percent_re.match(line) | 675 match = percent_re.match(line) |
673 if not match or not int(match.group(1)) % 10: | 676 if not match or not int(match.group(1)) % 10: |
674 print '%s' % line | 677 print '%s' % line |
675 | 678 |
676 for _ in range(3): | 679 for _ in range(3): |
677 try: | 680 try: |
678 self._Run(clone_cmd, options, cwd=self._root_dir, filter_fn=_GitFilter, | 681 self._Run(clone_cmd, options, cwd=self._root_dir, filter_fn=_GitFilter, |
679 print_stdout=False) | 682 print_stdout=False) |
683 # Update the "branch-heads" remote-tracking branches, since clone | |
684 # doesn't automatically fetch those, and we might need it to checkout a | |
685 # specific revision below. | |
686 if options.with_branch_heads: | |
687 fetch_cmd = ['fetch'] | |
szager1
2013/03/07 01:12:32
fetch_cmd = ['fetch', 'origin']
It's possible tha
Michael Moss
2013/03/07 03:12:07
Done.
| |
688 if options.verbose: | |
689 fetch_cmd.append('--verbose') | |
690 self._Run(fetch_cmd, options) | |
680 break | 691 break |
681 except subprocess2.CalledProcessError, e: | 692 except subprocess2.CalledProcessError, e: |
682 # Too bad we don't have access to the actual output yet. | 693 # Too bad we don't have access to the actual output yet. |
683 # We should check for "transfer closed with NNN bytes remaining to | 694 # We should check for "transfer closed with NNN bytes remaining to |
684 # read". In the meantime, just make sure .git exists. | 695 # read". In the meantime, just make sure .git exists. |
685 if (e.returncode == 128 and | 696 if (e.returncode == 128 and |
686 os.path.exists(os.path.join(self.checkout_path, '.git'))): | 697 os.path.exists(os.path.join(self.checkout_path, '.git'))): |
687 print(str(e)) | 698 print(str(e)) |
688 print('Retrying...') | 699 print('Retrying...') |
689 continue | 700 continue |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1225 new_command.append('--force') | 1236 new_command.append('--force') |
1226 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1237 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1227 new_command.extend(('--accept', 'theirs-conflict')) | 1238 new_command.extend(('--accept', 'theirs-conflict')) |
1228 elif options.manually_grab_svn_rev: | 1239 elif options.manually_grab_svn_rev: |
1229 new_command.append('--force') | 1240 new_command.append('--force') |
1230 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1241 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1231 new_command.extend(('--accept', 'postpone')) | 1242 new_command.extend(('--accept', 'postpone')) |
1232 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1243 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1233 new_command.extend(('--accept', 'postpone')) | 1244 new_command.extend(('--accept', 'postpone')) |
1234 return new_command | 1245 return new_command |
OLD | NEW |