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

Unified Diff: gclient_scm.py

Issue 192323006: Revert of Another attempt: gclient: delete mismatching checkouts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 9 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 | scm.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_scm.py
diff --git a/gclient_scm.py b/gclient_scm.py
index 151fe147b4e2f54d059901c21c3d553aa12b4d85..af48b5f7f33b5984667abe2e4887f9f224e59737 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -300,21 +300,6 @@
if (not os.path.exists(self.checkout_path) or
(os.path.isdir(self.checkout_path) and
not os.path.exists(os.path.join(self.checkout_path, '.git')))):
- if (os.path.isdir(self.checkout_path) and
- not os.path.exists(os.path.join(self.checkout_path, '.git'))):
- if options.force:
- # Delete and re-sync.
- print('_____ Conflicting directory found in %s. Removing.'
- % self.checkout_path)
- gclient_utils.rmtree(self.checkout_path)
- else:
- raise gclient_utils.Error('\n____ %s%s\n'
- '\tPath is not a git repo. No .git dir.\n'
- '\tTo resolve:\n'
- '\t\trm -rf %s\n'
- '\tAnd run gclient sync again\n'
- '\tOr run with --force\n'
- % (self.relpath, rev_str, self.relpath))
self._Clone(revision, url, options)
self.UpdateSubmoduleConfig()
if file_list is not None:
@@ -332,6 +317,14 @@
print ('________ unmanaged solution; skipping %s' % self.relpath)
return self._Capture(['rev-parse', '--verify', 'HEAD'])
+ if not os.path.exists(os.path.join(self.checkout_path, '.git')):
+ raise gclient_utils.Error('\n____ %s%s\n'
+ '\tPath is not a git repo. No .git dir.\n'
+ '\tTo resolve:\n'
+ '\t\trm -rf %s\n'
+ '\tAnd run gclient sync again\n'
+ % (self.relpath, rev_str, self.relpath))
+
# See if the url has changed (the unittests use git://foo for the url, let
# that through).
current_url = self._Capture(['config', 'remote.%s.url' % self.remote])
@@ -341,7 +334,7 @@
# Skip url auto-correction if remote.origin.gclient-auto-fix-url is set.
# This allows devs to use experimental repos which have a different url
# but whose branch(s) are the same as official repos.
- if (current_url.rstrip('/') != url.rstrip('/') and
+ if (current_url != url and
url != 'git://foo' and
subprocess2.capture(
['git', 'config', 'remote.%s.gclient-auto-fix-url' % self.remote],
@@ -1006,7 +999,12 @@
Raises:
Error: if can't get URL for relative path.
"""
- # Only update if hg is not controlling the directory.
+ # Only update if git or hg is not controlling the directory.
+ git_path = os.path.join(self.checkout_path, '.git')
+ if os.path.exists(git_path):
+ print('________ found .git directory; skipping %s' % self.relpath)
+ return
+
hg_path = os.path.join(self.checkout_path, '.hg')
if os.path.exists(hg_path):
print('________ found .hg directory; skipping %s' % self.relpath)
@@ -1037,26 +1035,14 @@
forced_revision = False
rev_str = ''
+ # Get the existing scm url and the revision number of the current checkout.
exists = os.path.exists(self.checkout_path)
- if exists and managed:
- # Git is only okay if it's a git-svn checkout of the right repo.
- if scm.GIT.IsGitSvn(self.checkout_path):
- remote_url = scm.GIT.Capture(['config', '--local', '--get',
- 'svn-remote.svn.url'],
- cwd=self.checkout_path).rstrip()
- if remote_url.rstrip('/') == base_url.rstrip('/'):
- print('\n_____ %s looks like a git-svn checkout. Skipping.'
- % self.relpath)
- return # TODO(borenet): Get the svn revision number?
-
- # Get the existing scm url and the revision number of the current checkout.
if exists and managed:
try:
from_info = scm.SVN.CaptureLocalInfo(
[], os.path.join(self.checkout_path, '.'))
except (gclient_utils.Error, subprocess2.CalledProcessError):
- if (options.force or
- (options.reset and options.delete_unversioned_trees)):
+ if options.reset and options.delete_unversioned_trees:
print 'Removing troublesome path %s' % self.checkout_path
gclient_utils.rmtree(self.checkout_path)
exists = False
@@ -1143,9 +1129,7 @@
if not managed:
print ('________ unmanaged solution; skipping %s' % self.relpath)
- if not scm.GIT.IsGitSvn(self.checkout_path):
- return self.Svnversion()
- return
+ return self.Svnversion()
if 'URL' not in from_info:
raise gclient_utils.Error(
@@ -1188,7 +1172,7 @@
revision = str(from_info_live['Revision'])
rev_str = ' at %s' % revision
- if from_info['URL'].rstrip('/') != base_url.rstrip('/'):
+ if from_info['URL'] != base_url:
# The repository url changed, need to switch.
try:
to_info = scm.SVN.CaptureRemoteInfo(url)
« no previous file with comments | « no previous file | scm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698