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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 if revision.startswith('refs/'): | 333 if revision.startswith('refs/'): |
334 rev_type = "branch" | 334 rev_type = "branch" |
335 elif revision.startswith(self.remote + '/'): | 335 elif revision.startswith(self.remote + '/'): |
336 # For compatibility with old naming, translate 'origin' to 'refs/heads' | 336 # For compatibility with old naming, translate 'origin' to 'refs/heads' |
337 revision = revision.replace(self.remote + '/', 'refs/heads/') | 337 revision = revision.replace(self.remote + '/', 'refs/heads/') |
338 rev_type = "branch" | 338 rev_type = "branch" |
339 else: | 339 else: |
340 # hash is also a tag, only make a distinction at checkout | 340 # hash is also a tag, only make a distinction at checkout |
341 rev_type = "hash" | 341 rev_type = "hash" |
342 | 342 |
343 if (not os.path.exists(self.checkout_path) or | 343 if not managed: |
344 (os.path.isdir(self.checkout_path) and | 344 self._UpdateBranchHeads(options, fetch=False) |
345 not os.path.exists(os.path.join(self.checkout_path, '.git')))): | 345 self.UpdateSubmoduleConfig() |
346 print ('________ unmanaged solution; skipping %s' % self.relpath) | |
347 return self._Capture(['rev-parse', '--verify', 'HEAD']) | |
348 | |
349 needs_delete = False | |
350 exists = os.path.exists(self.checkout_path) | |
351 if exists and not os.path.exists(os.path.join(self.checkout_path, '.git')): | |
352 needs_delete = True | |
353 | |
354 # See if the url has changed (the unittests use git://foo for the url, let | |
355 # that through). | |
356 return_early = False | |
357 if exists and not needs_delete: | |
358 current_url = self._Capture(['config', 'remote.%s.url' % self.remote]) | |
359 # TODO(maruel): Delete url != 'git://foo' since it's just to make the | |
360 # unit test pass. (and update the comment above) | |
361 # Skip url auto-correction if remote.origin.gclient-auto-fix-url is set. | |
362 # This allows devs to use experimental repos which have a different url | |
363 # but whose branch(s) are the same as official repos. | |
364 if (current_url != url and url != 'git://foo'): | |
365 auto_fix = False | |
szager1
2014/02/26 21:34:07
Shouldn't this be:
auto_fix = 'true'
?
borenet
2014/02/26 21:52:18
I *think* the behavior we want is to delete the ch
szager1
2014/02/26 22:16:53
Ah, I see. I'm not trying to torture you with thi
borenet
2014/02/26 22:49:53
Got it. Changed to switch the checkout rather tha
| |
366 try: | |
367 auto_fix = self._Capture( | |
368 ['config', 'remote.%s.gclient-auto-fix-url' % self.remote], | |
369 cwd=self.checkout_path).strip() | |
370 except subprocess2.CalledProcessError: | |
371 needs_delete = True | |
372 if auto_fix in ('1', 'true', 'True', 'yes', 'Yes', 'y', 'Y'): | |
373 print('_____ switching %s to a new upstream' % self.relpath) | |
374 # Make sure it's clean | |
375 self._CheckClean(rev_str) | |
376 # Switch over to the new upstream | |
377 self._Run(['remote', 'set-url', self.remote, url], options) | |
378 self._FetchAndReset(revision, file_list, options) | |
379 return_early = True | |
380 | |
381 if (needs_delete and | |
382 gclient_utils.enable_deletion_of_conflicting_checkouts()): | |
383 if options.force: | |
384 print('Conflicting directory found in %s. Removing.' | |
385 % self.checkout_path) | |
386 gclient_utils.rmtree(self.checkout_path) | |
387 else: | |
388 raise gclient_utils.Error('Conflicting directory found in %s. Please ' | |
389 'delete it or run with --force.' | |
390 % self.checkout_path) | |
391 | |
392 if not os.path.exists(self.checkout_path): | |
346 self._Clone(revision, url, options) | 393 self._Clone(revision, url, options) |
347 self.UpdateSubmoduleConfig() | 394 self.UpdateSubmoduleConfig() |
348 if file_list is not None: | 395 if file_list is not None: |
349 files = self._Capture(['ls-files']).splitlines() | 396 files = self._Capture(['ls-files']).splitlines() |
350 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 397 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
351 if not verbose: | 398 if not verbose: |
352 # Make the output a little prettier. It's nice to have some whitespace | 399 # Make the output a little prettier. It's nice to have some whitespace |
353 # between projects when cloning. | 400 # between projects when cloning. |
354 print('') | 401 print('') |
355 return self._Capture(['rev-parse', '--verify', 'HEAD']) | 402 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
356 | 403 |
357 if not managed: | |
358 self._UpdateBranchHeads(options, fetch=False) | |
359 self.UpdateSubmoduleConfig() | |
360 print ('________ unmanaged solution; skipping %s' % self.relpath) | |
361 return self._Capture(['rev-parse', '--verify', 'HEAD']) | |
362 | |
363 if not os.path.exists(os.path.join(self.checkout_path, '.git')): | |
364 raise gclient_utils.Error('\n____ %s%s\n' | |
365 '\tPath is not a git repo. No .git dir.\n' | |
366 '\tTo resolve:\n' | |
367 '\t\trm -rf %s\n' | |
368 '\tAnd run gclient sync again\n' | |
369 % (self.relpath, rev_str, self.relpath)) | |
370 | |
371 # See if the url has changed (the unittests use git://foo for the url, let | |
372 # that through). | |
373 current_url = self._Capture(['config', 'remote.%s.url' % self.remote]) | |
374 return_early = False | |
375 # TODO(maruel): Delete url != 'git://foo' since it's just to make the | |
376 # unit test pass. (and update the comment above) | |
377 # Skip url auto-correction if remote.origin.gclient-auto-fix-url is set. | |
378 # This allows devs to use experimental repos which have a different url | |
379 # but whose branch(s) are the same as official repos. | |
380 if (current_url != url and | |
381 url != 'git://foo' and | |
382 subprocess2.capture( | |
383 ['git', 'config', 'remote.%s.gclient-auto-fix-url' % self.remote], | |
384 cwd=self.checkout_path).strip() != 'False'): | |
385 print('_____ switching %s to a new upstream' % self.relpath) | |
386 # Make sure it's clean | |
387 self._CheckClean(rev_str) | |
388 # Switch over to the new upstream | |
389 self._Run(['remote', 'set-url', self.remote, url], options) | |
390 self._FetchAndReset(revision, file_list, options) | |
391 return_early = True | |
392 | |
393 # Need to do this in the normal path as well as in the post-remote-switch | 404 # Need to do this in the normal path as well as in the post-remote-switch |
394 # path. | 405 # path. |
395 self._PossiblySwitchCache(url, options) | 406 self._PossiblySwitchCache(url, options) |
396 | 407 |
397 if return_early: | 408 if return_early: |
398 return self._Capture(['rev-parse', '--verify', 'HEAD']) | 409 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
399 | 410 |
400 cur_branch = self._GetCurrentBranch() | 411 cur_branch = self._GetCurrentBranch() |
401 | 412 |
402 # Cases: | 413 # Cases: |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
656 raise gclient_utils.Error( | 667 raise gclient_utils.Error( |
657 ( 'We could not find a valid hash for safesync_url response "%s".\n' | 668 ( 'We could not find a valid hash for safesync_url response "%s".\n' |
658 'Safesync URLs with a git checkout currently require the repo to\n' | 669 'Safesync URLs with a git checkout currently require the repo to\n' |
659 'be cloned without a safesync_url before adding the safesync_url.\n' | 670 'be cloned without a safesync_url before adding the safesync_url.\n' |
660 'For more info, see: ' | 671 'For more info, see: ' |
661 'http://code.google.com/p/chromium/wiki/UsingNewGit' | 672 'http://code.google.com/p/chromium/wiki/UsingNewGit' |
662 '#Initial_checkout' ) % rev) | 673 '#Initial_checkout' ) % rev) |
663 elif rev.isdigit() and len(rev) < 7: | 674 elif rev.isdigit() and len(rev) < 7: |
664 # Handles an SVN rev. As an optimization, only verify an SVN revision as | 675 # Handles an SVN rev. As an optimization, only verify an SVN revision as |
665 # [0-9]{1,6} for now to avoid making a network request. | 676 # [0-9]{1,6} for now to avoid making a network request. |
666 if scm.GIT.IsGitSvn(cwd=self.checkout_path): | 677 if scm.GIT.IsGitSvn(self.checkout_path): |
667 local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path) | 678 local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path) |
668 if not local_head or local_head < int(rev): | 679 if not local_head or local_head < int(rev): |
669 try: | 680 try: |
670 logging.debug('Looking for git-svn configuration optimizations.') | 681 logging.debug('Looking for git-svn configuration optimizations.') |
671 if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], | 682 if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], |
672 cwd=self.checkout_path): | 683 cwd=self.checkout_path): |
673 scm.GIT.Capture(['fetch'], cwd=self.checkout_path) | 684 scm.GIT.Capture(['fetch'], cwd=self.checkout_path) |
674 except subprocess2.CalledProcessError: | 685 except subprocess2.CalledProcessError: |
675 logging.debug('git config --get svn-remote.svn.fetch failed, ' | 686 logging.debug('git config --get svn-remote.svn.fetch failed, ' |
676 'ignoring possible optimization.') | 687 'ignoring possible optimization.') |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1135 filter_fn=SvnDiffFilterer(self.relpath).Filter) | 1146 filter_fn=SvnDiffFilterer(self.relpath).Filter) |
1136 | 1147 |
1137 def update(self, options, args, file_list): | 1148 def update(self, options, args, file_list): |
1138 """Runs svn to update or transparently checkout the working copy. | 1149 """Runs svn to update or transparently checkout the working copy. |
1139 | 1150 |
1140 All updated files will be appended to file_list. | 1151 All updated files will be appended to file_list. |
1141 | 1152 |
1142 Raises: | 1153 Raises: |
1143 Error: if can't get URL for relative path. | 1154 Error: if can't get URL for relative path. |
1144 """ | 1155 """ |
1145 # Only update if git or hg is not controlling the directory. | |
1146 git_path = os.path.join(self.checkout_path, '.git') | |
1147 if os.path.exists(git_path): | |
1148 print('________ found .git directory; skipping %s' % self.relpath) | |
1149 return | |
1150 | |
1151 hg_path = os.path.join(self.checkout_path, '.hg') | |
1152 if os.path.exists(hg_path): | |
1153 print('________ found .hg directory; skipping %s' % self.relpath) | |
1154 return | |
1155 | |
1156 if args: | 1156 if args: |
1157 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) | 1157 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) |
1158 | 1158 |
1159 # revision is the revision to match. It is None if no revision is specified, | 1159 # revision is the revision to match. It is None if no revision is specified, |
1160 # i.e. the 'deps ain't pinned'. | 1160 # i.e. the 'deps ain't pinned'. |
1161 url, revision = gclient_utils.SplitUrlRevision(self.url) | 1161 url, revision = gclient_utils.SplitUrlRevision(self.url) |
1162 # Keep the original unpinned url for reference in case the repo is switched. | 1162 # Keep the original unpinned url for reference in case the repo is switched. |
1163 base_url = url | 1163 base_url = url |
1164 managed = True | 1164 managed = True |
1165 if options.revision: | 1165 if options.revision: |
1166 # Override the revision number. | 1166 # Override the revision number. |
1167 revision = str(options.revision) | 1167 revision = str(options.revision) |
1168 if revision: | 1168 if revision: |
1169 if revision != 'unmanaged': | 1169 if revision != 'unmanaged': |
1170 forced_revision = True | 1170 forced_revision = True |
1171 # Reconstruct the url. | 1171 # Reconstruct the url. |
1172 url = '%s@%s' % (url, revision) | 1172 url = '%s@%s' % (url, revision) |
1173 rev_str = ' at %s' % revision | 1173 rev_str = ' at %s' % revision |
1174 else: | 1174 else: |
1175 managed = False | 1175 managed = False |
1176 revision = None | 1176 revision = None |
1177 else: | 1177 else: |
1178 forced_revision = False | 1178 forced_revision = False |
1179 rev_str = '' | 1179 rev_str = '' |
1180 | 1180 |
1181 if not managed: | |
1182 print ('________ unmanaged solution; skipping %s' % self.relpath) | |
1183 return self.Svnversion() | |
1184 | |
1181 # Get the existing scm url and the revision number of the current checkout. | 1185 # Get the existing scm url and the revision number of the current checkout. |
1182 exists = os.path.exists(self.checkout_path) | 1186 exists = os.path.exists(self.checkout_path) |
1183 if exists and managed: | 1187 needs_delete = False |
1188 from_info = None | |
1189 | |
1190 if exists: | |
1191 # If there's a git-svn checkout, verify that the svn-remote is correct. | |
1192 if scm.GIT.IsGitSvn(self.checkout_path): | |
1193 remote_url = scm.GIT.Capture(['config', '--local', '--get', | |
1194 'svn-remote.svn.url'], | |
1195 cwd=self.checkout_path).rstrip() | |
1196 if remote_url != base_url: | |
1197 needs_delete = True | |
1198 else: | |
1199 print('\n_____ %s looks like a git-svn checkout. Skipping.' | |
1200 % self.relpath) | |
1201 return # TODO(borenet): Get the svn revision number? | |
1202 | |
1184 try: | 1203 try: |
1185 from_info = scm.SVN.CaptureLocalInfo( | 1204 from_info = scm.SVN.CaptureLocalInfo( |
1186 [], os.path.join(self.checkout_path, '.')) | 1205 [], os.path.join(self.checkout_path, '.')) |
1187 except (gclient_utils.Error, subprocess2.CalledProcessError): | 1206 except (gclient_utils.Error, subprocess2.CalledProcessError): |
1188 if options.reset and options.delete_unversioned_trees: | 1207 if gclient_utils.enable_deletion_of_conflicting_checkouts(): |
1189 print 'Removing troublesome path %s' % self.checkout_path | 1208 needs_delete = True |
1190 gclient_utils.rmtree(self.checkout_path) | 1209 else: # TODO(borenet): Remove this once we can get rid of the guard. |
1191 exists = False | 1210 if options.reset and options.delete_unversioned_trees: |
1192 else: | 1211 print 'Removing troublesome path %s' % self.checkout_path |
1193 msg = ('Can\'t update/checkout %s if an unversioned directory is ' | 1212 gclient_utils.rmtree(self.checkout_path) |
1194 'present. Delete the directory and try again.') | 1213 exists = False |
1195 raise gclient_utils.Error(msg % self.checkout_path) | 1214 else: |
1215 msg = ('Can\'t update/checkout %s if an unversioned directory is ' | |
1216 'present. Delete the directory and try again.') | |
1217 raise gclient_utils.Error(msg % self.checkout_path) | |
1218 | |
1219 # Switch the checkout if necessary. | |
1220 if not needs_delete and from_info and from_info['URL'] != base_url: | |
1221 # The repository url changed, need to switch. | |
1222 try: | |
1223 to_info = scm.SVN.CaptureRemoteInfo(url) | |
1224 except (gclient_utils.Error, subprocess2.CalledProcessError): | |
1225 # The url is invalid or the server is not accessible, it's safer to bail | |
1226 # out right now. | |
1227 raise gclient_utils.Error('This url is unreachable: %s' % url) | |
1228 can_switch = ((from_info['Repository Root'] != to_info['Repository Root']) | |
1229 and (from_info['UUID'] == to_info['UUID'])) | |
1230 if can_switch: | |
1231 print('\n_____ relocating %s to a new checkout' % self.relpath) | |
1232 # We have different roots, so check if we can switch --relocate. | |
1233 # Subversion only permits this if the repository UUIDs match. | |
1234 # Perform the switch --relocate, then rewrite the from_url | |
1235 # to reflect where we "are now." (This is the same way that | |
1236 # Subversion itself handles the metadata when switch --relocate | |
1237 # is used.) This makes the checks below for whether we | |
1238 # can update to a revision or have to switch to a different | |
1239 # branch work as expected. | |
1240 # TODO(maruel): TEST ME ! | |
1241 command = ['switch', '--relocate', | |
1242 from_info['Repository Root'], | |
1243 to_info['Repository Root'], | |
1244 self.relpath] | |
1245 self._Run(command, options, cwd=self._root_dir) | |
1246 from_info['URL'] = from_info['URL'].replace( | |
1247 from_info['Repository Root'], | |
1248 to_info['Repository Root']) | |
1249 else: | |
1250 needs_delete = True | |
1251 | |
1252 if (needs_delete and | |
1253 gclient_utils.enable_deletion_of_conflicting_checkouts()): | |
1254 if options.force: | |
1255 gclient_utils.rmtree(self.checkout_path) | |
1256 exists = False | |
1257 else: | |
1258 raise gclient_utils.Error('Conflicting directory found in %s. Please ' | |
1259 'delete it or run with --force.' | |
1260 % self.checkout_path) | |
1196 | 1261 |
1197 BASE_URLS = { | 1262 BASE_URLS = { |
1198 '/chrome/trunk/src': 'gs://chromium-svn-checkout/chrome/', | 1263 '/chrome/trunk/src': 'gs://chromium-svn-checkout/chrome/', |
1199 '/blink/trunk': 'gs://chromium-svn-checkout/blink/', | 1264 '/blink/trunk': 'gs://chromium-svn-checkout/blink/', |
1200 } | 1265 } |
1201 WHITELISTED_ROOTS = [ | 1266 WHITELISTED_ROOTS = [ |
1202 'svn://svn.chromium.org', | 1267 'svn://svn.chromium.org', |
1203 'svn://svn-mirror.golo.chromium.org', | 1268 'svn://svn-mirror.golo.chromium.org', |
1204 ] | 1269 ] |
1205 if not exists: | 1270 if not exists: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1263 print 'Resuming normal operations.' | 1328 print 'Resuming normal operations.' |
1264 print str(e) | 1329 print str(e) |
1265 | 1330 |
1266 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path)) | 1331 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path)) |
1267 # We need to checkout. | 1332 # We need to checkout. |
1268 command = ['checkout', url, self.checkout_path] | 1333 command = ['checkout', url, self.checkout_path] |
1269 command = self._AddAdditionalUpdateFlags(command, options, revision) | 1334 command = self._AddAdditionalUpdateFlags(command, options, revision) |
1270 self._RunAndGetFileList(command, options, file_list, self._root_dir) | 1335 self._RunAndGetFileList(command, options, file_list, self._root_dir) |
1271 return self.Svnversion() | 1336 return self.Svnversion() |
1272 | 1337 |
1273 if not managed: | |
1274 print ('________ unmanaged solution; skipping %s' % self.relpath) | |
1275 return self.Svnversion() | |
1276 | |
1277 if 'URL' not in from_info: | 1338 if 'URL' not in from_info: |
1278 raise gclient_utils.Error( | 1339 raise gclient_utils.Error( |
1279 ('gclient is confused. Couldn\'t get the url for %s.\n' | 1340 ('gclient is confused. Couldn\'t get the url for %s.\n' |
1280 'Try using @unmanaged.\n%s') % ( | 1341 'Try using @unmanaged.\n%s') % ( |
1281 self.checkout_path, from_info)) | 1342 self.checkout_path, from_info)) |
1282 | 1343 |
1283 # Look for locked directories. | 1344 # Look for locked directories. |
1284 dir_info = scm.SVN.CaptureStatus( | 1345 dir_info = scm.SVN.CaptureStatus( |
1285 None, os.path.join(self.checkout_path, '.')) | 1346 None, os.path.join(self.checkout_path, '.')) |
1286 if any(d[0][2] == 'L' for d in dir_info): | 1347 if any(d[0][2] == 'L' for d in dir_info): |
(...skipping 21 matching lines...) Expand all Loading... | |
1308 if d[0][0] == '!': | 1369 if d[0][0] == '!': |
1309 print 'You can pass --force to enable automatic removal.' | 1370 print 'You can pass --force to enable automatic removal.' |
1310 raise e | 1371 raise e |
1311 | 1372 |
1312 # Retrieve the current HEAD version because svn is slow at null updates. | 1373 # Retrieve the current HEAD version because svn is slow at null updates. |
1313 if options.manually_grab_svn_rev and not revision: | 1374 if options.manually_grab_svn_rev and not revision: |
1314 from_info_live = scm.SVN.CaptureRemoteInfo(from_info['URL']) | 1375 from_info_live = scm.SVN.CaptureRemoteInfo(from_info['URL']) |
1315 revision = str(from_info_live['Revision']) | 1376 revision = str(from_info_live['Revision']) |
1316 rev_str = ' at %s' % revision | 1377 rev_str = ' at %s' % revision |
1317 | 1378 |
1318 if from_info['URL'] != base_url: | |
1319 # The repository url changed, need to switch. | |
1320 try: | |
1321 to_info = scm.SVN.CaptureRemoteInfo(url) | |
1322 except (gclient_utils.Error, subprocess2.CalledProcessError): | |
1323 # The url is invalid or the server is not accessible, it's safer to bail | |
1324 # out right now. | |
1325 raise gclient_utils.Error('This url is unreachable: %s' % url) | |
1326 can_switch = ((from_info['Repository Root'] != to_info['Repository Root']) | |
1327 and (from_info['UUID'] == to_info['UUID'])) | |
1328 if can_switch: | |
1329 print('\n_____ relocating %s to a new checkout' % self.relpath) | |
1330 # We have different roots, so check if we can switch --relocate. | |
1331 # Subversion only permits this if the repository UUIDs match. | |
1332 # Perform the switch --relocate, then rewrite the from_url | |
1333 # to reflect where we "are now." (This is the same way that | |
1334 # Subversion itself handles the metadata when switch --relocate | |
1335 # is used.) This makes the checks below for whether we | |
1336 # can update to a revision or have to switch to a different | |
1337 # branch work as expected. | |
1338 # TODO(maruel): TEST ME ! | |
1339 command = ['switch', '--relocate', | |
1340 from_info['Repository Root'], | |
1341 to_info['Repository Root'], | |
1342 self.relpath] | |
1343 self._Run(command, options, cwd=self._root_dir) | |
1344 from_info['URL'] = from_info['URL'].replace( | |
1345 from_info['Repository Root'], | |
1346 to_info['Repository Root']) | |
1347 else: | |
1348 if not options.force and not options.reset: | |
1349 # Look for local modifications but ignore unversioned files. | |
1350 for status in scm.SVN.CaptureStatus(None, self.checkout_path): | |
1351 if status[0][0] != '?': | |
1352 raise gclient_utils.Error( | |
1353 ('Can\'t switch the checkout to %s; UUID don\'t match and ' | |
1354 'there is local changes in %s. Delete the directory and ' | |
1355 'try again.') % (url, self.checkout_path)) | |
1356 # Ok delete it. | |
1357 print('\n_____ switching %s to a new checkout' % self.relpath) | |
1358 gclient_utils.rmtree(self.checkout_path) | |
1359 # We need to checkout. | |
1360 command = ['checkout', url, self.checkout_path] | |
1361 command = self._AddAdditionalUpdateFlags(command, options, revision) | |
1362 self._RunAndGetFileList(command, options, file_list, self._root_dir) | |
1363 return self.Svnversion() | |
1364 | |
1365 # If the provided url has a revision number that matches the revision | 1379 # If the provided url has a revision number that matches the revision |
1366 # number of the existing directory, then we don't need to bother updating. | 1380 # number of the existing directory, then we don't need to bother updating. |
1367 if not options.force and str(from_info['Revision']) == revision: | 1381 if not options.force and str(from_info['Revision']) == revision: |
1368 if options.verbose or not forced_revision: | 1382 if options.verbose or not forced_revision: |
1369 print('\n_____ %s%s' % (self.relpath, rev_str)) | 1383 print('\n_____ %s%s' % (self.relpath, rev_str)) |
1370 else: | 1384 else: |
1371 command = ['update', self.checkout_path] | 1385 command = ['update', self.checkout_path] |
1372 command = self._AddAdditionalUpdateFlags(command, options, revision) | 1386 command = self._AddAdditionalUpdateFlags(command, options, revision) |
1373 self._RunAndGetFileList(command, options, file_list, self._root_dir) | 1387 self._RunAndGetFileList(command, options, file_list, self._root_dir) |
1374 | 1388 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1424 # svn revert won't work if the directory doesn't exist. It needs to | 1438 # svn revert won't work if the directory doesn't exist. It needs to |
1425 # checkout instead. | 1439 # checkout instead. |
1426 print('\n_____ %s is missing, synching instead' % self.relpath) | 1440 print('\n_____ %s is missing, synching instead' % self.relpath) |
1427 # Don't reuse the args. | 1441 # Don't reuse the args. |
1428 return self.update(options, [], file_list) | 1442 return self.update(options, [], file_list) |
1429 | 1443 |
1430 if not os.path.isdir(os.path.join(self.checkout_path, '.svn')): | 1444 if not os.path.isdir(os.path.join(self.checkout_path, '.svn')): |
1431 if os.path.isdir(os.path.join(self.checkout_path, '.git')): | 1445 if os.path.isdir(os.path.join(self.checkout_path, '.git')): |
1432 print('________ found .git directory; skipping %s' % self.relpath) | 1446 print('________ found .git directory; skipping %s' % self.relpath) |
1433 return | 1447 return |
1434 if os.path.isdir(os.path.join(self.checkout_path, '.hg')): | |
1435 print('________ found .hg directory; skipping %s' % self.relpath) | |
1436 return | |
1437 if not options.force: | 1448 if not options.force: |
1438 raise gclient_utils.Error('Invalid checkout path, aborting') | 1449 raise gclient_utils.Error('Invalid checkout path, aborting') |
1439 print( | 1450 print( |
1440 '\n_____ %s is not a valid svn checkout, synching instead' % | 1451 '\n_____ %s is not a valid svn checkout, synching instead' % |
1441 self.relpath) | 1452 self.relpath) |
1442 gclient_utils.rmtree(self.checkout_path) | 1453 gclient_utils.rmtree(self.checkout_path) |
1443 # Don't reuse the args. | 1454 # Don't reuse the args. |
1444 return self.update(options, [], file_list) | 1455 return self.update(options, [], file_list) |
1445 | 1456 |
1446 def printcb(file_status): | 1457 def printcb(file_status): |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1544 new_command.append('--force') | 1555 new_command.append('--force') |
1545 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1556 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1546 new_command.extend(('--accept', 'theirs-conflict')) | 1557 new_command.extend(('--accept', 'theirs-conflict')) |
1547 elif options.manually_grab_svn_rev: | 1558 elif options.manually_grab_svn_rev: |
1548 new_command.append('--force') | 1559 new_command.append('--force') |
1549 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1560 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1550 new_command.extend(('--accept', 'postpone')) | 1561 new_command.extend(('--accept', 'postpone')) |
1551 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1562 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1552 new_command.extend(('--accept', 'postpone')) | 1563 new_command.extend(('--accept', 'postpone')) |
1553 return new_command | 1564 return new_command |
OLD | NEW |