Commit 8b322b3c authored by maruel@chromium.org's avatar maruel@chromium.org

Handle cases where '.' show up in svn status and is deleted

This would cause random try job failures, especially when switching around
DEPS <-> svn directory conversion.

R=dpranke@chromium.org
BUG=
TEST=


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@108144 0039d316-1c4b-4281-b951-d872f2087c98
parent f639e633
...@@ -954,6 +954,11 @@ class SVNWrapper(SCMWrapper): ...@@ -954,6 +954,11 @@ class SVNWrapper(SCMWrapper):
print(os.path.join(self.checkout_path, file_status[1])) print(os.path.join(self.checkout_path, file_status[1]))
scm.SVN.Revert(self.checkout_path, callback=printcb) scm.SVN.Revert(self.checkout_path, callback=printcb)
# Revert() may delete the directory altogether.
if not os.path.isdir(self.checkout_path):
# Don't reuse the args.
return self.update(options, [], file_list)
try: try:
# svn revert is so broken we don't even use it. Using # svn revert is so broken we don't even use it. Using
# "svn up --revision BASE" achieve the same effect. # "svn up --revision BASE" achieve the same effect.
......
...@@ -985,6 +985,9 @@ class SVN(object): ...@@ -985,6 +985,9 @@ class SVN(object):
not file_status[0][1:].isspace()): not file_status[0][1:].isspace()):
# Added, deleted file requires manual intervention and require calling # Added, deleted file requires manual intervention and require calling
# revert, like for properties. # revert, like for properties.
if not os.path.isdir(repo_root):
# '.' was deleted. It's not worth continuing.
return
try: try:
SVN.Capture(['revert', file_status[1]], cwd=repo_root) SVN.Capture(['revert', file_status[1]], cwd=repo_root)
except subprocess2.CalledProcessError: except subprocess2.CalledProcessError:
......
...@@ -196,6 +196,7 @@ class SVNWrapperTestCase(BaseTestCase): ...@@ -196,6 +196,7 @@ class SVNWrapperTestCase(BaseTestCase):
gclient_scm.os.path.isdir(self.base_path).AndReturn(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.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True)
gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn([]) gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn([])
gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
gclient_scm.scm.SVN.RunAndGetFileList( gclient_scm.scm.SVN.RunAndGetFileList(
options.verbose, options.verbose,
['update', '--revision', 'BASE', '--ignore-externals'], ['update', '--revision', 'BASE', '--ignore-externals'],
...@@ -222,6 +223,7 @@ class SVNWrapperTestCase(BaseTestCase): ...@@ -222,6 +223,7 @@ class SVNWrapperTestCase(BaseTestCase):
gclient_scm.os.path.islink(file_path).AndReturn(False) gclient_scm.os.path.islink(file_path).AndReturn(False)
gclient_scm.os.path.isdir(file_path).AndReturn(True) gclient_scm.os.path.isdir(file_path).AndReturn(True)
gclient_scm.gclient_utils.RemoveDirectory(file_path) gclient_scm.gclient_utils.RemoveDirectory(file_path)
gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
gclient_scm.scm.SVN.RunAndGetFileList( gclient_scm.scm.SVN.RunAndGetFileList(
options.verbose, options.verbose,
['update', '--revision', 'BASE', '--ignore-externals'], ['update', '--revision', 'BASE', '--ignore-externals'],
...@@ -235,6 +237,33 @@ class SVNWrapperTestCase(BaseTestCase): ...@@ -235,6 +237,33 @@ class SVNWrapperTestCase(BaseTestCase):
scm.revert(options, self.args, file_list2) scm.revert(options, self.args, file_list2)
self.checkstdout(('%s\n' % file_path)) self.checkstdout(('%s\n' % file_path))
def testRevertDot(self):
self.mox.StubOutWithMock(gclient_scm.SVNWrapper, 'update')
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 = [
('~ ', '.'),
]
gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn(items)
file_path = join(self.base_path, '.')
gclient_scm.os.path.exists(file_path).AndReturn(True)
gclient_scm.os.path.isfile(file_path).AndReturn(False)
gclient_scm.os.path.islink(file_path).AndReturn(False)
gclient_scm.os.path.isdir(file_path).AndReturn(True)
gclient_scm.gclient_utils.RemoveDirectory(file_path)
gclient_scm.os.path.isdir(self.base_path).AndReturn(False)
# The mock is unbound so self is not necessary.
# pylint: disable=E1120
gclient_scm.SVNWrapper.update(options, [], ['.'])
self.mox.ReplayAll()
scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
relpath=self.relpath)
file_list2 = []
scm.revert(options, self.args, file_list2)
self.checkstdout(('%s\n' % file_path))
def testStatus(self): def testStatus(self):
options = self.Options(verbose=True) options = self.Options(verbose=True)
gclient_scm.os.path.isdir(self.base_path).AndReturn(True) gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
......
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