Remove more unversioned directories.

Currently, if an unversioned directory is present where we would expect
a versioned repository to be, the following error is printed:

  Can't update/checkout %s if an unversioned directory is present.
  Delete the directory and try again.

If --reset and --delete_unversioned_trees are used, gclient should delete
the unversioned directory in this case.

This problem can be reproduced using the following recipe:
  $ rm -rf src/third_party/webrtc/.svn
  $ gclient sync -nRftD

BUG=none
TEST=Verify that above error is fixed. Run all smoke tests.


Review URL: https://chromiumcodereview.appspot.com/11366239

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@167942 0039d316-1c4b-4281-b951-d872f2087c98
parent b299e7c2
...@@ -929,7 +929,23 @@ class SVNWrapper(SCMWrapper): ...@@ -929,7 +929,23 @@ class SVNWrapper(SCMWrapper):
forced_revision = False forced_revision = False
rev_str = '' rev_str = ''
if not os.path.exists(self.checkout_path): # Get the existing scm url and the revision number of the current checkout.
exists = os.path.exists(self.checkout_path)
if exists and managed:
try:
from_info = scm.SVN.CaptureLocalInfo(
[], os.path.join(self.checkout_path, '.'))
except (gclient_utils.Error, subprocess2.CalledProcessError):
if options.reset and options.delete_unversioned_trees:
print 'Removing troublesome path %s' % self.checkout_path
gclient_utils.rmtree(self.checkout_path)
exists = False
else:
msg = ('Can\'t update/checkout %s if an unversioned directory is '
'present. Delete the directory and try again.')
raise gclient_utils.Error(msg % self.checkout_path)
if not exists:
gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path)) gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path))
# We need to checkout. # We need to checkout.
command = ['checkout', url, self.checkout_path] command = ['checkout', url, self.checkout_path]
...@@ -941,15 +957,6 @@ class SVNWrapper(SCMWrapper): ...@@ -941,15 +957,6 @@ class SVNWrapper(SCMWrapper):
print ('________ unmanaged solution; skipping %s' % self.relpath) print ('________ unmanaged solution; skipping %s' % self.relpath)
return return
# Get the existing scm url and the revision number of the current checkout.
try:
from_info = scm.SVN.CaptureLocalInfo(
[], os.path.join(self.checkout_path, '.'))
except (gclient_utils.Error, subprocess2.CalledProcessError):
raise gclient_utils.Error(
('Can\'t update/checkout %s if an unversioned directory is present. '
'Delete the directory and try again.') % self.checkout_path)
if 'URL' not in from_info: if 'URL' not in from_info:
raise gclient_utils.Error( raise gclient_utils.Error(
('gclient is confused. Couldn\'t get the url for %s.\n' ('gclient is confused. Couldn\'t get the url for %s.\n'
......
...@@ -21,6 +21,7 @@ ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ...@@ -21,6 +21,7 @@ ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, ROOT_DIR) sys.path.insert(0, ROOT_DIR)
from testing_support.fake_repos import join, write, FakeReposTestBase from testing_support.fake_repos import join, write, FakeReposTestBase
import gclient_utils
import subprocess2 import subprocess2
...@@ -784,6 +785,21 @@ class GClientSmokeSVN(GClientSmokeBase): ...@@ -784,6 +785,21 @@ class GClientSmokeSVN(GClientSmokeBase):
self.checkBlock(res[0], self.checkBlock(res[0],
['running', 'running', 'running']) ['running', 'running', 'running'])
def testUnversionedRepository(self):
# Check that gclient automatically deletes crippled SVN repositories.
if not self.enabled:
return
self.gclient(['config', self.svn_base + 'trunk/src/'])
cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset']
self.assertEquals(0, self.gclient(cmd)[-1])
third_party = join(self.root_dir, 'src', 'third_party')
subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'],
cwd=third_party)
# Cripple src/third_party/foo and make sure gclient still succeeds.
gclient_utils.rmtree(join(third_party, 'foo', '.svn'))
self.assertEquals(0, self.gclient(cmd)[-1])
class GClientSmokeGIT(GClientSmokeBase): class GClientSmokeGIT(GClientSmokeBase):
def setUp(self): def setUp(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment