Commit 41e3a6c5 authored by agable's avatar agable Committed by Commit bot

Remove SVN support from gclient_utils and gclient_scm

This removes SVN support (most notably the SVNWrapper class, and the git-svn
logic in GitWrapper.GetUsableRev) from gclient_scm. It also removes some
references to SVN from comments in gclient_utils.

R=maruel@chromium.org
BUG=641588

Review-Url: https://chromiumcodereview.appspot.com/2393773003
parent bc0b4c6e
This diff is collapsed.
...@@ -179,9 +179,8 @@ def rmtree(path): ...@@ -179,9 +179,8 @@ def rmtree(path):
Recursively removes a directory, even if it's marked read-only. Recursively removes a directory, even if it's marked read-only.
shutil.rmtree() doesn't work on Windows if any of the files or directories shutil.rmtree() doesn't work on Windows if any of the files or directories
are read-only, which svn repositories and some .svn files are. We need to are read-only. We need to be able to force the files to be writable (i.e.,
be able to force the files to be writable (i.e., deletable) as we traverse deletable) as we traverse the tree.
the tree.
Even with all this, Windows still sometimes fails to delete a file, citing Even with all this, Windows still sometimes fails to delete a file, citing
a permission error (maybe something to do with antivirus scans or disk a permission error (maybe something to do with antivirus scans or disk
...@@ -494,8 +493,9 @@ def CheckCallAndFilter(args, stdout=None, filter_fn=None, ...@@ -494,8 +493,9 @@ def CheckCallAndFilter(args, stdout=None, filter_fn=None,
# Also, we need to forward stdout to prevent weird re-ordering of output. # Also, we need to forward stdout to prevent weird re-ordering of output.
# This has to be done on a per byte basis to make sure it is not buffered: # This has to be done on a per byte basis to make sure it is not buffered:
# normally buffering is done for each line, but if svn requests input, no # normally buffering is done for each line, but if the process requests
# end-of-line character is output after the prompt and it would not show up. # input, no end-of-line character is output after the prompt and it would
# not show up.
try: try:
in_byte = kid.stdout.read(1) in_byte = kid.stdout.read(1)
if in_byte: if in_byte:
...@@ -1060,7 +1060,7 @@ def GetEditor(git_editor=None): ...@@ -1060,7 +1060,7 @@ def GetEditor(git_editor=None):
"""Returns the most plausible editor to use. """Returns the most plausible editor to use.
In order of preference: In order of preference:
- GIT_EDITOR/SVN_EDITOR environment variable - GIT_EDITOR environment variable
- core.editor git configuration variable (if supplied by git-cl) - core.editor git configuration variable (if supplied by git-cl)
- VISUAL environment variable - VISUAL environment variable
- EDITOR environment variable - EDITOR environment variable
......
...@@ -67,24 +67,16 @@ class BaseTestCase(GCBaseTestCase, SuperMoxTestBase): ...@@ -67,24 +67,16 @@ class BaseTestCase(GCBaseTestCase, SuperMoxTestBase):
self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileRead') self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileRead')
self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileWrite') self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileWrite')
self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'rmtree') self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'rmtree')
self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'Capture')
self.mox.StubOutWithMock(gclient_scm.scm.SVN, '_CaptureInfo')
self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'CaptureStatus')
self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'RunAndGetFileList')
self.mox.StubOutWithMock(subprocess2, 'communicate') self.mox.StubOutWithMock(subprocess2, 'communicate')
self.mox.StubOutWithMock(subprocess2, 'Popen') self.mox.StubOutWithMock(subprocess2, 'Popen')
self._scm_wrapper = gclient_scm.CreateSCM self._scm_wrapper = gclient_scm.CreateSCM
gclient_scm.scm.SVN.current_version = None
self._original_SVNBinaryExists = gclient_scm.SVNWrapper.BinaryExists
self._original_GitBinaryExists = gclient_scm.GitWrapper.BinaryExists self._original_GitBinaryExists = gclient_scm.GitWrapper.BinaryExists
gclient_scm.SVNWrapper.BinaryExists = staticmethod(lambda : True)
gclient_scm.GitWrapper.BinaryExists = staticmethod(lambda : True) gclient_scm.GitWrapper.BinaryExists = staticmethod(lambda : True)
# Absolute path of the fake checkout directory. # Absolute path of the fake checkout directory.
self.base_path = join(self.root_dir, self.relpath) self.base_path = join(self.root_dir, self.relpath)
def tearDown(self): def tearDown(self):
SuperMoxTestBase.tearDown(self) SuperMoxTestBase.tearDown(self)
gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists
gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists
...@@ -123,7 +115,6 @@ class BaseGitWrapperTestCase(GCBaseTestCase, StdoutCheck, TestCaseUtils, ...@@ -123,7 +115,6 @@ class BaseGitWrapperTestCase(GCBaseTestCase, StdoutCheck, TestCaseUtils,
self.auto_rebase = False self.auto_rebase = False
self.verbose = verbose self.verbose = verbose
self.revision = revision self.revision = revision
self.manually_grab_svn_rev = True
self.deps_os = None self.deps_os = None
self.force = False self.force = False
self.reset = False self.reset = False
...@@ -249,9 +240,7 @@ from :3 ...@@ -249,9 +240,7 @@ from :3
self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path) self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path)
StdoutCheck.setUp(self) StdoutCheck.setUp(self)
self._original_GitBinaryExists = gclient_scm.GitWrapper.BinaryExists self._original_GitBinaryExists = gclient_scm.GitWrapper.BinaryExists
self._original_SVNBinaryExists = gclient_scm.SVNWrapper.BinaryExists
gclient_scm.GitWrapper.BinaryExists = staticmethod(lambda : True) gclient_scm.GitWrapper.BinaryExists = staticmethod(lambda : True)
gclient_scm.SVNWrapper.BinaryExists = staticmethod(lambda : True)
def tearDown(self): def tearDown(self):
try: try:
...@@ -262,7 +251,6 @@ from :3 ...@@ -262,7 +251,6 @@ from :3
finally: finally:
# TODO(maruel): Use auto_stub.TestCase. # TODO(maruel): Use auto_stub.TestCase.
gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists
gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists
class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): class ManagedGitWrapperTestCase(BaseGitWrapperTestCase):
...@@ -607,11 +595,15 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase): ...@@ -607,11 +595,15 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase):
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True)
gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1
).AndReturn(True) ).AndReturn(True)
gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev='1'
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) ).AndReturn(False)
gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev='1'
).AndReturn(False) ).AndReturn(False)
self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Fetch', True)
# pylint: disable=no-value-for-parameter
gclient_scm.GitWrapper._Fetch(options).AndReturn(None)
gclient_scm.scm.os.path.isdir(self.base_path).AndReturn(True) gclient_scm.scm.os.path.isdir(self.base_path).AndReturn(True)
gclient_scm.os.path.isdir(self.base_path).AndReturn(True) gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
...@@ -627,79 +619,6 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase): ...@@ -627,79 +619,6 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase):
self.assertRaises(gclient_scm.gclient_utils.Error, self.assertRaises(gclient_scm.gclient_utils.Error,
git_scm.GetUsableRev, '1', options) git_scm.GetUsableRev, '1', options)
def testGetUsableRevGitSvn(self):
# pylint: disable=E1101
options = self.Options()
too_big = str(1e7)
# Pretend like the git-svn repo's HEAD is at r2.
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'GetGitSvnHeadRev', True)
gclient_scm.scm.GIT.GetGitSvnHeadRev(cwd=self.base_path).MultipleTimes(
).AndReturn(2)
self.mox.StubOutWithMock(
gclient_scm.scm.GIT, 'GetBlessedSha1ForSvnRev', True)
# r1 -> first fake hash, r3 -> second fake hash.
gclient_scm.scm.GIT.GetBlessedSha1ForSvnRev(cwd=self.base_path, rev='1'
).AndReturn(self.fake_hash_1)
gclient_scm.scm.GIT.GetBlessedSha1ForSvnRev(cwd=self.base_path, rev='3'
).MultipleTimes().AndReturn(self.fake_hash_2)
# Ensure that we call git svn fetch if our LKGR is > the git-svn HEAD rev.
self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Fetch', True)
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture', True)
gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'],
cwd=self.base_path).AndReturn('blah')
# pylint: disable=E1120
gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path)
error = subprocess2.CalledProcessError(1, 'cmd', '/cwd', 'stdout', 'stderr')
gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'],
cwd=self.base_path).AndRaise(error)
gclient_scm.GitWrapper._Fetch(options)
gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path)
gclient_scm.GitWrapper._Fetch(options)
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes(
).AndReturn(True)
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True)
gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1
).AndReturn(True)
gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big
).MultipleTimes(2).AndReturn(False)
gclient_scm.os.path.isdir(self.base_path).AndReturn(False)
gclient_scm.os.path.isdir(self.base_path).MultipleTimes().AndReturn(True)
self.mox.ReplayAll()
git_svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
relpath=self.relpath)
# Without an existing checkout, this should fail.
# TODO(dbeam) Fix this. http://crbug.com/109184
self.assertRaises(gclient_scm.gclient_utils.Error,
git_svn_scm.GetUsableRev, '1', options)
# Given an SVN revision with a git-svn checkout, it should be translated to
# a git sha1 and be usable.
self.assertEquals(git_svn_scm.GetUsableRev('1', options),
self.fake_hash_1)
# Our fake HEAD rev is r2, so this should call git fetch and git svn fetch
# to get more revs (pymox will complain if this doesn't happen). We mock an
# optimized checkout the first time, so this run should call git fetch.
self.assertEquals(git_svn_scm.GetUsableRev('3', options),
self.fake_hash_2)
# The time we pretend we're not optimized, so no git fetch should fire.
self.assertEquals(git_svn_scm.GetUsableRev('3', options),
self.fake_hash_2)
# Given a git sha1 with a git-svn checkout, it should be used as is.
self.assertEquals(git_svn_scm.GetUsableRev(self.fake_hash_1, options),
self.fake_hash_1)
# We currently check for seemingly valid SVN revisions by assuming 6 digit
# numbers, so assure that numeric revs >= 1000000 don't work.
self.assertRaises(gclient_scm.gclient_utils.Error,
git_svn_scm.GetUsableRev, too_big, options)
def testUpdateNoDotGit(self): def testUpdateNoDotGit(self):
options = self.Options() options = self.Options()
......
...@@ -156,11 +156,7 @@ class GClientSmokeBase(fake_repos.FakeReposTestBase): ...@@ -156,11 +156,7 @@ class GClientSmokeBase(fake_repos.FakeReposTestBase):
class GClientSmoke(GClientSmokeBase): class GClientSmoke(GClientSmokeBase):
"""Doesn't require either svnserve nor git-daemon.""" """Doesn't require git-daemon."""
@property
def svn_base(self):
return 'svn://random.server/svn/'
@property @property
def git_base(self): def git_base(self):
return 'git://random.server/git/' return 'git://random.server/git/'
...@@ -203,10 +199,10 @@ class GClientSmoke(GClientSmokeBase): ...@@ -203,10 +199,10 @@ class GClientSmoke(GClientSmokeBase):
self.check(('', '', 0), results) self.check(('', '', 0), results)
self.checkString(expected, open(p, 'rU').read()) self.checkString(expected, open(p, 'rU').read())
test(['config', self.svn_base + 'trunk/src/'], test(['config', self.git_base + 'src/'],
('solutions = [\n' ('solutions = [\n'
' { "name" : "src",\n' ' { "name" : "src",\n'
' "url" : "%strunk/src",\n' ' "url" : "%ssrc",\n'
' "deps_file" : "DEPS",\n' ' "deps_file" : "DEPS",\n'
' "managed" : True,\n' ' "managed" : True,\n'
' "custom_deps" : {\n' ' "custom_deps" : {\n'
...@@ -214,7 +210,7 @@ class GClientSmoke(GClientSmokeBase): ...@@ -214,7 +210,7 @@ class GClientSmoke(GClientSmokeBase):
' "safesync_url": "",\n' ' "safesync_url": "",\n'
' },\n' ' },\n'
']\n' ']\n'
'cache_dir = None\n') % self.svn_base) 'cache_dir = None\n') % self.git_base)
test(['config', self.git_base + 'repo_1', '--name', 'src'], test(['config', self.git_base + 'repo_1', '--name', 'src'],
('solutions = [\n' ('solutions = [\n'
...@@ -287,14 +283,19 @@ class GClientSmoke(GClientSmokeBase): ...@@ -287,14 +283,19 @@ class GClientSmoke(GClientSmokeBase):
def testDifferentTopLevelDirectory(self): def testDifferentTopLevelDirectory(self):
# Check that even if the .gclient file does not mention the directory src # Check that even if the .gclient file does not mention the directory src
# itself, but it is included via dependencies, the .gclient file is used. # itself, but it is included via dependencies, the .gclient file is used.
self.gclient(['config', self.svn_base + 'trunk/src.DEPS']) self.gclient(['config', self.git_base + 'src.DEPS'])
deps = join(self.root_dir, 'src.DEPS') deps = join(self.root_dir, 'src.DEPS')
os.mkdir(deps) os.mkdir(deps)
subprocess2.check_output(['git', 'init'], cwd=deps)
write(join(deps, 'DEPS'), write(join(deps, 'DEPS'),
'deps = { "src": "%strunk/src" }' % (self.svn_base)) 'deps = { "src": "%ssrc" }' % (self.git_base))
subprocess2.check_output(['git', 'add', 'DEPS'], cwd=deps)
subprocess2.check_output(
['git', 'commit', '-a', '-m', 'DEPS file'], cwd=deps)
src = join(self.root_dir, 'src') src = join(self.root_dir, 'src')
os.mkdir(src) os.mkdir(src)
res = self.gclient(['status', '--jobs', '1'], src) subprocess2.check_output(['git', 'init'], cwd=src)
res = self.gclient(['status', '--jobs', '1', '-v'], src)
self.checkBlock(res[0], [('running', deps), ('running', src)]) self.checkBlock(res[0], [('running', deps), ('running', src)])
......
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