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 collections | 7 import collections |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import posixpath | 10 import posixpath |
11 import re | 11 import re |
12 import shlex | |
12 import sys | 13 import sys |
13 import tempfile | 14 import tempfile |
14 import threading | 15 import threading |
15 import time | 16 import time |
16 | 17 |
17 import gclient_utils | 18 import gclient_utils |
18 import scm | 19 import scm |
19 import subprocess2 | 20 import subprocess2 |
20 | 21 |
21 | 22 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 result, version = scm.GIT.AssertVersion('1.7') | 209 result, version = scm.GIT.AssertVersion('1.7') |
209 if not result: | 210 if not result: |
210 raise gclient_utils.Error('Git version is older than 1.7: %s' % version) | 211 raise gclient_utils.Error('Git version is older than 1.7: %s' % version) |
211 return result | 212 return result |
212 except OSError: | 213 except OSError: |
213 return False | 214 return False |
214 | 215 |
215 def GetCheckoutRoot(self): | 216 def GetCheckoutRoot(self): |
216 return scm.GIT.GetCheckoutRoot(self.checkout_path) | 217 return scm.GIT.GetCheckoutRoot(self.checkout_path) |
217 | 218 |
219 def GetRemoteURL(self, options): | |
220 try: | |
221 remote_info = self._Capture(['remote', '-v']) | |
222 except (OSError, subprocess2.CalledProcessError): | |
223 return None | |
224 for line in remote_info.splitlines(): | |
225 if line.startswith('origin'): | |
226 return shlex.split(line)[1] | |
227 return None | |
iannucci
2013/11/15 18:25:25
Maybe just `git config remote.origin.url` ? Also I
borenet
2013/11/25 13:55:42
I didn't see such a utility method, but I did see
| |
228 | |
218 def GetRevisionDate(self, _revision): | 229 def GetRevisionDate(self, _revision): |
219 """Returns the given revision's date in ISO-8601 format (which contains the | 230 """Returns the given revision's date in ISO-8601 format (which contains the |
220 time zone).""" | 231 time zone).""" |
221 # TODO(floitsch): get the time-stamp of the given revision and not just the | 232 # TODO(floitsch): get the time-stamp of the given revision and not just the |
222 # time-stamp of the currently checked out revision. | 233 # time-stamp of the currently checked out revision. |
223 return self._Capture(['log', '-n', '1', '--format=%ai']) | 234 return self._Capture(['log', '-n', '1', '--format=%ai']) |
224 | 235 |
225 @staticmethod | 236 @staticmethod |
226 def cleanup(options, args, file_list): | 237 def cleanup(options, args, file_list): |
227 """'Cleanup' the repo. | 238 """'Cleanup' the repo. |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1070 result, version = scm.SVN.AssertVersion('1.4') | 1081 result, version = scm.SVN.AssertVersion('1.4') |
1071 if not result: | 1082 if not result: |
1072 raise gclient_utils.Error('SVN version is older than 1.4: %s' % version) | 1083 raise gclient_utils.Error('SVN version is older than 1.4: %s' % version) |
1073 return result | 1084 return result |
1074 except OSError: | 1085 except OSError: |
1075 return False | 1086 return False |
1076 | 1087 |
1077 def GetCheckoutRoot(self): | 1088 def GetCheckoutRoot(self): |
1078 return scm.SVN.GetCheckoutRoot(self.checkout_path) | 1089 return scm.SVN.GetCheckoutRoot(self.checkout_path) |
1079 | 1090 |
1091 def GetRemoteURL(self, options): | |
1092 try: | |
1093 if self.relpath: | |
1094 cwd = os.path.join(self._root_dir, self.relpath) | |
1095 else: | |
1096 cwd = self._root_dir | |
1097 svn_info = scm.SVN.Capture(['info', os.curdir], cwd) | |
1098 except (OSError, subprocess2.CalledProcessError): | |
1099 return None | |
1100 url_prefix = 'URL: ' | |
1101 for line in svn_info.splitlines(): | |
1102 if line.startswith(url_prefix): | |
1103 return line[len(url_prefix):].rstrip() | |
1104 return None | |
iannucci
2013/11/15 18:25:25
I think we should probably rely on the XML version
borenet
2013/11/25 13:55:42
Done.
| |
1105 | |
1080 def GetRevisionDate(self, revision): | 1106 def GetRevisionDate(self, revision): |
1081 """Returns the given revision's date in ISO-8601 format (which contains the | 1107 """Returns the given revision's date in ISO-8601 format (which contains the |
1082 time zone).""" | 1108 time zone).""" |
1083 date = scm.SVN.Capture( | 1109 date = scm.SVN.Capture( |
1084 ['propget', '--revprop', 'svn:date', '-r', revision], | 1110 ['propget', '--revprop', 'svn:date', '-r', revision], |
1085 os.path.join(self.checkout_path, '.')) | 1111 os.path.join(self.checkout_path, '.')) |
1086 return date.strip() | 1112 return date.strip() |
1087 | 1113 |
1088 def cleanup(self, options, args, _file_list): | 1114 def cleanup(self, options, args, _file_list): |
1089 """Cleanup working copy.""" | 1115 """Cleanup working copy.""" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1450 new_command.append('--force') | 1476 new_command.append('--force') |
1451 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1477 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1452 new_command.extend(('--accept', 'theirs-conflict')) | 1478 new_command.extend(('--accept', 'theirs-conflict')) |
1453 elif options.manually_grab_svn_rev: | 1479 elif options.manually_grab_svn_rev: |
1454 new_command.append('--force') | 1480 new_command.append('--force') |
1455 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1481 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1456 new_command.extend(('--accept', 'postpone')) | 1482 new_command.extend(('--accept', 'postpone')) |
1457 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1483 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1458 new_command.extend(('--accept', 'postpone')) | 1484 new_command.extend(('--accept', 'postpone')) |
1459 return new_command | 1485 return new_command |
OLD | NEW |