Commit 885d6e89 authored by maruel@chromium.org's avatar maruel@chromium.org

Fix scm.SVN.GetCheckoutRoot() so it is not confused by intermixed checkouts

from the same repository.

TEST=added regression test.
BUG=none

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@75937 0039d316-1c4b-4281-b951-d872f2087c98
parent 31f10a86
......@@ -806,14 +806,19 @@ class SVN(object):
"""
directory = os.path.abspath(directory)
try:
cur_dir_repo_root = SVN.CaptureInfo(directory)['Repository Root']
info = SVN.CaptureInfo(directory)
cur_dir_repo_root = info['Repository Root']
url = info['URL']
except gclient_utils.Error:
return None
while True:
parent = os.path.dirname(directory)
try:
if SVN.CaptureInfo(parent)['Repository Root'] != cur_dir_repo_root:
info = SVN.CaptureInfo(parent)
if (info['Repository Root'] != cur_dir_repo_root or
info['URL'] != os.path.dirname(url)):
break
url = info['URL']
except gclient_utils.Error:
break
directory = parent
......
......@@ -85,16 +85,23 @@ class SVNTestCase(BaseSCMTestCase):
def testGetCheckoutRoot(self):
self.mox.StubOutWithMock(scm.SVN, 'CaptureInfo')
self.mox.StubOutWithMock(scm, 'GetCasedPath')
scm.os.path.abspath(self.root_dir + 'x').AndReturn(self.root_dir)
scm.GetCasedPath(self.root_dir).AndReturn(self.root_dir)
result1 = { "Repository Root": "Some root" }
scm.SVN.CaptureInfo(self.root_dir).AndReturn(result1)
results2 = { "Repository Root": "A different root" }
scm.SVN.CaptureInfo(
scm.os.path.dirname(self.root_dir)).AndReturn(results2)
scm.os.path.abspath = lambda x: x
scm.GetCasedPath = lambda x: x
scm.SVN.CaptureInfo(self.root_dir + '/foo/bar').AndReturn({
'Repository Root': 'svn://svn.chromium.org/chrome',
'URL': 'svn://svn.chromium.org/chrome/trunk/src',
})
scm.SVN.CaptureInfo(self.root_dir + '/foo').AndReturn({
'Repository Root': 'svn://svn.chromium.org/chrome',
'URL': 'svn://svn.chromium.org/chrome/trunk',
})
scm.SVN.CaptureInfo(self.root_dir).AndReturn({
'Repository Root': 'svn://svn.chromium.org/chrome',
'URL': 'svn://svn.chromium.org/chrome/trunk/tools/commit-queue/workdir',
})
self.mox.ReplayAll()
self.assertEquals(scm.SVN.GetCheckoutRoot(self.root_dir + 'x'),
self.root_dir)
self.assertEquals(scm.SVN.GetCheckoutRoot(self.root_dir + '/foo/bar'),
self.root_dir + '/foo')
def testGetFileInfo(self):
xml_text = r"""<?xml version="1.0"?>
......
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