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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | |
228 def GetRevisionDate(self, _revision): | 213 def GetRevisionDate(self, _revision): |
229 """Returns the given revision's date in ISO-8601 format (which contains the | 214 """Returns the given revision's date in ISO-8601 format (which contains the |
230 time zone).""" | 215 time zone).""" |
231 # TODO(floitsch): get the time-stamp of the given revision and not just the | 216 # TODO(floitsch): get the time-stamp of the given revision and not just the |
232 # time-stamp of the currently checked out revision. | 217 # time-stamp of the currently checked out revision. |
233 return self._Capture(['log', '-n', '1', '--format=%ai']) | 218 return self._Capture(['log', '-n', '1', '--format=%ai']) |
234 | 219 |
235 @staticmethod | 220 @staticmethod |
236 def cleanup(options, args, file_list): | 221 def cleanup(options, args, file_list): |
237 """'Cleanup' the repo. | 222 """'Cleanup' the repo. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 # Not a fatal error, or even very interesting in a non-git-submodule | 258 # Not a fatal error, or even very interesting in a non-git-submodule |
274 # world. So just keep it quiet. | 259 # world. So just keep it quiet. |
275 pass | 260 pass |
276 try: | 261 try: |
277 gclient_utils.CheckCallAndFilter(cmd3, **kwargs) | 262 gclient_utils.CheckCallAndFilter(cmd3, **kwargs) |
278 except subprocess2.CalledProcessError: | 263 except subprocess2.CalledProcessError: |
279 gclient_utils.CheckCallAndFilter(cmd3 + ['always'], **kwargs) | 264 gclient_utils.CheckCallAndFilter(cmd3 + ['always'], **kwargs) |
280 | 265 |
281 gclient_utils.CheckCallAndFilter(cmd4, **kwargs) | 266 gclient_utils.CheckCallAndFilter(cmd4, **kwargs) |
282 | 267 |
| 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 |
283 def update(self, options, args, file_list): | 284 def update(self, options, args, file_list): |
284 """Runs git to update or transparently checkout the working copy. | 285 """Runs git to update or transparently checkout the working copy. |
285 | 286 |
286 All updated files will be appended to file_list. | 287 All updated files will be appended to file_list. |
287 | 288 |
288 Raises: | 289 Raises: |
289 Error: if can't get URL for relative path. | 290 Error: if can't get URL for relative path. |
290 """ | 291 """ |
291 if args: | 292 if args: |
292 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) | 293 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 return self._Capture(['rev-parse', '--verify', 'HEAD']) | 360 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
360 | 361 |
361 if not os.path.exists(os.path.join(self.checkout_path, '.git')): | 362 if not os.path.exists(os.path.join(self.checkout_path, '.git')): |
362 raise gclient_utils.Error('\n____ %s%s\n' | 363 raise gclient_utils.Error('\n____ %s%s\n' |
363 '\tPath is not a git repo. No .git dir.\n' | 364 '\tPath is not a git repo. No .git dir.\n' |
364 '\tTo resolve:\n' | 365 '\tTo resolve:\n' |
365 '\t\trm -rf %s\n' | 366 '\t\trm -rf %s\n' |
366 '\tAnd run gclient sync again\n' | 367 '\tAnd run gclient sync again\n' |
367 % (self.relpath, rev_str, self.relpath)) | 368 % (self.relpath, rev_str, self.relpath)) |
368 | 369 |
| 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 |
369 # Need to do this in the normal path as well as in the post-remote-switch | 392 # Need to do this in the normal path as well as in the post-remote-switch |
370 # path. | 393 # path. |
371 self._PossiblySwitchCache(url, options) | 394 self._PossiblySwitchCache(url, options) |
372 | 395 |
| 396 if return_early: |
| 397 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
| 398 |
373 cur_branch = self._GetCurrentBranch() | 399 cur_branch = self._GetCurrentBranch() |
374 | 400 |
375 # Cases: | 401 # Cases: |
376 # 0) HEAD is detached. Probably from our initial clone. | 402 # 0) HEAD is detached. Probably from our initial clone. |
377 # - make sure HEAD is contained by a named ref, then update. | 403 # - make sure HEAD is contained by a named ref, then update. |
378 # Cases 1-4. HEAD is a branch. | 404 # Cases 1-4. HEAD is a branch. |
379 # 1) current branch is not tracking a remote branch (could be git-svn) | 405 # 1) current branch is not tracking a remote branch (could be git-svn) |
380 # - try to rebase onto the new hash or branch | 406 # - try to rebase onto the new hash or branch |
381 # 2) current branch is tracking a remote branch with local committed | 407 # 2) current branch is tracking a remote branch with local committed |
382 # changes, but the DEPS file switched to point to a hash | 408 # changes, but the DEPS file switched to point to a hash |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 raise gclient_utils.Error( | 654 raise gclient_utils.Error( |
629 ( 'We could not find a valid hash for safesync_url response "%s".\n' | 655 ( 'We could not find a valid hash for safesync_url response "%s".\n' |
630 'Safesync URLs with a git checkout currently require the repo to\n' | 656 'Safesync URLs with a git checkout currently require the repo to\n' |
631 'be cloned without a safesync_url before adding the safesync_url.\n' | 657 'be cloned without a safesync_url before adding the safesync_url.\n' |
632 'For more info, see: ' | 658 'For more info, see: ' |
633 'http://code.google.com/p/chromium/wiki/UsingNewGit' | 659 'http://code.google.com/p/chromium/wiki/UsingNewGit' |
634 '#Initial_checkout' ) % rev) | 660 '#Initial_checkout' ) % rev) |
635 elif rev.isdigit() and len(rev) < 7: | 661 elif rev.isdigit() and len(rev) < 7: |
636 # Handles an SVN rev. As an optimization, only verify an SVN revision as | 662 # Handles an SVN rev. As an optimization, only verify an SVN revision as |
637 # [0-9]{1,6} for now to avoid making a network request. | 663 # [0-9]{1,6} for now to avoid making a network request. |
638 if scm.GIT.IsGitSvn(self.checkout_path): | 664 if scm.GIT.IsGitSvn(cwd=self.checkout_path): |
639 local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path) | 665 local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path) |
640 if not local_head or local_head < int(rev): | 666 if not local_head or local_head < int(rev): |
641 try: | 667 try: |
642 logging.debug('Looking for git-svn configuration optimizations.') | 668 logging.debug('Looking for git-svn configuration optimizations.') |
643 if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], | 669 if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], |
644 cwd=self.checkout_path): | 670 cwd=self.checkout_path): |
645 scm.GIT.Capture(['fetch'], cwd=self.checkout_path) | 671 scm.GIT.Capture(['fetch'], cwd=self.checkout_path) |
646 except subprocess2.CalledProcessError: | 672 except subprocess2.CalledProcessError: |
647 logging.debug('git config --get svn-remote.svn.fetch failed, ' | 673 logging.debug('git config --get svn-remote.svn.fetch failed, ' |
648 'ignoring possible optimization.') | 674 'ignoring possible optimization.') |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 if use_reference: | 801 if use_reference: |
776 cmd += ['--reference', os.path.abspath(self.checkout_path)] | 802 cmd += ['--reference', os.path.abspath(self.checkout_path)] |
777 | 803 |
778 self._Run(cmd + [url, folder], | 804 self._Run(cmd + [url, folder], |
779 options, filter_fn=filter_fn, cwd=self.cache_dir, retry=True) | 805 options, filter_fn=filter_fn, cwd=self.cache_dir, retry=True) |
780 else: | 806 else: |
781 # For now, assert that host/path/to/repo.git is identical. We may want | 807 # For now, assert that host/path/to/repo.git is identical. We may want |
782 # to relax this restriction in the future to allow for smarter cache | 808 # to relax this restriction in the future to allow for smarter cache |
783 # repo update schemes (such as pulling the same repo, but from a | 809 # repo update schemes (such as pulling the same repo, but from a |
784 # different host). | 810 # different host). |
785 existing_url = self.GetRemoteURL(options, cwd=folder) | 811 existing_url = self._Capture(['config', 'remote.%s.url' % self.remote], |
| 812 cwd=folder) |
786 assert self._NormalizeGitURL(existing_url) == self._NormalizeGitURL(url) | 813 assert self._NormalizeGitURL(existing_url) == self._NormalizeGitURL(url) |
787 | 814 |
788 if use_reference: | 815 if use_reference: |
789 with open(altfile, 'w') as f: | 816 with open(altfile, 'w') as f: |
790 f.write(os.path.abspath(checkout_objects)) | 817 f.write(os.path.abspath(checkout_objects)) |
791 | 818 |
792 # Would normally use `git remote update`, but it doesn't support | 819 # Would normally use `git remote update`, but it doesn't support |
793 # --progress, so use fetch instead. | 820 # --progress, so use fetch instead. |
794 self._Run(['fetch'] + v + ['--multiple', '--progress', '--all'], | 821 self._Run(['fetch'] + v + ['--multiple', '--progress', '--all'], |
795 options, filter_fn=filter_fn, cwd=folder, retry=True) | 822 options, filter_fn=filter_fn, cwd=folder, retry=True) |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 result, version = scm.SVN.AssertVersion('1.4') | 1091 result, version = scm.SVN.AssertVersion('1.4') |
1065 if not result: | 1092 if not result: |
1066 raise gclient_utils.Error('SVN version is older than 1.4: %s' % version) | 1093 raise gclient_utils.Error('SVN version is older than 1.4: %s' % version) |
1067 return result | 1094 return result |
1068 except OSError: | 1095 except OSError: |
1069 return False | 1096 return False |
1070 | 1097 |
1071 def GetCheckoutRoot(self): | 1098 def GetCheckoutRoot(self): |
1072 return scm.SVN.GetCheckoutRoot(self.checkout_path) | 1099 return scm.SVN.GetCheckoutRoot(self.checkout_path) |
1073 | 1100 |
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 | |
1090 def GetRevisionDate(self, revision): | 1101 def GetRevisionDate(self, revision): |
1091 """Returns the given revision's date in ISO-8601 format (which contains the | 1102 """Returns the given revision's date in ISO-8601 format (which contains the |
1092 time zone).""" | 1103 time zone).""" |
1093 date = scm.SVN.Capture( | 1104 date = scm.SVN.Capture( |
1094 ['propget', '--revprop', 'svn:date', '-r', revision], | 1105 ['propget', '--revprop', 'svn:date', '-r', revision], |
1095 os.path.join(self.checkout_path, '.')) | 1106 os.path.join(self.checkout_path, '.')) |
1096 return date.strip() | 1107 return date.strip() |
1097 | 1108 |
1098 def cleanup(self, options, args, _file_list): | 1109 def cleanup(self, options, args, _file_list): |
1099 """Cleanup working copy.""" | 1110 """Cleanup working copy.""" |
(...skipping 19 matching lines...) Expand all Loading... |
1119 filter_fn=SvnDiffFilterer(self.relpath).Filter) | 1130 filter_fn=SvnDiffFilterer(self.relpath).Filter) |
1120 | 1131 |
1121 def update(self, options, args, file_list): | 1132 def update(self, options, args, file_list): |
1122 """Runs svn to update or transparently checkout the working copy. | 1133 """Runs svn to update or transparently checkout the working copy. |
1123 | 1134 |
1124 All updated files will be appended to file_list. | 1135 All updated files will be appended to file_list. |
1125 | 1136 |
1126 Raises: | 1137 Raises: |
1127 Error: if can't get URL for relative path. | 1138 Error: if can't get URL for relative path. |
1128 """ | 1139 """ |
1129 exists = os.path.exists(self.checkout_path) | 1140 # Only update if git or hg is not controlling the directory. |
| 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 |
1130 | 1145 |
1131 if exists and scm.GIT.IsGitSvn(self.checkout_path): | 1146 hg_path = os.path.join(self.checkout_path, '.hg') |
1132 print '________ %s looks like git-svn; skipping.' % self.relpath | 1147 if os.path.exists(hg_path): |
| 1148 print('________ found .hg directory; skipping %s' % self.relpath) |
1133 return | 1149 return |
1134 | 1150 |
1135 if args: | 1151 if args: |
1136 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) | 1152 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) |
1137 | 1153 |
1138 # revision is the revision to match. It is None if no revision is specified, | 1154 # revision is the revision to match. It is None if no revision is specified, |
1139 # i.e. the 'deps ain't pinned'. | 1155 # i.e. the 'deps ain't pinned'. |
1140 url, revision = gclient_utils.SplitUrlRevision(self.url) | 1156 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 |
1141 managed = True | 1159 managed = True |
1142 if options.revision: | 1160 if options.revision: |
1143 # Override the revision number. | 1161 # Override the revision number. |
1144 revision = str(options.revision) | 1162 revision = str(options.revision) |
1145 if revision: | 1163 if revision: |
1146 if revision != 'unmanaged': | 1164 if revision != 'unmanaged': |
1147 forced_revision = True | 1165 forced_revision = True |
1148 # Reconstruct the url. | 1166 # Reconstruct the url. |
1149 url = '%s@%s' % (url, revision) | 1167 url = '%s@%s' % (url, revision) |
1150 rev_str = ' at %s' % revision | 1168 rev_str = ' at %s' % revision |
1151 else: | 1169 else: |
1152 managed = False | 1170 managed = False |
1153 revision = None | 1171 revision = None |
1154 else: | 1172 else: |
1155 forced_revision = False | 1173 forced_revision = False |
1156 rev_str = '' | 1174 rev_str = '' |
1157 | 1175 |
1158 # Get the existing scm url and the revision number of the current checkout. | 1176 # Get the existing scm url and the revision number of the current checkout. |
| 1177 exists = os.path.exists(self.checkout_path) |
1159 if exists and managed: | 1178 if exists and managed: |
1160 try: | 1179 try: |
1161 from_info = scm.SVN.CaptureLocalInfo( | 1180 from_info = scm.SVN.CaptureLocalInfo( |
1162 [], os.path.join(self.checkout_path, '.')) | 1181 [], os.path.join(self.checkout_path, '.')) |
1163 except (gclient_utils.Error, subprocess2.CalledProcessError): | 1182 except (gclient_utils.Error, subprocess2.CalledProcessError): |
1164 if options.reset and options.delete_unversioned_trees: | 1183 if options.reset and options.delete_unversioned_trees: |
1165 print 'Removing troublesome path %s' % self.checkout_path | 1184 print 'Removing troublesome path %s' % self.checkout_path |
1166 gclient_utils.rmtree(self.checkout_path) | 1185 gclient_utils.rmtree(self.checkout_path) |
1167 exists = False | 1186 exists = False |
1168 else: | 1187 else: |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 if d[0][0] == '!': | 1303 if d[0][0] == '!': |
1285 print 'You can pass --force to enable automatic removal.' | 1304 print 'You can pass --force to enable automatic removal.' |
1286 raise e | 1305 raise e |
1287 | 1306 |
1288 # Retrieve the current HEAD version because svn is slow at null updates. | 1307 # Retrieve the current HEAD version because svn is slow at null updates. |
1289 if options.manually_grab_svn_rev and not revision: | 1308 if options.manually_grab_svn_rev and not revision: |
1290 from_info_live = scm.SVN.CaptureRemoteInfo(from_info['URL']) | 1309 from_info_live = scm.SVN.CaptureRemoteInfo(from_info['URL']) |
1291 revision = str(from_info_live['Revision']) | 1310 revision = str(from_info_live['Revision']) |
1292 rev_str = ' at %s' % revision | 1311 rev_str = ' at %s' % revision |
1293 | 1312 |
| 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 |
1294 # If the provided url has a revision number that matches the revision | 1360 # If the provided url has a revision number that matches the revision |
1295 # number of the existing directory, then we don't need to bother updating. | 1361 # number of the existing directory, then we don't need to bother updating. |
1296 if not options.force and str(from_info['Revision']) == revision: | 1362 if not options.force and str(from_info['Revision']) == revision: |
1297 if options.verbose or not forced_revision: | 1363 if options.verbose or not forced_revision: |
1298 print('\n_____ %s%s' % (self.relpath, rev_str)) | 1364 print('\n_____ %s%s' % (self.relpath, rev_str)) |
1299 else: | 1365 else: |
1300 command = ['update', self.checkout_path] | 1366 command = ['update', self.checkout_path] |
1301 command = self._AddAdditionalUpdateFlags(command, options, revision) | 1367 command = self._AddAdditionalUpdateFlags(command, options, revision) |
1302 self._RunAndGetFileList(command, options, file_list, self._root_dir) | 1368 self._RunAndGetFileList(command, options, file_list, self._root_dir) |
1303 | 1369 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 if not os.path.isdir(self.checkout_path): | 1416 if not os.path.isdir(self.checkout_path): |
1351 if os.path.exists(self.checkout_path): | 1417 if os.path.exists(self.checkout_path): |
1352 gclient_utils.rmtree(self.checkout_path) | 1418 gclient_utils.rmtree(self.checkout_path) |
1353 # svn revert won't work if the directory doesn't exist. It needs to | 1419 # svn revert won't work if the directory doesn't exist. It needs to |
1354 # checkout instead. | 1420 # checkout instead. |
1355 print('\n_____ %s is missing, synching instead' % self.relpath) | 1421 print('\n_____ %s is missing, synching instead' % self.relpath) |
1356 # Don't reuse the args. | 1422 # Don't reuse the args. |
1357 return self.update(options, [], file_list) | 1423 return self.update(options, [], file_list) |
1358 | 1424 |
1359 if not os.path.isdir(os.path.join(self.checkout_path, '.svn')): | 1425 if not os.path.isdir(os.path.join(self.checkout_path, '.svn')): |
1360 if scm.GIT.IsGitSvn(self.checkout_path): | 1426 if os.path.isdir(os.path.join(self.checkout_path, '.git')): |
1361 print '________ %s looks like git-svn; skipping.' % self.relpath | 1427 print('________ found .git directory; skipping %s' % 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) |
1362 return | 1431 return |
1363 if not options.force: | 1432 if not options.force: |
1364 raise gclient_utils.Error('Invalid checkout path, aborting') | 1433 raise gclient_utils.Error('Invalid checkout path, aborting') |
1365 print( | 1434 print( |
1366 '\n_____ %s is not a valid svn checkout, synching instead' % | 1435 '\n_____ %s is not a valid svn checkout, synching instead' % |
1367 self.relpath) | 1436 self.relpath) |
1368 gclient_utils.rmtree(self.checkout_path) | 1437 gclient_utils.rmtree(self.checkout_path) |
1369 # Don't reuse the args. | 1438 # Don't reuse the args. |
1370 return self.update(options, [], file_list) | 1439 return self.update(options, [], file_list) |
1371 | 1440 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 new_command.append('--force') | 1539 new_command.append('--force') |
1471 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1540 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1472 new_command.extend(('--accept', 'theirs-conflict')) | 1541 new_command.extend(('--accept', 'theirs-conflict')) |
1473 elif options.manually_grab_svn_rev: | 1542 elif options.manually_grab_svn_rev: |
1474 new_command.append('--force') | 1543 new_command.append('--force') |
1475 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1544 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1476 new_command.extend(('--accept', 'postpone')) | 1545 new_command.extend(('--accept', 'postpone')) |
1477 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1546 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1478 new_command.extend(('--accept', 'postpone')) | 1547 new_command.extend(('--accept', 'postpone')) |
1479 return new_command | 1548 return new_command |
OLD | NEW |