Commit fc83c11b authored by maruel@chromium.org's avatar maruel@chromium.org

Remove gcl.WriteFile

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@34949 0039d316-1c4b-4281-b951-d872f2087c98
parent f5a1163b
......@@ -139,7 +139,7 @@ def GetCachedFile(filename, max_age=60*60*24*3, use_root=False):
url_path = os.path.dirname(url_path)
# Write a cached version even if there isn't a file, so we don't try to
# fetch it each time.
WriteFile(cached_file, content)
gclient_utils.FileWrite(cached_file, content)
else:
content = ReadFile(cached_file)
# Keep the content cached in memory.
......@@ -213,13 +213,6 @@ def ReadFile(filename, flags='r'):
return result
def WriteFile(filename, contents):
"""Overwrites the file with the given contents."""
f = open(filename, 'w')
f.write(contents)
f.close()
def FilterFlag(args, flag):
"""Returns True if the flag is present in args list.
......@@ -306,7 +299,7 @@ class ChangeInfo(object):
"%d, %d, %s" % (self.issue, self.patchset, needs_upload),
"\n".join([f[0] + f[1] for f in self.GetFiles()]),
self.description])
WriteFile(GetChangelistInfoFile(self.name), data)
gclient_utils.FileWrite(GetChangelistInfoFile(self.name), data)
def Delete(self):
"""Removes the changelist information from disk."""
......
......@@ -19,9 +19,8 @@ class GclTestsBase(SuperMoxTestBase):
self.mox.StubOutWithMock(gcl.SVN, 'CaptureInfo')
self.mox.StubOutWithMock(gcl, 'tempfile')
self.mox.StubOutWithMock(gcl.upload, 'RealMain')
# These are not tested.
self.mox.StubOutWithMock(gcl, 'ReadFile')
self.mox.StubOutWithMock(gcl, 'WriteFile')
self.mox.StubOutWithMock(gcl.gclient_utils, 'FileWrite')
class GclUnittest(GclTestsBase):
......@@ -41,7 +40,6 @@ class GclUnittest(GclTestsBase):
'OptionallyDoPresubmitChecks', 'PresubmitCL', 'REPOSITORY_ROOT',
'ReadFile', 'RunShell', 'RunShellWithReturnCode', 'SVN',
'SendToRietveld', 'TryChange', 'UnknownFiles', 'UploadCL', 'Warn',
'WriteFile',
'breakpad', 'gclient_utils', 'getpass', 'main', 'os', 'random', 're',
'shutil', 'string', 'subprocess', 'sys', 'tempfile', 'upload',
'urllib2',
......@@ -215,8 +213,9 @@ class ChangeInfoUnittest(GclTestsBase):
def testSaveEmpty(self):
gcl.GetChangelistInfoFile('').AndReturn('foo')
gcl.WriteFile('foo', gcl.ChangeInfo._SEPARATOR.join(['0, 0, clean', '',
'']))
gcl.gclient_utils.FileWrite(
'foo',
gcl.ChangeInfo._SEPARATOR.join(['0, 0, clean', '', '']))
self.mox.ReplayAll()
change_info = gcl.ChangeInfo('', 0, 0, '', None, self.fake_root_dir)
......@@ -224,8 +223,9 @@ class ChangeInfoUnittest(GclTestsBase):
def testSaveDirty(self):
gcl.GetChangelistInfoFile('').AndReturn('foo')
gcl.WriteFile('foo', gcl.ChangeInfo._SEPARATOR.join(['0, 0, dirty', '',
'']))
gcl.gclient_utils.FileWrite(
'foo',
gcl.ChangeInfo._SEPARATOR.join(['0, 0, dirty', '', '']))
self.mox.ReplayAll()
change_info = gcl.ChangeInfo('', 0, 0, '', None, self.fake_root_dir,
......
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