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 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 if revision.startswith('refs/'): | 295 if revision.startswith('refs/'): |
296 rev_type = "branch" | 296 rev_type = "branch" |
297 elif revision.startswith(self.remote + '/'): | 297 elif revision.startswith(self.remote + '/'): |
298 # For compatibility with old naming, translate 'origin' to 'refs/heads' | 298 # For compatibility with old naming, translate 'origin' to 'refs/heads' |
299 revision = revision.replace(self.remote + '/', 'refs/heads/') | 299 revision = revision.replace(self.remote + '/', 'refs/heads/') |
300 rev_type = "branch" | 300 rev_type = "branch" |
301 else: | 301 else: |
302 # hash is also a tag, only make a distinction at checkout | 302 # hash is also a tag, only make a distinction at checkout |
303 rev_type = "hash" | 303 rev_type = "hash" |
304 | 304 |
305 if not managed: | 305 if (not os.path.exists(self.checkout_path) or |
306 self._UpdateBranchHeads(options, fetch=False) | 306 (os.path.isdir(self.checkout_path) and |
307 self.UpdateSubmoduleConfig() | 307 not os.path.exists(os.path.join(self.checkout_path, '.git')))): |
308 print ('________ unmanaged solution; skipping %s' % self.relpath) | |
309 return self._Capture(['rev-parse', '--verify', 'HEAD']) | |
310 | |
311 needs_delete = False | |
312 exists = os.path.exists(self.checkout_path) | |
313 if exists and not os.path.exists(os.path.join(self.checkout_path, '.git')): | |
314 needs_delete = True | |
315 | |
316 # See if the url has changed (the unittests use git://foo for the url, let | |
317 # that through). | |
318 return_early = False | |
319 if exists and not needs_delete: | |
320 current_url = self._Capture(['config', 'remote.%s.url' % self.remote]) | |
321 # TODO(maruel): Delete url != 'git://foo' since it's just to make the | |
322 # unit test pass. (and update the comment above) | |
323 # Skip url auto-correction if remote.origin.gclient-auto-fix-url is set. | |
324 # This allows devs to use experimental repos which have a different url | |
325 # but whose branch(s) are the same as official repos. | |
326 if (current_url != url and url != 'git://foo'): | |
327 auto_fix = 'True' | |
328 try: | |
329 auto_fix = self._Capture( | |
330 ['config', 'remote.%s.gclient-auto-fix-url' % self.remote], | |
331 cwd=self.checkout_path).strip() | |
332 except subprocess2.CalledProcessError: | |
333 pass | |
334 if auto_fix in ('1', 'true', 'True', 'yes', 'Yes', 'y', 'Y'): | |
335 print('_____ switching %s to a new upstream' % self.relpath) | |
336 # Make sure it's clean | |
337 self._CheckClean(rev_str) | |
338 # Switch over to the new upstream | |
339 self._Run(['remote', 'set-url', self.remote, url], options) | |
340 self._FetchAndReset(revision, file_list, options) | |
341 return_early = True | |
342 | |
343 if (needs_delete and | |
344 gclient_utils.enable_deletion_of_conflicting_checkouts()): | |
345 if options.force: | |
346 print('Conflicting directory found in %s. Removing.' | |
347 % self.checkout_path) | |
348 gclient_utils.rmtree(self.checkout_path) | |
349 else: | |
350 raise gclient_utils.Error('Conflicting directory found in %s. Please ' | |
351 'delete it or run with --force.' | |
352 % self.checkout_path) | |
353 | |
354 if not os.path.exists(self.checkout_path): | |
355 self._Clone(revision, url, options) | 308 self._Clone(revision, url, options) |
356 self.UpdateSubmoduleConfig() | 309 self.UpdateSubmoduleConfig() |
357 if file_list is not None: | 310 if file_list is not None: |
358 files = self._Capture(['ls-files']).splitlines() | 311 files = self._Capture(['ls-files']).splitlines() |
359 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 312 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
360 if not verbose: | 313 if not verbose: |
361 # Make the output a little prettier. It's nice to have some whitespace | 314 # Make the output a little prettier. It's nice to have some whitespace |
362 # between projects when cloning. | 315 # between projects when cloning. |
363 print('') | 316 print('') |
364 return self._Capture(['rev-parse', '--verify', 'HEAD']) | 317 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
365 | 318 |
| 319 if not managed: |
| 320 self._UpdateBranchHeads(options, fetch=False) |
| 321 self.UpdateSubmoduleConfig() |
| 322 print ('________ unmanaged solution; skipping %s' % self.relpath) |
| 323 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
| 324 |
| 325 if not os.path.exists(os.path.join(self.checkout_path, '.git')): |
| 326 raise gclient_utils.Error('\n____ %s%s\n' |
| 327 '\tPath is not a git repo. No .git dir.\n' |
| 328 '\tTo resolve:\n' |
| 329 '\t\trm -rf %s\n' |
| 330 '\tAnd run gclient sync again\n' |
| 331 % (self.relpath, rev_str, self.relpath)) |
| 332 |
| 333 # See if the url has changed (the unittests use git://foo for the url, let |
| 334 # that through). |
| 335 current_url = self._Capture(['config', 'remote.%s.url' % self.remote]) |
| 336 return_early = False |
| 337 # TODO(maruel): Delete url != 'git://foo' since it's just to make the |
| 338 # unit test pass. (and update the comment above) |
| 339 # Skip url auto-correction if remote.origin.gclient-auto-fix-url is set. |
| 340 # This allows devs to use experimental repos which have a different url |
| 341 # but whose branch(s) are the same as official repos. |
| 342 if (current_url != url and |
| 343 url != 'git://foo' and |
| 344 subprocess2.capture( |
| 345 ['git', 'config', 'remote.%s.gclient-auto-fix-url' % self.remote], |
| 346 cwd=self.checkout_path).strip() != 'False'): |
| 347 print('_____ switching %s to a new upstream' % self.relpath) |
| 348 # Make sure it's clean |
| 349 self._CheckClean(rev_str) |
| 350 # Switch over to the new upstream |
| 351 self._Run(['remote', 'set-url', self.remote, url], options) |
| 352 self._FetchAndReset(revision, file_list, options) |
| 353 return_early = True |
| 354 |
366 # Need to do this in the normal path as well as in the post-remote-switch | 355 # Need to do this in the normal path as well as in the post-remote-switch |
367 # path. | 356 # path. |
368 self._PossiblySwitchCache(url, options) | 357 self._PossiblySwitchCache(url, options) |
369 | 358 |
370 if return_early: | 359 if return_early: |
371 return self._Capture(['rev-parse', '--verify', 'HEAD']) | 360 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
372 | 361 |
373 cur_branch = self._GetCurrentBranch() | 362 cur_branch = self._GetCurrentBranch() |
374 | 363 |
375 # Cases: | 364 # Cases: |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 raise gclient_utils.Error( | 618 raise gclient_utils.Error( |
630 ( 'We could not find a valid hash for safesync_url response "%s".\n' | 619 ( 'We could not find a valid hash for safesync_url response "%s".\n' |
631 'Safesync URLs with a git checkout currently require the repo to\n' | 620 'Safesync URLs with a git checkout currently require the repo to\n' |
632 'be cloned without a safesync_url before adding the safesync_url.\n' | 621 'be cloned without a safesync_url before adding the safesync_url.\n' |
633 'For more info, see: ' | 622 'For more info, see: ' |
634 'http://code.google.com/p/chromium/wiki/UsingNewGit' | 623 'http://code.google.com/p/chromium/wiki/UsingNewGit' |
635 '#Initial_checkout' ) % rev) | 624 '#Initial_checkout' ) % rev) |
636 elif rev.isdigit() and len(rev) < 7: | 625 elif rev.isdigit() and len(rev) < 7: |
637 # Handles an SVN rev. As an optimization, only verify an SVN revision as | 626 # Handles an SVN rev. As an optimization, only verify an SVN revision as |
638 # [0-9]{1,6} for now to avoid making a network request. | 627 # [0-9]{1,6} for now to avoid making a network request. |
639 if scm.GIT.IsGitSvn(self.checkout_path): | 628 if scm.GIT.IsGitSvn(cwd=self.checkout_path): |
640 local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path) | 629 local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path) |
641 if not local_head or local_head < int(rev): | 630 if not local_head or local_head < int(rev): |
642 try: | 631 try: |
643 logging.debug('Looking for git-svn configuration optimizations.') | 632 logging.debug('Looking for git-svn configuration optimizations.') |
644 if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], | 633 if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], |
645 cwd=self.checkout_path): | 634 cwd=self.checkout_path): |
646 scm.GIT.Capture(['fetch'], cwd=self.checkout_path) | 635 scm.GIT.Capture(['fetch'], cwd=self.checkout_path) |
647 except subprocess2.CalledProcessError: | 636 except subprocess2.CalledProcessError: |
648 logging.debug('git config --get svn-remote.svn.fetch failed, ' | 637 logging.debug('git config --get svn-remote.svn.fetch failed, ' |
649 'ignoring possible optimization.') | 638 'ignoring possible optimization.') |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 filter_fn=SvnDiffFilterer(self.relpath).Filter) | 1097 filter_fn=SvnDiffFilterer(self.relpath).Filter) |
1109 | 1098 |
1110 def update(self, options, args, file_list): | 1099 def update(self, options, args, file_list): |
1111 """Runs svn to update or transparently checkout the working copy. | 1100 """Runs svn to update or transparently checkout the working copy. |
1112 | 1101 |
1113 All updated files will be appended to file_list. | 1102 All updated files will be appended to file_list. |
1114 | 1103 |
1115 Raises: | 1104 Raises: |
1116 Error: if can't get URL for relative path. | 1105 Error: if can't get URL for relative path. |
1117 """ | 1106 """ |
| 1107 # Only update if git or hg is not controlling the directory. |
| 1108 git_path = os.path.join(self.checkout_path, '.git') |
| 1109 if os.path.exists(git_path): |
| 1110 print('________ found .git directory; skipping %s' % self.relpath) |
| 1111 return |
| 1112 |
| 1113 hg_path = os.path.join(self.checkout_path, '.hg') |
| 1114 if os.path.exists(hg_path): |
| 1115 print('________ found .hg directory; skipping %s' % self.relpath) |
| 1116 return |
| 1117 |
1118 if args: | 1118 if args: |
1119 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) | 1119 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) |
1120 | 1120 |
1121 # revision is the revision to match. It is None if no revision is specified, | 1121 # revision is the revision to match. It is None if no revision is specified, |
1122 # i.e. the 'deps ain't pinned'. | 1122 # i.e. the 'deps ain't pinned'. |
1123 url, revision = gclient_utils.SplitUrlRevision(self.url) | 1123 url, revision = gclient_utils.SplitUrlRevision(self.url) |
1124 # Keep the original unpinned url for reference in case the repo is switched. | 1124 # Keep the original unpinned url for reference in case the repo is switched. |
1125 base_url = url | 1125 base_url = url |
1126 managed = True | 1126 managed = True |
1127 if options.revision: | 1127 if options.revision: |
1128 # Override the revision number. | 1128 # Override the revision number. |
1129 revision = str(options.revision) | 1129 revision = str(options.revision) |
1130 if revision: | 1130 if revision: |
1131 if revision != 'unmanaged': | 1131 if revision != 'unmanaged': |
1132 forced_revision = True | 1132 forced_revision = True |
1133 # Reconstruct the url. | 1133 # Reconstruct the url. |
1134 url = '%s@%s' % (url, revision) | 1134 url = '%s@%s' % (url, revision) |
1135 rev_str = ' at %s' % revision | 1135 rev_str = ' at %s' % revision |
1136 else: | 1136 else: |
1137 managed = False | 1137 managed = False |
1138 revision = None | 1138 revision = None |
1139 else: | 1139 else: |
1140 forced_revision = False | 1140 forced_revision = False |
1141 rev_str = '' | 1141 rev_str = '' |
1142 | 1142 |
1143 if not managed: | |
1144 print ('________ unmanaged solution; skipping %s' % self.relpath) | |
1145 return self.Svnversion() | |
1146 | |
1147 # Get the existing scm url and the revision number of the current checkout. | 1143 # Get the existing scm url and the revision number of the current checkout. |
1148 exists = os.path.exists(self.checkout_path) | 1144 exists = os.path.exists(self.checkout_path) |
1149 needs_delete = False | 1145 if exists and managed: |
1150 from_info = None | |
1151 | |
1152 if exists: | |
1153 # If there's a git-svn checkout, verify that the svn-remote is correct. | |
1154 if scm.GIT.IsGitSvn(self.checkout_path): | |
1155 remote_url = scm.GIT.Capture(['config', '--local', '--get', | |
1156 'svn-remote.svn.url'], | |
1157 cwd=self.checkout_path).rstrip() | |
1158 if remote_url != base_url: | |
1159 needs_delete = True | |
1160 else: | |
1161 print('\n_____ %s looks like a git-svn checkout. Skipping.' | |
1162 % self.relpath) | |
1163 return # TODO(borenet): Get the svn revision number? | |
1164 | |
1165 try: | 1146 try: |
1166 from_info = scm.SVN.CaptureLocalInfo( | 1147 from_info = scm.SVN.CaptureLocalInfo( |
1167 [], os.path.join(self.checkout_path, '.')) | 1148 [], os.path.join(self.checkout_path, '.')) |
1168 except (gclient_utils.Error, subprocess2.CalledProcessError): | 1149 except (gclient_utils.Error, subprocess2.CalledProcessError): |
1169 if gclient_utils.enable_deletion_of_conflicting_checkouts(): | 1150 if options.reset and options.delete_unversioned_trees: |
1170 needs_delete = True | 1151 print 'Removing troublesome path %s' % self.checkout_path |
1171 else: # TODO(borenet): Remove this once we can get rid of the guard. | 1152 gclient_utils.rmtree(self.checkout_path) |
1172 if options.reset and options.delete_unversioned_trees: | 1153 exists = False |
1173 print 'Removing troublesome path %s' % self.checkout_path | 1154 else: |
1174 gclient_utils.rmtree(self.checkout_path) | 1155 msg = ('Can\'t update/checkout %s if an unversioned directory is ' |
1175 exists = False | 1156 'present. Delete the directory and try again.') |
1176 else: | 1157 raise gclient_utils.Error(msg % self.checkout_path) |
1177 msg = ('Can\'t update/checkout %s if an unversioned directory is ' | |
1178 'present. Delete the directory and try again.') | |
1179 raise gclient_utils.Error(msg % self.checkout_path) | |
1180 | |
1181 # Switch the checkout if necessary. | |
1182 if not needs_delete and from_info and from_info['URL'] != base_url: | |
1183 # The repository url changed, need to switch. | |
1184 try: | |
1185 to_info = scm.SVN.CaptureRemoteInfo(url) | |
1186 except (gclient_utils.Error, subprocess2.CalledProcessError): | |
1187 # The url is invalid or the server is not accessible, it's safer to bail | |
1188 # out right now. | |
1189 raise gclient_utils.Error('This url is unreachable: %s' % url) | |
1190 can_switch = ((from_info['Repository Root'] != to_info['Repository Root']) | |
1191 and (from_info['UUID'] == to_info['UUID'])) | |
1192 if can_switch: | |
1193 print('\n_____ relocating %s to a new checkout' % self.relpath) | |
1194 # We have different roots, so check if we can switch --relocate. | |
1195 # Subversion only permits this if the repository UUIDs match. | |
1196 # Perform the switch --relocate, then rewrite the from_url | |
1197 # to reflect where we "are now." (This is the same way that | |
1198 # Subversion itself handles the metadata when switch --relocate | |
1199 # is used.) This makes the checks below for whether we | |
1200 # can update to a revision or have to switch to a different | |
1201 # branch work as expected. | |
1202 # TODO(maruel): TEST ME ! | |
1203 command = ['switch', '--relocate', | |
1204 from_info['Repository Root'], | |
1205 to_info['Repository Root'], | |
1206 self.relpath] | |
1207 self._Run(command, options, cwd=self._root_dir) | |
1208 from_info['URL'] = from_info['URL'].replace( | |
1209 from_info['Repository Root'], | |
1210 to_info['Repository Root']) | |
1211 else: | |
1212 needs_delete = True | |
1213 | |
1214 if (needs_delete and | |
1215 gclient_utils.enable_deletion_of_conflicting_checkouts()): | |
1216 if options.force: | |
1217 gclient_utils.rmtree(self.checkout_path) | |
1218 exists = False | |
1219 else: | |
1220 raise gclient_utils.Error('Conflicting directory found in %s. Please ' | |
1221 'delete it or run with --force.' | |
1222 % self.checkout_path) | |
1223 | 1158 |
1224 BASE_URLS = { | 1159 BASE_URLS = { |
1225 '/chrome/trunk/src': 'gs://chromium-svn-checkout/chrome/', | 1160 '/chrome/trunk/src': 'gs://chromium-svn-checkout/chrome/', |
1226 '/blink/trunk': 'gs://chromium-svn-checkout/blink/', | 1161 '/blink/trunk': 'gs://chromium-svn-checkout/blink/', |
1227 } | 1162 } |
1228 WHITELISTED_ROOTS = [ | 1163 WHITELISTED_ROOTS = [ |
1229 'svn://svn.chromium.org', | 1164 'svn://svn.chromium.org', |
1230 'svn://svn-mirror.golo.chromium.org', | 1165 'svn://svn-mirror.golo.chromium.org', |
1231 ] | 1166 ] |
1232 if not exists: | 1167 if not exists: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 print 'Resuming normal operations.' | 1225 print 'Resuming normal operations.' |
1291 print str(e) | 1226 print str(e) |
1292 | 1227 |
1293 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path)) | 1228 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path)) |
1294 # We need to checkout. | 1229 # We need to checkout. |
1295 command = ['checkout', url, self.checkout_path] | 1230 command = ['checkout', url, self.checkout_path] |
1296 command = self._AddAdditionalUpdateFlags(command, options, revision) | 1231 command = self._AddAdditionalUpdateFlags(command, options, revision) |
1297 self._RunAndGetFileList(command, options, file_list, self._root_dir) | 1232 self._RunAndGetFileList(command, options, file_list, self._root_dir) |
1298 return self.Svnversion() | 1233 return self.Svnversion() |
1299 | 1234 |
| 1235 if not managed: |
| 1236 print ('________ unmanaged solution; skipping %s' % self.relpath) |
| 1237 return self.Svnversion() |
| 1238 |
1300 if 'URL' not in from_info: | 1239 if 'URL' not in from_info: |
1301 raise gclient_utils.Error( | 1240 raise gclient_utils.Error( |
1302 ('gclient is confused. Couldn\'t get the url for %s.\n' | 1241 ('gclient is confused. Couldn\'t get the url for %s.\n' |
1303 'Try using @unmanaged.\n%s') % ( | 1242 'Try using @unmanaged.\n%s') % ( |
1304 self.checkout_path, from_info)) | 1243 self.checkout_path, from_info)) |
1305 | 1244 |
1306 # Look for locked directories. | 1245 # Look for locked directories. |
1307 dir_info = scm.SVN.CaptureStatus( | 1246 dir_info = scm.SVN.CaptureStatus( |
1308 None, os.path.join(self.checkout_path, '.')) | 1247 None, os.path.join(self.checkout_path, '.')) |
1309 if any(d[0][2] == 'L' for d in dir_info): | 1248 if any(d[0][2] == 'L' for d in dir_info): |
(...skipping 21 matching lines...) Expand all Loading... |
1331 if d[0][0] == '!': | 1270 if d[0][0] == '!': |
1332 print 'You can pass --force to enable automatic removal.' | 1271 print 'You can pass --force to enable automatic removal.' |
1333 raise e | 1272 raise e |
1334 | 1273 |
1335 # Retrieve the current HEAD version because svn is slow at null updates. | 1274 # Retrieve the current HEAD version because svn is slow at null updates. |
1336 if options.manually_grab_svn_rev and not revision: | 1275 if options.manually_grab_svn_rev and not revision: |
1337 from_info_live = scm.SVN.CaptureRemoteInfo(from_info['URL']) | 1276 from_info_live = scm.SVN.CaptureRemoteInfo(from_info['URL']) |
1338 revision = str(from_info_live['Revision']) | 1277 revision = str(from_info_live['Revision']) |
1339 rev_str = ' at %s' % revision | 1278 rev_str = ' at %s' % revision |
1340 | 1279 |
| 1280 if from_info['URL'] != base_url: |
| 1281 # The repository url changed, need to switch. |
| 1282 try: |
| 1283 to_info = scm.SVN.CaptureRemoteInfo(url) |
| 1284 except (gclient_utils.Error, subprocess2.CalledProcessError): |
| 1285 # The url is invalid or the server is not accessible, it's safer to bail |
| 1286 # out right now. |
| 1287 raise gclient_utils.Error('This url is unreachable: %s' % url) |
| 1288 can_switch = ((from_info['Repository Root'] != to_info['Repository Root']) |
| 1289 and (from_info['UUID'] == to_info['UUID'])) |
| 1290 if can_switch: |
| 1291 print('\n_____ relocating %s to a new checkout' % self.relpath) |
| 1292 # We have different roots, so check if we can switch --relocate. |
| 1293 # Subversion only permits this if the repository UUIDs match. |
| 1294 # Perform the switch --relocate, then rewrite the from_url |
| 1295 # to reflect where we "are now." (This is the same way that |
| 1296 # Subversion itself handles the metadata when switch --relocate |
| 1297 # is used.) This makes the checks below for whether we |
| 1298 # can update to a revision or have to switch to a different |
| 1299 # branch work as expected. |
| 1300 # TODO(maruel): TEST ME ! |
| 1301 command = ['switch', '--relocate', |
| 1302 from_info['Repository Root'], |
| 1303 to_info['Repository Root'], |
| 1304 self.relpath] |
| 1305 self._Run(command, options, cwd=self._root_dir) |
| 1306 from_info['URL'] = from_info['URL'].replace( |
| 1307 from_info['Repository Root'], |
| 1308 to_info['Repository Root']) |
| 1309 else: |
| 1310 if not options.force and not options.reset: |
| 1311 # Look for local modifications but ignore unversioned files. |
| 1312 for status in scm.SVN.CaptureStatus(None, self.checkout_path): |
| 1313 if status[0][0] != '?': |
| 1314 raise gclient_utils.Error( |
| 1315 ('Can\'t switch the checkout to %s; UUID don\'t match and ' |
| 1316 'there is local changes in %s. Delete the directory and ' |
| 1317 'try again.') % (url, self.checkout_path)) |
| 1318 # Ok delete it. |
| 1319 print('\n_____ switching %s to a new checkout' % self.relpath) |
| 1320 gclient_utils.rmtree(self.checkout_path) |
| 1321 # We need to checkout. |
| 1322 command = ['checkout', url, self.checkout_path] |
| 1323 command = self._AddAdditionalUpdateFlags(command, options, revision) |
| 1324 self._RunAndGetFileList(command, options, file_list, self._root_dir) |
| 1325 return self.Svnversion() |
| 1326 |
1341 # If the provided url has a revision number that matches the revision | 1327 # If the provided url has a revision number that matches the revision |
1342 # number of the existing directory, then we don't need to bother updating. | 1328 # number of the existing directory, then we don't need to bother updating. |
1343 if not options.force and str(from_info['Revision']) == revision: | 1329 if not options.force and str(from_info['Revision']) == revision: |
1344 if options.verbose or not forced_revision: | 1330 if options.verbose or not forced_revision: |
1345 print('\n_____ %s%s' % (self.relpath, rev_str)) | 1331 print('\n_____ %s%s' % (self.relpath, rev_str)) |
1346 else: | 1332 else: |
1347 command = ['update', self.checkout_path] | 1333 command = ['update', self.checkout_path] |
1348 command = self._AddAdditionalUpdateFlags(command, options, revision) | 1334 command = self._AddAdditionalUpdateFlags(command, options, revision) |
1349 self._RunAndGetFileList(command, options, file_list, self._root_dir) | 1335 self._RunAndGetFileList(command, options, file_list, self._root_dir) |
1350 | 1336 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 # svn revert won't work if the directory doesn't exist. It needs to | 1386 # svn revert won't work if the directory doesn't exist. It needs to |
1401 # checkout instead. | 1387 # checkout instead. |
1402 print('\n_____ %s is missing, synching instead' % self.relpath) | 1388 print('\n_____ %s is missing, synching instead' % self.relpath) |
1403 # Don't reuse the args. | 1389 # Don't reuse the args. |
1404 return self.update(options, [], file_list) | 1390 return self.update(options, [], file_list) |
1405 | 1391 |
1406 if not os.path.isdir(os.path.join(self.checkout_path, '.svn')): | 1392 if not os.path.isdir(os.path.join(self.checkout_path, '.svn')): |
1407 if os.path.isdir(os.path.join(self.checkout_path, '.git')): | 1393 if os.path.isdir(os.path.join(self.checkout_path, '.git')): |
1408 print('________ found .git directory; skipping %s' % self.relpath) | 1394 print('________ found .git directory; skipping %s' % self.relpath) |
1409 return | 1395 return |
| 1396 if os.path.isdir(os.path.join(self.checkout_path, '.hg')): |
| 1397 print('________ found .hg directory; skipping %s' % self.relpath) |
| 1398 return |
1410 if not options.force: | 1399 if not options.force: |
1411 raise gclient_utils.Error('Invalid checkout path, aborting') | 1400 raise gclient_utils.Error('Invalid checkout path, aborting') |
1412 print( | 1401 print( |
1413 '\n_____ %s is not a valid svn checkout, synching instead' % | 1402 '\n_____ %s is not a valid svn checkout, synching instead' % |
1414 self.relpath) | 1403 self.relpath) |
1415 gclient_utils.rmtree(self.checkout_path) | 1404 gclient_utils.rmtree(self.checkout_path) |
1416 # Don't reuse the args. | 1405 # Don't reuse the args. |
1417 return self.update(options, [], file_list) | 1406 return self.update(options, [], file_list) |
1418 | 1407 |
1419 def printcb(file_status): | 1408 def printcb(file_status): |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 new_command.append('--force') | 1506 new_command.append('--force') |
1518 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1507 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1519 new_command.extend(('--accept', 'theirs-conflict')) | 1508 new_command.extend(('--accept', 'theirs-conflict')) |
1520 elif options.manually_grab_svn_rev: | 1509 elif options.manually_grab_svn_rev: |
1521 new_command.append('--force') | 1510 new_command.append('--force') |
1522 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1511 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1523 new_command.extend(('--accept', 'postpone')) | 1512 new_command.extend(('--accept', 'postpone')) |
1524 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1513 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1525 new_command.extend(('--accept', 'postpone')) | 1514 new_command.extend(('--accept', 'postpone')) |
1526 return new_command | 1515 return new_command |
OLD | NEW |