Make revert more resilient to partial sync failure.

Improve revert to skip over non managed directory and to clobber invalid
checkouts.

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8227033

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@105103 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
maruel@chromium.org 14 years ago
parent 36ac239bd3
commit c0cc0871b4

@ -920,12 +920,30 @@ class SVNWrapper(SCMWrapper):
doesn't know about them.
"""
if not os.path.isdir(self.checkout_path):
if os.path.exists(self.checkout_path):
gclient_utils.rmtree(self.checkout_path)
# svn revert won't work if the directory doesn't exist. It needs to
# checkout instead.
print('\n_____ %s is missing, synching instead' % self.relpath)
# Don't reuse the args.
return self.update(options, [], file_list)
if not os.path.isdir(os.path.join(self.checkout_path, '.svn')):
if os.path.isdir(os.path.join(self.checkout_path, '.git')):
print('________ found .git directory; skipping %s' % self.relpath)
return
if os.path.isdir(os.path.join(self.checkout_path, '.hg')):
print('________ found .hg directory; skipping %s' % self.relpath)
return
if not options.force:
raise gclient_utils.Error('Invalid checkout path, aborting')
print(
'\n_____ %s is not a valid svn checkout, synching instead' %
self.relpath)
gclient_utils.rmtree(self.checkout_path)
# Don't reuse the args.
return self.update(options, [], file_list)
def printcb(file_status):
file_list.append(file_status[1])
if logging.getLogger().isEnabledFor(logging.INFO):

@ -65,12 +65,12 @@ class BaseTestCase(GCBaseTestCase, SuperMoxTestBase):
class SVNWrapperTestCase(BaseTestCase):
class OptionsObject(object):
def __init__(self, verbose=False, revision=None):
def __init__(self, verbose=False, revision=None, force=False):
self.verbose = verbose
self.revision = revision
self.manually_grab_svn_rev = True
self.deps_os = None
self.force = False
self.force = force
self.reset = False
self.nohooks = False
# TODO(maruel): Test --jobs > 1.
@ -134,6 +134,7 @@ class SVNWrapperTestCase(BaseTestCase):
def testRevertMissing(self):
options = self.Options(verbose=True)
gclient_scm.os.path.isdir(self.base_path).AndReturn(False)
gclient_scm.os.path.exists(self.base_path).AndReturn(False)
gclient_scm.scm.SVN.Capture(['--version']
).AndReturn('svn, version 1.5.1 (r32289)')
# It'll to a checkout instead.
@ -155,9 +156,37 @@ class SVNWrapperTestCase(BaseTestCase):
self.checkstdout(
('\n_____ %s is missing, synching instead\n' % self.relpath))
def testRevertNoDotSvn(self):
options = self.Options(verbose=True, force=True)
gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(False)
gclient_scm.os.path.isdir(join(self.base_path, '.git')).AndReturn(False)
gclient_scm.os.path.isdir(join(self.base_path, '.hg')).AndReturn(False)
# Checkout.
gclient_scm.os.path.exists(self.base_path).AndReturn(False)
gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
gclient_scm.os.path.exists(self.base_path).AndReturn(False)
files_list = self.mox.CreateMockAnything()
gclient_scm.scm.SVN.Capture(['--version']).AndReturn('svn, version 1.6')
gclient_scm.scm.SVN.RunAndGetFileList(
options.verbose,
['checkout', self.url, self.base_path, '--force', '--ignore-externals'],
cwd=self.root_dir,
file_list=files_list)
self.mox.ReplayAll()
scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
relpath=self.relpath)
scm.revert(options, self.args, files_list)
self.checkstdout(
'\n_____ %s is not a valid svn checkout, synching instead\n' %
self.relpath)
def testRevertNone(self):
options = self.Options(verbose=True)
gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True)
gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn([])
gclient_scm.scm.SVN.RunAndGetFileList(
options.verbose,
@ -174,6 +203,7 @@ class SVNWrapperTestCase(BaseTestCase):
def testRevertDirectory(self):
options = self.Options(verbose=True)
gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True)
items = [
('~ ', 'a'),
]

Loading…
Cancel
Save