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

Unified Diff: gclient.py

Issue 113319: Finally implement the code to automatically switch checkout when there is no ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient.py
===================================================================
--- gclient.py (revision 15927)
+++ gclient.py (working copy)
@@ -752,7 +752,8 @@
Error: if can't get URL for relative path.
"""
# Only update if git is not controlling the directory.
- git_path = os.path.join(self._root_dir, self.relpath, '.git')
+ checkout_path = os.path.join(self._root_dir, self.relpath)
+ git_path = os.path.join(checkout_path, '.git')
if options.path_exists(git_path):
print("________ found .git directory; skipping %s" % self.relpath)
return
@@ -777,17 +778,16 @@
if revision:
rev_str = ' at %d' % revision
- if not options.path_exists(os.path.join(self._root_dir, self.relpath)):
+ if not options.path_exists(checkout_path):
# We need to checkout.
- command = ['checkout', url, os.path.join(self._root_dir, self.relpath)]
+ command = ['checkout', url, checkout_path]
if revision:
command.extend(['--revision', str(revision)])
RunSVNAndGetFileList(command, self._root_dir, file_list)
return
# Get the existing scm url and the revision number of the current checkout.
- from_info = CaptureSVNInfo(os.path.join(self._root_dir, self.relpath, '.'),
- '.')
+ from_info = CaptureSVNInfo(os.path.join(checkout_path, '.'), '.')
if options.manually_grab_svn_rev:
# Retrieve the current HEAD version because svn is slow at null updates.
@@ -798,16 +798,12 @@
if from_info['URL'] != components[0]:
to_info = CaptureSVNInfo(url, '.')
- if from_info['Repository Root'] != to_info['Repository Root']:
+ can_switch = ((from_info['Repository Root'] != to_info['Repository Root'])
+ and (from_info['UUID'] == to_info['UUID']))
+ if can_switch:
+ print("\n_____ relocating %s to a new checkout" % self.relpath)
# We have different roots, so check if we can switch --relocate.
# Subversion only permits this if the repository UUIDs match.
- if from_info['UUID'] != to_info['UUID']:
- raise Error("Can't switch the checkout to %s; UUID don't match. That "
- "simply means in theory, gclient should verify you don't "
- "have a local change, remove the old checkout and do a "
- "fresh new checkout of the new repo. Contributions are "
- "welcome." % url)
-
# Perform the switch --relocate, then rewrite the from_url
# to reflect where we "are now." (This is the same way that
# Subversion itself handles the metadata when switch --relocate
@@ -823,6 +819,21 @@
from_info['URL'] = from_info['URL'].replace(
from_info['Repository Root'],
to_info['Repository Root'])
+ else:
+ if CaptureSVNStatus(checkout_path):
+ raise Error("Can't switch the checkout to %s; UUID don't match and "
+ "there is local changes in %s. Delete the directory and "
+ "try again." % (url, checkout_path))
+ # Ok delete it.
+ print("\n_____ switching %s to a new checkout" % self.relpath)
+ RemoveDirectory(checkout_path)
+ # We need to checkout.
+ command = ['checkout', url, checkout_path]
+ if revision:
+ command.extend(['--revision', str(revision)])
+ RunSVNAndGetFileList(command, self._root_dir, file_list)
+ return
+
# If the provided url has a revision number that matches the revision
# number of the existing directory, then we don't need to bother updating.
@@ -831,7 +842,7 @@
print("\n_____ %s%s" % (self.relpath, rev_str))
return
- command = ["update", os.path.join(self._root_dir, self.relpath)]
+ command = ["update", checkout_path]
if revision:
command.extend(['--revision', str(revision)])
RunSVNAndGetFileList(command, self._root_dir, file_list)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698