OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
borenet
2014/02/18 21:56:58
I moved around some logic. I think it shouldn't h
| |
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 |
(...skipping 321 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 managed: | |
344 self._UpdateBranchHeads(options, fetch=False) | |
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 | |
365 url != 'git://foo'): | |
366 if subprocess2.capture( | |
367 ['git', 'config', 'remote.%s.gclient-auto-fix-url' % self.remote], | |
368 cwd=self.checkout_path).strip() != 'False': | |
369 print('_____ switching %s to a new upstream' % self.relpath) | |
370 # Make sure it's clean | |
371 self._CheckClean(rev_str) | |
372 # Switch over to the new upstream | |
373 self._Run(['remote', 'set-url', self.remote, url], options) | |
374 self._FetchAndReset(revision, file_list, options) | |
375 return_early = True | |
376 else: | |
377 needs_delete = True | |
378 | |
379 if needs_delete: | |
380 if options.force: | |
381 print('Conflicting directory found in %s. Removing.' | |
382 % self.checkout_path) | |
383 gclient_utils.rmtree(self.checkout_path) | |
384 else: | |
385 raise gclient_utils.Error('Conflicting directory found in %s. Please ' | |
386 'delete it or run with --force.' | |
387 % self.checkout_path) | |
388 | |
343 if (not os.path.exists(self.checkout_path) or | 389 if (not os.path.exists(self.checkout_path) or |
344 (os.path.isdir(self.checkout_path) and | 390 (os.path.isdir(self.checkout_path) and |
345 not os.path.exists(os.path.join(self.checkout_path, '.git')))): | 391 not os.path.exists(os.path.join(self.checkout_path, '.git')))): |
iannucci
2014/02/21 02:17:00
I think this logic is more complex than it needs t
borenet
2014/02/21 13:38:17
Changed to just "os.path.exists". This is more st
| |
346 self._Clone(revision, url, options) | 392 self._Clone(revision, url, options) |
347 self.UpdateSubmoduleConfig() | 393 self.UpdateSubmoduleConfig() |
348 if file_list is not None: | 394 if file_list is not None: |
349 files = self._Capture(['ls-files']).splitlines() | 395 files = self._Capture(['ls-files']).splitlines() |
350 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 396 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
351 if not verbose: | 397 if not verbose: |
352 # Make the output a little prettier. It's nice to have some whitespace | 398 # Make the output a little prettier. It's nice to have some whitespace |
353 # between projects when cloning. | 399 # between projects when cloning. |
354 print('') | 400 print('') |
355 return self._Capture(['rev-parse', '--verify', 'HEAD']) | 401 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
356 | 402 |
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 | 403 # Need to do this in the normal path as well as in the post-remote-switch |
394 # path. | 404 # path. |
395 self._PossiblySwitchCache(url, options) | 405 self._PossiblySwitchCache(url, options) |
396 | 406 |
397 if return_early: | 407 if return_early: |
398 return self._Capture(['rev-parse', '--verify', 'HEAD']) | 408 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
399 | 409 |
400 cur_branch = self._GetCurrentBranch() | 410 cur_branch = self._GetCurrentBranch() |
401 | 411 |
402 # Cases: | 412 # Cases: |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 raise gclient_utils.Error( | 665 raise gclient_utils.Error( |
656 ( 'We could not find a valid hash for safesync_url response "%s".\n' | 666 ( 'We could not find a valid hash for safesync_url response "%s".\n' |
657 'Safesync URLs with a git checkout currently require the repo to\n' | 667 'Safesync URLs with a git checkout currently require the repo to\n' |
658 'be cloned without a safesync_url before adding the safesync_url.\n' | 668 'be cloned without a safesync_url before adding the safesync_url.\n' |
659 'For more info, see: ' | 669 'For more info, see: ' |
660 'http://code.google.com/p/chromium/wiki/UsingNewGit' | 670 'http://code.google.com/p/chromium/wiki/UsingNewGit' |
661 '#Initial_checkout' ) % rev) | 671 '#Initial_checkout' ) % rev) |
662 elif rev.isdigit() and len(rev) < 7: | 672 elif rev.isdigit() and len(rev) < 7: |
663 # Handles an SVN rev. As an optimization, only verify an SVN revision as | 673 # Handles an SVN rev. As an optimization, only verify an SVN revision as |
664 # [0-9]{1,6} for now to avoid making a network request. | 674 # [0-9]{1,6} for now to avoid making a network request. |
665 if scm.GIT.IsGitSvn(cwd=self.checkout_path): | 675 if scm.GIT.IsGitSvn(self.checkout_path): |
666 local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path) | 676 local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path) |
667 if not local_head or local_head < int(rev): | 677 if not local_head or local_head < int(rev): |
668 try: | 678 try: |
669 logging.debug('Looking for git-svn configuration optimizations.') | 679 logging.debug('Looking for git-svn configuration optimizations.') |
670 if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], | 680 if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], |
671 cwd=self.checkout_path): | 681 cwd=self.checkout_path): |
672 scm.GIT.Capture(['fetch'], cwd=self.checkout_path) | 682 scm.GIT.Capture(['fetch'], cwd=self.checkout_path) |
673 except subprocess2.CalledProcessError: | 683 except subprocess2.CalledProcessError: |
674 logging.debug('git config --get svn-remote.svn.fetch failed, ' | 684 logging.debug('git config --get svn-remote.svn.fetch failed, ' |
675 'ignoring possible optimization.') | 685 'ignoring possible optimization.') |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1134 filter_fn=SvnDiffFilterer(self.relpath).Filter) | 1144 filter_fn=SvnDiffFilterer(self.relpath).Filter) |
1135 | 1145 |
1136 def update(self, options, args, file_list): | 1146 def update(self, options, args, file_list): |
1137 """Runs svn to update or transparently checkout the working copy. | 1147 """Runs svn to update or transparently checkout the working copy. |
1138 | 1148 |
1139 All updated files will be appended to file_list. | 1149 All updated files will be appended to file_list. |
1140 | 1150 |
1141 Raises: | 1151 Raises: |
1142 Error: if can't get URL for relative path. | 1152 Error: if can't get URL for relative path. |
1143 """ | 1153 """ |
1144 # Only update if git or hg is not controlling the directory. | |
1145 git_path = os.path.join(self.checkout_path, '.git') | |
1146 if os.path.exists(git_path): | |
1147 print('________ found .git directory; skipping %s' % self.relpath) | |
1148 return | |
1149 | |
1150 hg_path = os.path.join(self.checkout_path, '.hg') | |
1151 if os.path.exists(hg_path): | |
1152 print('________ found .hg directory; skipping %s' % self.relpath) | |
1153 return | |
borenet
2014/02/18 21:56:58
I removed this check altogether. Seems like we'd j
| |
1154 | |
1155 if args: | 1154 if args: |
1156 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) | 1155 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) |
1157 | 1156 |
1158 # revision is the revision to match. It is None if no revision is specified, | 1157 # revision is the revision to match. It is None if no revision is specified, |
1159 # i.e. the 'deps ain't pinned'. | 1158 # i.e. the 'deps ain't pinned'. |
1160 url, revision = gclient_utils.SplitUrlRevision(self.url) | 1159 url, revision = gclient_utils.SplitUrlRevision(self.url) |
1161 # Keep the original unpinned url for reference in case the repo is switched. | 1160 # Keep the original unpinned url for reference in case the repo is switched. |
1162 base_url = url | 1161 base_url = url |
1163 managed = True | 1162 managed = True |
1164 if options.revision: | 1163 if options.revision: |
1165 # Override the revision number. | 1164 # Override the revision number. |
1166 revision = str(options.revision) | 1165 revision = str(options.revision) |
1167 if revision: | 1166 if revision: |
1168 if revision != 'unmanaged': | 1167 if revision != 'unmanaged': |
1169 forced_revision = True | 1168 forced_revision = True |
1170 # Reconstruct the url. | 1169 # Reconstruct the url. |
1171 url = '%s@%s' % (url, revision) | 1170 url = '%s@%s' % (url, revision) |
1172 rev_str = ' at %s' % revision | 1171 rev_str = ' at %s' % revision |
1173 else: | 1172 else: |
1174 managed = False | 1173 managed = False |
1175 revision = None | 1174 revision = None |
1176 else: | 1175 else: |
1177 forced_revision = False | 1176 forced_revision = False |
1178 rev_str = '' | 1177 rev_str = '' |
1179 | 1178 |
1179 if not managed: | |
1180 print ('________ unmanaged solution; skipping %s' % self.relpath) | |
1181 return self.Svnversion() | |
1182 | |
1180 # Get the existing scm url and the revision number of the current checkout. | 1183 # Get the existing scm url and the revision number of the current checkout. |
1181 exists = os.path.exists(self.checkout_path) | 1184 exists = os.path.exists(self.checkout_path) |
1182 if exists and managed: | 1185 needs_delete = False |
1186 from_info = None | |
1187 | |
1188 if exists: | |
1189 # If there's a git-svn checkout, verify that the svn-remote is correct. | |
1190 if scm.GIT.IsGitSvn(self.checkout_path): | |
1191 remote_url = scm.GIT.Capture(['config', '--local', '--get', | |
1192 'svn-remote.svn.url'], | |
1193 cwd=self.checkout_path).rstrip() | |
1194 if remote_url != base_url: | |
1195 needs_delete = True | |
1196 else: | |
1197 print('\n_____ %s looks like a git-svn checkout. Skipping.' | |
1198 % self.relpath) | |
1199 return # TODO(borenet): Get the svn revision number? | |
iannucci
2014/02/21 02:17:00
This is weird... I don't understand why this claus
borenet
2014/02/21 13:38:17
One of my previous submissions broke a project who
iannucci
2014/02/24 21:18:19
:( That is so sad in so many ways :(
| |
1200 | |
1183 try: | 1201 try: |
1184 from_info = scm.SVN.CaptureLocalInfo( | 1202 from_info = scm.SVN.CaptureLocalInfo( |
1185 [], os.path.join(self.checkout_path, '.')) | 1203 [], os.path.join(self.checkout_path, '.')) |
1186 except (gclient_utils.Error, subprocess2.CalledProcessError): | 1204 except (gclient_utils.Error, subprocess2.CalledProcessError): |
1187 if options.reset and options.delete_unversioned_trees: | 1205 needs_delete = True |
1188 print 'Removing troublesome path %s' % self.checkout_path | 1206 |
1189 gclient_utils.rmtree(self.checkout_path) | 1207 # Switch the checkout if necessary. |
1190 exists = False | 1208 if from_info and from_info['URL'] != base_url: |
iannucci
2014/02/21 02:17:00
if not needs_delete and ....
?
borenet
2014/02/21 13:38:17
Not sure it's needed but added anyway.
| |
1191 else: | 1209 # The repository url changed, need to switch. |
1192 msg = ('Can\'t update/checkout %s if an unversioned directory is ' | 1210 try: |
1193 'present. Delete the directory and try again.') | 1211 to_info = scm.SVN.CaptureRemoteInfo(url) |
1194 raise gclient_utils.Error(msg % self.checkout_path) | 1212 except (gclient_utils.Error, subprocess2.CalledProcessError): |
1213 # The url is invalid or the server is not accessible, it's safer to bail | |
1214 # out right now. | |
1215 raise gclient_utils.Error('This url is unreachable: %s' % url) | |
1216 can_switch = ((from_info['Repository Root'] != to_info['Repository Root']) | |
1217 and (from_info['UUID'] == to_info['UUID'])) | |
1218 if can_switch: | |
1219 print('\n_____ relocating %s to a new checkout' % self.relpath) | |
1220 # We have different roots, so check if we can switch --relocate. | |
1221 # Subversion only permits this if the repository UUIDs match. | |
1222 # Perform the switch --relocate, then rewrite the from_url | |
1223 # to reflect where we "are now." (This is the same way that | |
1224 # Subversion itself handles the metadata when switch --relocate | |
1225 # is used.) This makes the checks below for whether we | |
1226 # can update to a revision or have to switch to a different | |
1227 # branch work as expected. | |
1228 # TODO(maruel): TEST ME ! | |
1229 command = ['switch', '--relocate', | |
1230 from_info['Repository Root'], | |
1231 to_info['Repository Root'], | |
1232 self.relpath] | |
1233 self._Run(command, options, cwd=self._root_dir) | |
1234 from_info['URL'] = from_info['URL'].replace( | |
1235 from_info['Repository Root'], | |
1236 to_info['Repository Root']) | |
1237 else: | |
1238 needs_delete = True | |
1239 | |
1240 if needs_delete: | |
1241 if options.force: | |
1242 gclient_utils.rmtree(self.checkout_path) | |
1243 exists = False | |
1244 else: | |
1245 raise gclient_utils.Error('Conflicting directory found in %s. Please ' | |
1246 'delete it or run with --force.' | |
1247 % self.checkout_path) | |
1195 | 1248 |
1196 BASE_URLS = { | 1249 BASE_URLS = { |
1197 '/chrome/trunk/src': 'gs://chromium-svn-checkout/chrome/', | 1250 '/chrome/trunk/src': 'gs://chromium-svn-checkout/chrome/', |
1198 '/blink/trunk': 'gs://chromium-svn-checkout/blink/', | 1251 '/blink/trunk': 'gs://chromium-svn-checkout/blink/', |
1199 } | 1252 } |
1200 WHITELISTED_ROOTS = [ | 1253 WHITELISTED_ROOTS = [ |
1201 'svn://svn.chromium.org', | 1254 'svn://svn.chromium.org', |
1202 'svn://svn-mirror.golo.chromium.org', | 1255 'svn://svn-mirror.golo.chromium.org', |
1203 ] | 1256 ] |
1204 if not exists: | 1257 if not exists: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1262 print 'Resuming normal operations.' | 1315 print 'Resuming normal operations.' |
1263 print str(e) | 1316 print str(e) |
1264 | 1317 |
1265 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path)) | 1318 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path)) |
1266 # We need to checkout. | 1319 # We need to checkout. |
1267 command = ['checkout', url, self.checkout_path] | 1320 command = ['checkout', url, self.checkout_path] |
1268 command = self._AddAdditionalUpdateFlags(command, options, revision) | 1321 command = self._AddAdditionalUpdateFlags(command, options, revision) |
1269 self._RunAndGetFileList(command, options, file_list, self._root_dir) | 1322 self._RunAndGetFileList(command, options, file_list, self._root_dir) |
1270 return self.Svnversion() | 1323 return self.Svnversion() |
1271 | 1324 |
1272 if not managed: | |
1273 print ('________ unmanaged solution; skipping %s' % self.relpath) | |
1274 return self.Svnversion() | |
1275 | |
1276 if 'URL' not in from_info: | 1325 if 'URL' not in from_info: |
1277 raise gclient_utils.Error( | 1326 raise gclient_utils.Error( |
1278 ('gclient is confused. Couldn\'t get the url for %s.\n' | 1327 ('gclient is confused. Couldn\'t get the url for %s.\n' |
1279 'Try using @unmanaged.\n%s') % ( | 1328 'Try using @unmanaged.\n%s') % ( |
1280 self.checkout_path, from_info)) | 1329 self.checkout_path, from_info)) |
1281 | 1330 |
1282 # Look for locked directories. | 1331 # Look for locked directories. |
1283 dir_info = scm.SVN.CaptureStatus( | 1332 dir_info = scm.SVN.CaptureStatus( |
1284 None, os.path.join(self.checkout_path, '.')) | 1333 None, os.path.join(self.checkout_path, '.')) |
1285 if any(d[0][2] == 'L' for d in dir_info): | 1334 if any(d[0][2] == 'L' for d in dir_info): |
(...skipping 21 matching lines...) Expand all Loading... | |
1307 if d[0][0] == '!': | 1356 if d[0][0] == '!': |
1308 print 'You can pass --force to enable automatic removal.' | 1357 print 'You can pass --force to enable automatic removal.' |
1309 raise e | 1358 raise e |
1310 | 1359 |
1311 # Retrieve the current HEAD version because svn is slow at null updates. | 1360 # Retrieve the current HEAD version because svn is slow at null updates. |
1312 if options.manually_grab_svn_rev and not revision: | 1361 if options.manually_grab_svn_rev and not revision: |
1313 from_info_live = scm.SVN.CaptureRemoteInfo(from_info['URL']) | 1362 from_info_live = scm.SVN.CaptureRemoteInfo(from_info['URL']) |
1314 revision = str(from_info_live['Revision']) | 1363 revision = str(from_info_live['Revision']) |
1315 rev_str = ' at %s' % revision | 1364 rev_str = ' at %s' % revision |
1316 | 1365 |
1317 if from_info['URL'] != base_url: | |
1318 # The repository url changed, need to switch. | |
1319 try: | |
1320 to_info = scm.SVN.CaptureRemoteInfo(url) | |
1321 except (gclient_utils.Error, subprocess2.CalledProcessError): | |
1322 # The url is invalid or the server is not accessible, it's safer to bail | |
1323 # out right now. | |
1324 raise gclient_utils.Error('This url is unreachable: %s' % url) | |
1325 can_switch = ((from_info['Repository Root'] != to_info['Repository Root']) | |
1326 and (from_info['UUID'] == to_info['UUID'])) | |
1327 if can_switch: | |
1328 print('\n_____ relocating %s to a new checkout' % self.relpath) | |
1329 # We have different roots, so check if we can switch --relocate. | |
1330 # Subversion only permits this if the repository UUIDs match. | |
1331 # Perform the switch --relocate, then rewrite the from_url | |
1332 # to reflect where we "are now." (This is the same way that | |
1333 # Subversion itself handles the metadata when switch --relocate | |
1334 # is used.) This makes the checks below for whether we | |
1335 # can update to a revision or have to switch to a different | |
1336 # branch work as expected. | |
1337 # TODO(maruel): TEST ME ! | |
1338 command = ['switch', '--relocate', | |
1339 from_info['Repository Root'], | |
1340 to_info['Repository Root'], | |
1341 self.relpath] | |
1342 self._Run(command, options, cwd=self._root_dir) | |
1343 from_info['URL'] = from_info['URL'].replace( | |
1344 from_info['Repository Root'], | |
1345 to_info['Repository Root']) | |
1346 else: | |
1347 if not options.force and not options.reset: | |
1348 # Look for local modifications but ignore unversioned files. | |
1349 for status in scm.SVN.CaptureStatus(None, self.checkout_path): | |
1350 if status[0][0] != '?': | |
1351 raise gclient_utils.Error( | |
1352 ('Can\'t switch the checkout to %s; UUID don\'t match and ' | |
1353 'there is local changes in %s. Delete the directory and ' | |
1354 'try again.') % (url, self.checkout_path)) | |
1355 # Ok delete it. | |
1356 print('\n_____ switching %s to a new checkout' % self.relpath) | |
1357 gclient_utils.rmtree(self.checkout_path) | |
1358 # We need to checkout. | |
1359 command = ['checkout', url, self.checkout_path] | |
1360 command = self._AddAdditionalUpdateFlags(command, options, revision) | |
1361 self._RunAndGetFileList(command, options, file_list, self._root_dir) | |
1362 return self.Svnversion() | |
1363 | |
1364 # If the provided url has a revision number that matches the revision | 1366 # If the provided url has a revision number that matches the revision |
1365 # number of the existing directory, then we don't need to bother updating. | 1367 # number of the existing directory, then we don't need to bother updating. |
1366 if not options.force and str(from_info['Revision']) == revision: | 1368 if not options.force and str(from_info['Revision']) == revision: |
1367 if options.verbose or not forced_revision: | 1369 if options.verbose or not forced_revision: |
1368 print('\n_____ %s%s' % (self.relpath, rev_str)) | 1370 print('\n_____ %s%s' % (self.relpath, rev_str)) |
1369 else: | 1371 else: |
1370 command = ['update', self.checkout_path] | 1372 command = ['update', self.checkout_path] |
1371 command = self._AddAdditionalUpdateFlags(command, options, revision) | 1373 command = self._AddAdditionalUpdateFlags(command, options, revision) |
1372 self._RunAndGetFileList(command, options, file_list, self._root_dir) | 1374 self._RunAndGetFileList(command, options, file_list, self._root_dir) |
1373 | 1375 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1423 # svn revert won't work if the directory doesn't exist. It needs to | 1425 # svn revert won't work if the directory doesn't exist. It needs to |
1424 # checkout instead. | 1426 # checkout instead. |
1425 print('\n_____ %s is missing, synching instead' % self.relpath) | 1427 print('\n_____ %s is missing, synching instead' % self.relpath) |
1426 # Don't reuse the args. | 1428 # Don't reuse the args. |
1427 return self.update(options, [], file_list) | 1429 return self.update(options, [], file_list) |
1428 | 1430 |
1429 if not os.path.isdir(os.path.join(self.checkout_path, '.svn')): | 1431 if not os.path.isdir(os.path.join(self.checkout_path, '.svn')): |
1430 if os.path.isdir(os.path.join(self.checkout_path, '.git')): | 1432 if os.path.isdir(os.path.join(self.checkout_path, '.git')): |
1431 print('________ found .git directory; skipping %s' % self.relpath) | 1433 print('________ found .git directory; skipping %s' % self.relpath) |
1432 return | 1434 return |
1433 if os.path.isdir(os.path.join(self.checkout_path, '.hg')): | |
1434 print('________ found .hg directory; skipping %s' % self.relpath) | |
1435 return | |
1436 if not options.force: | 1435 if not options.force: |
1437 raise gclient_utils.Error('Invalid checkout path, aborting') | 1436 raise gclient_utils.Error('Invalid checkout path, aborting') |
1438 print( | 1437 print( |
1439 '\n_____ %s is not a valid svn checkout, synching instead' % | 1438 '\n_____ %s is not a valid svn checkout, synching instead' % |
1440 self.relpath) | 1439 self.relpath) |
1441 gclient_utils.rmtree(self.checkout_path) | 1440 gclient_utils.rmtree(self.checkout_path) |
1442 # Don't reuse the args. | 1441 # Don't reuse the args. |
1443 return self.update(options, [], file_list) | 1442 return self.update(options, [], file_list) |
1444 | 1443 |
1445 def printcb(file_status): | 1444 def printcb(file_status): |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1543 new_command.append('--force') | 1542 new_command.append('--force') |
1544 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1543 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1545 new_command.extend(('--accept', 'theirs-conflict')) | 1544 new_command.extend(('--accept', 'theirs-conflict')) |
1546 elif options.manually_grab_svn_rev: | 1545 elif options.manually_grab_svn_rev: |
1547 new_command.append('--force') | 1546 new_command.append('--force') |
1548 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1547 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1549 new_command.extend(('--accept', 'postpone')) | 1548 new_command.extend(('--accept', 'postpone')) |
1550 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1549 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1551 new_command.extend(('--accept', 'postpone')) | 1550 new_command.extend(('--accept', 'postpone')) |
1552 return new_command | 1551 return new_command |
OLD | NEW |