OLD | NEW |
---|---|
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
469 """Display status information.""" | 469 """Display status information.""" |
470 if not os.path.isdir(self.checkout_path): | 470 if not os.path.isdir(self.checkout_path): |
471 print(('\n________ couldn\'t run status in %s:\n' | 471 print(('\n________ couldn\'t run status in %s:\n' |
472 'The directory does not exist.') % self.checkout_path) | 472 'The directory does not exist.') % self.checkout_path) |
473 else: | 473 else: |
474 merge_base = self._Capture(['merge-base', 'HEAD', 'origin']) | 474 merge_base = self._Capture(['merge-base', 'HEAD', 'origin']) |
475 self._Run(['diff', '--name-status', merge_base], options) | 475 self._Run(['diff', '--name-status', merge_base], options) |
476 files = self._Capture(['diff', '--name-only', merge_base]).split() | 476 files = self._Capture(['diff', '--name-only', merge_base]).split() |
477 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 477 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
478 | 478 |
479 def FindSafesyncRev(self, rev): | |
480 # If this doesn't look like a Subversion revision (just numbers), pass it | |
M-A Ruel
2011/10/31 13:46:51
Please add a proper docstring.
Dan Beam
2011/11/06 07:34:08
Done.
| |
481 # back as maybe somebody's made a git LKGR page? TODO(dbeam): Test if sha1? | |
482 if not rev.isdigit(): | |
M-A Ruel
2011/10/31 13:46:51
Also look for "or len(rev) > 7"
We'll revision onc
Dan Beam
2011/11/06 07:34:08
Done.
| |
483 return rev | |
484 # This probably only works if using git-svn, as the LKGR is only based on | |
485 # SVN revisions at the moment. | |
486 if not scm.GIT.IsGitSvn(cwd=self.checkout_path): | |
487 help_url = ''.join(['http://code.google.com/p/chromium/wiki/UsingNewGit', | |
488 '#Initial_checkout']) | |
489 print('WARNING: Safesync URLs currently require a git-svn remote.\n' | |
490 ' Please add a git-svn remote or remove the safesync_url.\n' | |
491 ' %s\n' % help_url) | |
492 return '' | |
M-A Ruel
2011/10/31 13:46:51
No, '01234567' could still be a valid short hash.
Dan Beam
2011/11/06 07:34:08
Done.
| |
493 # Otherwise, if using git-svn, let's search the index for a sha1 that | |
494 # matches this Subversion revision (the current LKGR format). | |
495 return scm.GIT.GetSha1ForSvnRev(cwd=self.checkout_path, rev=rev) | |
496 | |
479 def FullUrlForRelativeUrl(self, url): | 497 def FullUrlForRelativeUrl(self, url): |
480 # Strip from last '/' | 498 # Strip from last '/' |
481 # Equivalent to unix basename | 499 # Equivalent to unix basename |
482 base_url = self.url | 500 base_url = self.url |
483 return base_url[:base_url.rfind('/')] + url | 501 return base_url[:base_url.rfind('/')] + url |
484 | 502 |
485 def _Clone(self, revision, url, options): | 503 def _Clone(self, revision, url, options): |
486 """Clone a git repository from the given URL. | 504 """Clone a git repository from the given URL. |
487 | 505 |
488 Once we've cloned the repo, we checkout a working branch if the specified | 506 Once we've cloned the repo, we checkout a working branch if the specified |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
979 command = ['status'] + args | 997 command = ['status'] + args |
980 if not os.path.isdir(self.checkout_path): | 998 if not os.path.isdir(self.checkout_path): |
981 # svn status won't work if the directory doesn't exist. | 999 # svn status won't work if the directory doesn't exist. |
982 print(('\n________ couldn\'t run \'%s\' in \'%s\':\n' | 1000 print(('\n________ couldn\'t run \'%s\' in \'%s\':\n' |
983 'The directory does not exist.') % | 1001 'The directory does not exist.') % |
984 (' '.join(command), self.checkout_path)) | 1002 (' '.join(command), self.checkout_path)) |
985 # There's no file list to retrieve. | 1003 # There's no file list to retrieve. |
986 else: | 1004 else: |
987 self._RunAndGetFileList(command, options, file_list) | 1005 self._RunAndGetFileList(command, options, file_list) |
988 | 1006 |
1007 # pylint: disable-msg=r0201 | |
1008 def FindSafesyncRev(self, rev): | |
M-A Ruel
2011/10/31 13:46:51
Make it a @staticmethod instead of disabling the w
Dan Beam
2011/11/06 07:34:08
Done.
| |
1009 # If the SCM currently being used is Subversion, and it appears we were | |
1010 # passed a Subversion |rev| number, just return the same |rev|. | |
1011 if rev.isdigit(): | |
1012 return rev | |
1013 # If the SCM currently being used is Subversion, but we receieved a | |
1014 # non-numeric response, ignore the safesync_url's response in this case. | |
1015 print('WARNING: The content of safesync_url is currently assumed to be\n' | |
1016 ' only a Subversion revision when using a Subversion check\n' | |
1017 ' out, but the response was not a number.\n' | |
1018 ' Ignoring for now.\n') | |
1019 return '' | |
1020 | |
989 def FullUrlForRelativeUrl(self, url): | 1021 def FullUrlForRelativeUrl(self, url): |
990 # Find the forth '/' and strip from there. A bit hackish. | 1022 # Find the forth '/' and strip from there. A bit hackish. |
991 return '/'.join(self.url.split('/')[:4]) + url | 1023 return '/'.join(self.url.split('/')[:4]) + url |
992 | 1024 |
993 def _Run(self, args, options, **kwargs): | 1025 def _Run(self, args, options, **kwargs): |
994 """Runs a commands that goes to stdout.""" | 1026 """Runs a commands that goes to stdout.""" |
995 kwargs.setdefault('cwd', self.checkout_path) | 1027 kwargs.setdefault('cwd', self.checkout_path) |
996 gclient_utils.CheckCallAndFilterAndHeader(['svn'] + args, | 1028 gclient_utils.CheckCallAndFilterAndHeader(['svn'] + args, |
997 always=options.verbose, **kwargs) | 1029 always=options.verbose, **kwargs) |
998 | 1030 |
(...skipping 29 matching lines...) Expand all Loading... | |
1028 new_command.append('--force') | 1060 new_command.append('--force') |
1029 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1061 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1030 new_command.extend(('--accept', 'theirs-conflict')) | 1062 new_command.extend(('--accept', 'theirs-conflict')) |
1031 elif options.manually_grab_svn_rev: | 1063 elif options.manually_grab_svn_rev: |
1032 new_command.append('--force') | 1064 new_command.append('--force') |
1033 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1065 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1034 new_command.extend(('--accept', 'postpone')) | 1066 new_command.extend(('--accept', 'postpone')) |
1035 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1067 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1036 new_command.extend(('--accept', 'postpone')) | 1068 new_command.extend(('--accept', 'postpone')) |
1037 return new_command | 1069 return new_command |
OLD | NEW |