Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Side by Side Diff: gclient_scm.py

Issue 133073015: Re-reland r245404 ("If the destination directory doesn't contain the desired repo, delete it") (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Clean up check_output call, print hostname on bots Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gclient.py ('k') | scm.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 result, version = scm.GIT.AssertVersion('1.7') 203 result, version = scm.GIT.AssertVersion('1.7')
204 if not result: 204 if not result:
205 raise gclient_utils.Error('Git version is older than 1.7: %s' % version) 205 raise gclient_utils.Error('Git version is older than 1.7: %s' % version)
206 return result 206 return result
207 except OSError: 207 except OSError:
208 return False 208 return False
209 209
210 def GetCheckoutRoot(self): 210 def GetCheckoutRoot(self):
211 return scm.GIT.GetCheckoutRoot(self.checkout_path) 211 return scm.GIT.GetCheckoutRoot(self.checkout_path)
212 212
213 def GetRemoteURL(self, options, cwd=None):
214 try:
215 return self._Capture(['config', 'remote.%s.url' % self.remote],
216 cwd=cwd or self.checkout_path).rstrip()
217 except (OSError, subprocess2.CalledProcessError):
218 pass
219 try:
220 # This may occur if we have a git-svn checkout.
221 if scm.GIT.IsGitSvn(cwd or self.checkout_path):
222 return scm.GIT.Capture(['config', '--local', '--get',
223 'svn-remote.svn.url'], os.curdir).rstrip()
224 except (OSError, subprocess2.CalledProcessError):
225 pass
226 return None
227
213 def GetRevisionDate(self, _revision): 228 def GetRevisionDate(self, _revision):
214 """Returns the given revision's date in ISO-8601 format (which contains the 229 """Returns the given revision's date in ISO-8601 format (which contains the
215 time zone).""" 230 time zone)."""
216 # TODO(floitsch): get the time-stamp of the given revision and not just the 231 # TODO(floitsch): get the time-stamp of the given revision and not just the
217 # time-stamp of the currently checked out revision. 232 # time-stamp of the currently checked out revision.
218 return self._Capture(['log', '-n', '1', '--format=%ai']) 233 return self._Capture(['log', '-n', '1', '--format=%ai'])
219 234
220 @staticmethod 235 @staticmethod
221 def cleanup(options, args, file_list): 236 def cleanup(options, args, file_list):
222 """'Cleanup' the repo. 237 """'Cleanup' the repo.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 # Not a fatal error, or even very interesting in a non-git-submodule 273 # Not a fatal error, or even very interesting in a non-git-submodule
259 # world. So just keep it quiet. 274 # world. So just keep it quiet.
260 pass 275 pass
261 try: 276 try:
262 gclient_utils.CheckCallAndFilter(cmd3, **kwargs) 277 gclient_utils.CheckCallAndFilter(cmd3, **kwargs)
263 except subprocess2.CalledProcessError: 278 except subprocess2.CalledProcessError:
264 gclient_utils.CheckCallAndFilter(cmd3 + ['always'], **kwargs) 279 gclient_utils.CheckCallAndFilter(cmd3 + ['always'], **kwargs)
265 280
266 gclient_utils.CheckCallAndFilter(cmd4, **kwargs) 281 gclient_utils.CheckCallAndFilter(cmd4, **kwargs)
267 282
268 def _FetchAndReset(self, revision, file_list, options):
269 """Equivalent to git fetch; git reset."""
270 quiet = []
271 if not options.verbose:
272 quiet = ['--quiet']
273 self._UpdateBranchHeads(options, fetch=False)
274
275 fetch_cmd = [
276 '-c', 'core.deltaBaseCacheLimit=2g', 'fetch', self.remote, '--prune']
277 self._Run(fetch_cmd + quiet, options, retry=True)
278 self._Run(['reset', '--hard', revision] + quiet, options)
279 self.UpdateSubmoduleConfig()
280 if file_list is not None:
281 files = self._Capture(['ls-files']).splitlines()
282 file_list.extend([os.path.join(self.checkout_path, f) for f in files])
283
284 def update(self, options, args, file_list): 283 def update(self, options, args, file_list):
285 """Runs git to update or transparently checkout the working copy. 284 """Runs git to update or transparently checkout the working copy.
286 285
287 All updated files will be appended to file_list. 286 All updated files will be appended to file_list.
288 287
289 Raises: 288 Raises:
290 Error: if can't get URL for relative path. 289 Error: if can't get URL for relative path.
291 """ 290 """
292 if args: 291 if args:
293 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) 292 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args))
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 return self._Capture(['rev-parse', '--verify', 'HEAD']) 359 return self._Capture(['rev-parse', '--verify', 'HEAD'])
361 360
362 if not os.path.exists(os.path.join(self.checkout_path, '.git')): 361 if not os.path.exists(os.path.join(self.checkout_path, '.git')):
363 raise gclient_utils.Error('\n____ %s%s\n' 362 raise gclient_utils.Error('\n____ %s%s\n'
364 '\tPath is not a git repo. No .git dir.\n' 363 '\tPath is not a git repo. No .git dir.\n'
365 '\tTo resolve:\n' 364 '\tTo resolve:\n'
366 '\t\trm -rf %s\n' 365 '\t\trm -rf %s\n'
367 '\tAnd run gclient sync again\n' 366 '\tAnd run gclient sync again\n'
368 % (self.relpath, rev_str, self.relpath)) 367 % (self.relpath, rev_str, self.relpath))
369 368
370 # See if the url has changed (the unittests use git://foo for the url, let
371 # that through).
372 current_url = self._Capture(['config', 'remote.%s.url' % self.remote])
373 return_early = False
374 # TODO(maruel): Delete url != 'git://foo' since it's just to make the
375 # unit test pass. (and update the comment above)
376 # Skip url auto-correction if remote.origin.gclient-auto-fix-url is set.
377 # This allows devs to use experimental repos which have a different url
378 # but whose branch(s) are the same as official repos.
379 if (current_url != url and
380 url != 'git://foo' and
381 subprocess2.capture(
382 ['git', 'config', 'remote.%s.gclient-auto-fix-url' % self.remote],
383 cwd=self.checkout_path).strip() != 'False'):
384 print('_____ switching %s to a new upstream' % self.relpath)
385 # Make sure it's clean
386 self._CheckClean(rev_str)
387 # Switch over to the new upstream
388 self._Run(['remote', 'set-url', self.remote, url], options)
389 self._FetchAndReset(revision, file_list, options)
390 return_early = True
391
392 # Need to do this in the normal path as well as in the post-remote-switch 369 # Need to do this in the normal path as well as in the post-remote-switch
393 # path. 370 # path.
394 self._PossiblySwitchCache(url, options) 371 self._PossiblySwitchCache(url, options)
395 372
396 if return_early:
397 return self._Capture(['rev-parse', '--verify', 'HEAD'])
398
399 cur_branch = self._GetCurrentBranch() 373 cur_branch = self._GetCurrentBranch()
400 374
401 # Cases: 375 # Cases:
402 # 0) HEAD is detached. Probably from our initial clone. 376 # 0) HEAD is detached. Probably from our initial clone.
403 # - make sure HEAD is contained by a named ref, then update. 377 # - make sure HEAD is contained by a named ref, then update.
404 # Cases 1-4. HEAD is a branch. 378 # Cases 1-4. HEAD is a branch.
405 # 1) current branch is not tracking a remote branch (could be git-svn) 379 # 1) current branch is not tracking a remote branch (could be git-svn)
406 # - try to rebase onto the new hash or branch 380 # - try to rebase onto the new hash or branch
407 # 2) current branch is tracking a remote branch with local committed 381 # 2) current branch is tracking a remote branch with local committed
408 # changes, but the DEPS file switched to point to a hash 382 # changes, but the DEPS file switched to point to a hash
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 raise gclient_utils.Error( 628 raise gclient_utils.Error(
655 ( 'We could not find a valid hash for safesync_url response "%s".\n' 629 ( 'We could not find a valid hash for safesync_url response "%s".\n'
656 'Safesync URLs with a git checkout currently require the repo to\n' 630 'Safesync URLs with a git checkout currently require the repo to\n'
657 'be cloned without a safesync_url before adding the safesync_url.\n' 631 'be cloned without a safesync_url before adding the safesync_url.\n'
658 'For more info, see: ' 632 'For more info, see: '
659 'http://code.google.com/p/chromium/wiki/UsingNewGit' 633 'http://code.google.com/p/chromium/wiki/UsingNewGit'
660 '#Initial_checkout' ) % rev) 634 '#Initial_checkout' ) % rev)
661 elif rev.isdigit() and len(rev) < 7: 635 elif rev.isdigit() and len(rev) < 7:
662 # Handles an SVN rev. As an optimization, only verify an SVN revision as 636 # Handles an SVN rev. As an optimization, only verify an SVN revision as
663 # [0-9]{1,6} for now to avoid making a network request. 637 # [0-9]{1,6} for now to avoid making a network request.
664 if scm.GIT.IsGitSvn(cwd=self.checkout_path): 638 if scm.GIT.IsGitSvn(self.checkout_path):
665 local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path) 639 local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path)
666 if not local_head or local_head < int(rev): 640 if not local_head or local_head < int(rev):
667 try: 641 try:
668 logging.debug('Looking for git-svn configuration optimizations.') 642 logging.debug('Looking for git-svn configuration optimizations.')
669 if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], 643 if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'],
670 cwd=self.checkout_path): 644 cwd=self.checkout_path):
671 scm.GIT.Capture(['fetch'], cwd=self.checkout_path) 645 scm.GIT.Capture(['fetch'], cwd=self.checkout_path)
672 except subprocess2.CalledProcessError: 646 except subprocess2.CalledProcessError:
673 logging.debug('git config --get svn-remote.svn.fetch failed, ' 647 logging.debug('git config --get svn-remote.svn.fetch failed, '
674 'ignoring possible optimization.') 648 'ignoring possible optimization.')
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 if use_reference: 775 if use_reference:
802 cmd += ['--reference', os.path.abspath(self.checkout_path)] 776 cmd += ['--reference', os.path.abspath(self.checkout_path)]
803 777
804 self._Run(cmd + [url, folder], 778 self._Run(cmd + [url, folder],
805 options, filter_fn=filter_fn, cwd=self.cache_dir, retry=True) 779 options, filter_fn=filter_fn, cwd=self.cache_dir, retry=True)
806 else: 780 else:
807 # For now, assert that host/path/to/repo.git is identical. We may want 781 # For now, assert that host/path/to/repo.git is identical. We may want
808 # to relax this restriction in the future to allow for smarter cache 782 # to relax this restriction in the future to allow for smarter cache
809 # repo update schemes (such as pulling the same repo, but from a 783 # repo update schemes (such as pulling the same repo, but from a
810 # different host). 784 # different host).
811 existing_url = self._Capture(['config', 'remote.%s.url' % self.remote], 785 existing_url = self.GetRemoteURL(options, cwd=folder)
812 cwd=folder)
813 assert self._NormalizeGitURL(existing_url) == self._NormalizeGitURL(url) 786 assert self._NormalizeGitURL(existing_url) == self._NormalizeGitURL(url)
814 787
815 if use_reference: 788 if use_reference:
816 with open(altfile, 'w') as f: 789 with open(altfile, 'w') as f:
817 f.write(os.path.abspath(checkout_objects)) 790 f.write(os.path.abspath(checkout_objects))
818 791
819 # Would normally use `git remote update`, but it doesn't support 792 # Would normally use `git remote update`, but it doesn't support
820 # --progress, so use fetch instead. 793 # --progress, so use fetch instead.
821 self._Run(['fetch'] + v + ['--multiple', '--progress', '--all'], 794 self._Run(['fetch'] + v + ['--multiple', '--progress', '--all'],
822 options, filter_fn=filter_fn, cwd=folder, retry=True) 795 options, filter_fn=filter_fn, cwd=folder, retry=True)
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 result, version = scm.SVN.AssertVersion('1.4') 1064 result, version = scm.SVN.AssertVersion('1.4')
1092 if not result: 1065 if not result:
1093 raise gclient_utils.Error('SVN version is older than 1.4: %s' % version) 1066 raise gclient_utils.Error('SVN version is older than 1.4: %s' % version)
1094 return result 1067 return result
1095 except OSError: 1068 except OSError:
1096 return False 1069 return False
1097 1070
1098 def GetCheckoutRoot(self): 1071 def GetCheckoutRoot(self):
1099 return scm.SVN.GetCheckoutRoot(self.checkout_path) 1072 return scm.SVN.GetCheckoutRoot(self.checkout_path)
1100 1073
1074 def GetRemoteURL(self, options):
1075 try:
1076 return scm.SVN.CaptureLocalInfo([os.curdir],
1077 self.checkout_path).get('URL')
1078 except (OSError, subprocess2.CalledProcessError):
1079 pass
1080 try:
1081 # This may occur if we have a git-svn checkout.
1082 if scm.GIT.IsGitSvn(os.curdir):
1083 return scm.GIT.Capture(['config', '--local', '--get',
1084 'svn-remote.svn.url'], os.curdir).rstrip()
1085 except (OSError, subprocess2.CalledProcessError):
1086 pass
1087 return None
1088
1089
1101 def GetRevisionDate(self, revision): 1090 def GetRevisionDate(self, revision):
1102 """Returns the given revision's date in ISO-8601 format (which contains the 1091 """Returns the given revision's date in ISO-8601 format (which contains the
1103 time zone).""" 1092 time zone)."""
1104 date = scm.SVN.Capture( 1093 date = scm.SVN.Capture(
1105 ['propget', '--revprop', 'svn:date', '-r', revision], 1094 ['propget', '--revprop', 'svn:date', '-r', revision],
1106 os.path.join(self.checkout_path, '.')) 1095 os.path.join(self.checkout_path, '.'))
1107 return date.strip() 1096 return date.strip()
1108 1097
1109 def cleanup(self, options, args, _file_list): 1098 def cleanup(self, options, args, _file_list):
1110 """Cleanup working copy.""" 1099 """Cleanup working copy."""
(...skipping 19 matching lines...) Expand all
1130 filter_fn=SvnDiffFilterer(self.relpath).Filter) 1119 filter_fn=SvnDiffFilterer(self.relpath).Filter)
1131 1120
1132 def update(self, options, args, file_list): 1121 def update(self, options, args, file_list):
1133 """Runs svn to update or transparently checkout the working copy. 1122 """Runs svn to update or transparently checkout the working copy.
1134 1123
1135 All updated files will be appended to file_list. 1124 All updated files will be appended to file_list.
1136 1125
1137 Raises: 1126 Raises:
1138 Error: if can't get URL for relative path. 1127 Error: if can't get URL for relative path.
1139 """ 1128 """
1140 # Only update if git or hg is not controlling the directory. 1129 exists = os.path.exists(self.checkout_path)
1141 git_path = os.path.join(self.checkout_path, '.git')
1142 if os.path.exists(git_path):
1143 print('________ found .git directory; skipping %s' % self.relpath)
1144 return
1145 1130
1146 hg_path = os.path.join(self.checkout_path, '.hg') 1131 if exists and scm.GIT.IsGitSvn(self.checkout_path):
1147 if os.path.exists(hg_path): 1132 print '________ %s looks like git-svn; skipping.' % self.relpath
1148 print('________ found .hg directory; skipping %s' % self.relpath)
1149 return 1133 return
1150 1134
1151 if args: 1135 if args:
1152 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) 1136 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args))
1153 1137
1154 # revision is the revision to match. It is None if no revision is specified, 1138 # revision is the revision to match. It is None if no revision is specified,
1155 # i.e. the 'deps ain't pinned'. 1139 # i.e. the 'deps ain't pinned'.
1156 url, revision = gclient_utils.SplitUrlRevision(self.url) 1140 url, revision = gclient_utils.SplitUrlRevision(self.url)
1157 # Keep the original unpinned url for reference in case the repo is switched.
1158 base_url = url
1159 managed = True 1141 managed = True
1160 if options.revision: 1142 if options.revision:
1161 # Override the revision number. 1143 # Override the revision number.
1162 revision = str(options.revision) 1144 revision = str(options.revision)
1163 if revision: 1145 if revision:
1164 if revision != 'unmanaged': 1146 if revision != 'unmanaged':
1165 forced_revision = True 1147 forced_revision = True
1166 # Reconstruct the url. 1148 # Reconstruct the url.
1167 url = '%s@%s' % (url, revision) 1149 url = '%s@%s' % (url, revision)
1168 rev_str = ' at %s' % revision 1150 rev_str = ' at %s' % revision
1169 else: 1151 else:
1170 managed = False 1152 managed = False
1171 revision = None 1153 revision = None
1172 else: 1154 else:
1173 forced_revision = False 1155 forced_revision = False
1174 rev_str = '' 1156 rev_str = ''
1175 1157
1176 # Get the existing scm url and the revision number of the current checkout. 1158 # Get the existing scm url and the revision number of the current checkout.
1177 exists = os.path.exists(self.checkout_path)
1178 if exists and managed: 1159 if exists and managed:
1179 try: 1160 try:
1180 from_info = scm.SVN.CaptureLocalInfo( 1161 from_info = scm.SVN.CaptureLocalInfo(
1181 [], os.path.join(self.checkout_path, '.')) 1162 [], os.path.join(self.checkout_path, '.'))
1182 except (gclient_utils.Error, subprocess2.CalledProcessError): 1163 except (gclient_utils.Error, subprocess2.CalledProcessError):
1183 if options.reset and options.delete_unversioned_trees: 1164 if options.reset and options.delete_unversioned_trees:
1184 print 'Removing troublesome path %s' % self.checkout_path 1165 print 'Removing troublesome path %s' % self.checkout_path
1185 gclient_utils.rmtree(self.checkout_path) 1166 gclient_utils.rmtree(self.checkout_path)
1186 exists = False 1167 exists = False
1187 else: 1168 else:
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 if d[0][0] == '!': 1284 if d[0][0] == '!':
1304 print 'You can pass --force to enable automatic removal.' 1285 print 'You can pass --force to enable automatic removal.'
1305 raise e 1286 raise e
1306 1287
1307 # Retrieve the current HEAD version because svn is slow at null updates. 1288 # Retrieve the current HEAD version because svn is slow at null updates.
1308 if options.manually_grab_svn_rev and not revision: 1289 if options.manually_grab_svn_rev and not revision:
1309 from_info_live = scm.SVN.CaptureRemoteInfo(from_info['URL']) 1290 from_info_live = scm.SVN.CaptureRemoteInfo(from_info['URL'])
1310 revision = str(from_info_live['Revision']) 1291 revision = str(from_info_live['Revision'])
1311 rev_str = ' at %s' % revision 1292 rev_str = ' at %s' % revision
1312 1293
1313 if from_info['URL'] != base_url:
1314 # The repository url changed, need to switch.
1315 try:
1316 to_info = scm.SVN.CaptureRemoteInfo(url)
1317 except (gclient_utils.Error, subprocess2.CalledProcessError):
1318 # The url is invalid or the server is not accessible, it's safer to bail
1319 # out right now.
1320 raise gclient_utils.Error('This url is unreachable: %s' % url)
1321 can_switch = ((from_info['Repository Root'] != to_info['Repository Root'])
1322 and (from_info['UUID'] == to_info['UUID']))
1323 if can_switch:
1324 print('\n_____ relocating %s to a new checkout' % self.relpath)
1325 # We have different roots, so check if we can switch --relocate.
1326 # Subversion only permits this if the repository UUIDs match.
1327 # Perform the switch --relocate, then rewrite the from_url
1328 # to reflect where we "are now." (This is the same way that
1329 # Subversion itself handles the metadata when switch --relocate
1330 # is used.) This makes the checks below for whether we
1331 # can update to a revision or have to switch to a different
1332 # branch work as expected.
1333 # TODO(maruel): TEST ME !
1334 command = ['switch', '--relocate',
1335 from_info['Repository Root'],
1336 to_info['Repository Root'],
1337 self.relpath]
1338 self._Run(command, options, cwd=self._root_dir)
1339 from_info['URL'] = from_info['URL'].replace(
1340 from_info['Repository Root'],
1341 to_info['Repository Root'])
1342 else:
1343 if not options.force and not options.reset:
1344 # Look for local modifications but ignore unversioned files.
1345 for status in scm.SVN.CaptureStatus(None, self.checkout_path):
1346 if status[0][0] != '?':
1347 raise gclient_utils.Error(
1348 ('Can\'t switch the checkout to %s; UUID don\'t match and '
1349 'there is local changes in %s. Delete the directory and '
1350 'try again.') % (url, self.checkout_path))
1351 # Ok delete it.
1352 print('\n_____ switching %s to a new checkout' % self.relpath)
1353 gclient_utils.rmtree(self.checkout_path)
1354 # We need to checkout.
1355 command = ['checkout', url, self.checkout_path]
1356 command = self._AddAdditionalUpdateFlags(command, options, revision)
1357 self._RunAndGetFileList(command, options, file_list, self._root_dir)
1358 return self.Svnversion()
1359
1360 # If the provided url has a revision number that matches the revision 1294 # If the provided url has a revision number that matches the revision
1361 # number of the existing directory, then we don't need to bother updating. 1295 # number of the existing directory, then we don't need to bother updating.
1362 if not options.force and str(from_info['Revision']) == revision: 1296 if not options.force and str(from_info['Revision']) == revision:
1363 if options.verbose or not forced_revision: 1297 if options.verbose or not forced_revision:
1364 print('\n_____ %s%s' % (self.relpath, rev_str)) 1298 print('\n_____ %s%s' % (self.relpath, rev_str))
1365 else: 1299 else:
1366 command = ['update', self.checkout_path] 1300 command = ['update', self.checkout_path]
1367 command = self._AddAdditionalUpdateFlags(command, options, revision) 1301 command = self._AddAdditionalUpdateFlags(command, options, revision)
1368 self._RunAndGetFileList(command, options, file_list, self._root_dir) 1302 self._RunAndGetFileList(command, options, file_list, self._root_dir)
1369 1303
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 if not os.path.isdir(self.checkout_path): 1350 if not os.path.isdir(self.checkout_path):
1417 if os.path.exists(self.checkout_path): 1351 if os.path.exists(self.checkout_path):
1418 gclient_utils.rmtree(self.checkout_path) 1352 gclient_utils.rmtree(self.checkout_path)
1419 # svn revert won't work if the directory doesn't exist. It needs to 1353 # svn revert won't work if the directory doesn't exist. It needs to
1420 # checkout instead. 1354 # checkout instead.
1421 print('\n_____ %s is missing, synching instead' % self.relpath) 1355 print('\n_____ %s is missing, synching instead' % self.relpath)
1422 # Don't reuse the args. 1356 # Don't reuse the args.
1423 return self.update(options, [], file_list) 1357 return self.update(options, [], file_list)
1424 1358
1425 if not os.path.isdir(os.path.join(self.checkout_path, '.svn')): 1359 if not os.path.isdir(os.path.join(self.checkout_path, '.svn')):
1426 if os.path.isdir(os.path.join(self.checkout_path, '.git')): 1360 if scm.GIT.IsGitSvn(self.checkout_path):
1427 print('________ found .git directory; skipping %s' % self.relpath) 1361 print '________ %s looks like git-svn; skipping.' % self.relpath
1428 return
1429 if os.path.isdir(os.path.join(self.checkout_path, '.hg')):
1430 print('________ found .hg directory; skipping %s' % self.relpath)
1431 return 1362 return
1432 if not options.force: 1363 if not options.force:
1433 raise gclient_utils.Error('Invalid checkout path, aborting') 1364 raise gclient_utils.Error('Invalid checkout path, aborting')
1434 print( 1365 print(
1435 '\n_____ %s is not a valid svn checkout, synching instead' % 1366 '\n_____ %s is not a valid svn checkout, synching instead' %
1436 self.relpath) 1367 self.relpath)
1437 gclient_utils.rmtree(self.checkout_path) 1368 gclient_utils.rmtree(self.checkout_path)
1438 # Don't reuse the args. 1369 # Don't reuse the args.
1439 return self.update(options, [], file_list) 1370 return self.update(options, [], file_list)
1440 1371
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 new_command.append('--force') 1470 new_command.append('--force')
1540 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1471 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1541 new_command.extend(('--accept', 'theirs-conflict')) 1472 new_command.extend(('--accept', 'theirs-conflict'))
1542 elif options.manually_grab_svn_rev: 1473 elif options.manually_grab_svn_rev:
1543 new_command.append('--force') 1474 new_command.append('--force')
1544 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1475 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1545 new_command.extend(('--accept', 'postpone')) 1476 new_command.extend(('--accept', 'postpone'))
1546 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1477 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1547 new_command.extend(('--accept', 'postpone')) 1478 new_command.extend(('--accept', 'postpone'))
1548 return new_command 1479 return new_command
OLDNEW
« no previous file with comments | « gclient.py ('k') | scm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698