Commit 5f3eee3b authored by maruel@chromium.org's avatar maruel@chromium.org

gclient: remove wildcard import from git_scm

Part of a larger refactoring to abstract SCM-specific bits.

presubmit_support, revert, gcl: modify to import gclient_scm and gclient_utils

Part of a larger refactoring to abstract SCM-specific bits.

revert, gcl: modify to import gclient_scm and gclient_utils

Part of a larger refactoring to abstract SCM-specific bits.

gclient: pull out SCM bits

Pulled out SCMWrapper into gcliet_scm.py as part of a larger refactoring to
abstract SCM-specific bits. Plan is to evenutally add git support.

Pulling out SCMWrapper also required pulling out utility functions into
a gclient_utility.py.

Patch contributed by msb@

TEST=none
BUG=none


git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@26423 0039d316-1c4b-4281-b951-d872f2087c98
parent 6df3334c
......@@ -20,7 +20,8 @@ import urllib2
import xml.dom.minidom
# gcl now depends on gclient.
import gclient
import gclient_scm
import gclient_utils
__version__ = '1.1.1'
......@@ -50,7 +51,7 @@ FILES_CACHE = {}
def IsSVNMoved(filename):
"""Determine if a file has been added through svn mv"""
info = gclient.CaptureSVNInfo(filename)
info = gclient_scm.CaptureSVNInfo(filename)
return (info.get('Copied From URL') and
info.get('Copied From Rev') and
info.get('Schedule') == 'add')
......@@ -82,7 +83,7 @@ def UnknownFiles(extra_args):
Any args in |extra_args| are passed to the tool to support giving alternate
code locations.
"""
return [item[1] for item in gclient.CaptureSVNStatus(extra_args)
return [item[1] for item in gclient_scm.CaptureSVNStatus(extra_args)
if item[0][0] == '?']
......@@ -93,15 +94,15 @@ def GetRepositoryRoot():
"""
global REPOSITORY_ROOT
if not REPOSITORY_ROOT:
infos = gclient.CaptureSVNInfo(os.getcwd(), print_error=False)
infos = gclient_scm.CaptureSVNInfo(os.getcwd(), print_error=False)
cur_dir_repo_root = infos.get("Repository Root")
if not cur_dir_repo_root:
raise gclient.Error("gcl run outside of repository")
raise gclient_utils.Error("gcl run outside of repository")
REPOSITORY_ROOT = os.getcwd()
while True:
parent = os.path.dirname(REPOSITORY_ROOT)
if (gclient.CaptureSVNInfo(parent, print_error=False).get(
if (gclient_scm.CaptureSVNInfo(parent, print_error=False).get(
"Repository Root") != cur_dir_repo_root):
break
REPOSITORY_ROOT = parent
......@@ -140,11 +141,11 @@ def GetCachedFile(filename, max_age=60*60*24*3, use_root=False):
# First we check if we have a cached version.
try:
cached_file = os.path.join(GetCacheDir(), filename)
except gclient.Error:
except gclient_utils.Error:
return None
if (not os.path.exists(cached_file) or
os.stat(cached_file).st_mtime > max_age):
dir_info = gclient.CaptureSVNInfo(".")
dir_info = gclient_scm.CaptureSVNInfo(".")
repo_root = dir_info["Repository Root"]
if use_root:
url_path = repo_root
......@@ -461,7 +462,7 @@ class ChangeInfo(object):
if update_status:
for file in files:
filename = os.path.join(local_root, file[1])
status_result = gclient.CaptureSVNStatus(filename)
status_result = gclient_scm.CaptureSVNStatus(filename)
if not status_result or not status_result[0][0]:
# File has been reverted.
save = True
......@@ -545,7 +546,7 @@ def GetModifiedFiles():
files_in_cl[filename] = change_info.name
# Get all the modified files.
status_result = gclient.CaptureSVNStatus(None)
status_result = gclient_scm.CaptureSVNStatus(None)
for line in status_result:
status = line[0]
filename = line[1]
......@@ -724,7 +725,8 @@ def GenerateDiff(files, root=None):
for file in files:
# Use svn info output instead of os.path.isdir because the latter fails
# when the file is deleted.
if gclient.CaptureSVNInfo(file).get("Node Kind") in ("dir", "directory"):
if gclient_scm.CaptureSVNInfo(file).get("Node Kind") in ("dir",
"directory"):
continue
# If the user specified a custom diff command in their svn config file,
# then it'll be used when we do svn diff, which we don't want to happen
......@@ -1149,7 +1151,7 @@ def main(argv=None):
shutil.move(file_path, GetChangesDir())
if not os.path.exists(GetCacheDir()):
os.mkdir(GetCacheDir())
except gclient.Error:
except gclient_utils.Error:
# Will throw an exception if not run in a svn checkout.
pass
......
This diff is collapsed.
This diff is collapsed.
# Copyright 2009 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import subprocess
import sys
import xml.dom.minidom
## Generic utils
def ParseXML(output):
try:
return xml.dom.minidom.parseString(output)
except xml.parsers.expat.ExpatError:
return None
def GetNamedNodeText(node, node_name):
child_nodes = node.getElementsByTagName(node_name)
if not child_nodes:
return None
assert len(child_nodes) == 1 and child_nodes[0].childNodes.length == 1
return child_nodes[0].firstChild.nodeValue
def GetNodeNamedAttributeText(node, node_name, attribute_name):
child_nodes = node.getElementsByTagName(node_name)
if not child_nodes:
return None
assert len(child_nodes) == 1
return child_nodes[0].getAttribute(attribute_name)
class Error(Exception):
"""gclient exception class."""
pass
class PrintableObject(object):
def __str__(self):
output = ''
for i in dir(self):
if i.startswith('__'):
continue
output += '%s = %s\n' % (i, str(getattr(self, i, '')))
return output
def FileRead(filename):
content = None
f = open(filename, "rU")
try:
content = f.read()
finally:
f.close()
return content
def FileWrite(filename, content):
f = open(filename, "w")
try:
f.write(content)
finally:
f.close()
def RemoveDirectory(*path):
"""Recursively removes a directory, even if it's marked read-only.
Remove the directory located at *path, if it exists.
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
be able to force the files to be writable (i.e., deletable) as we traverse
the tree.
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
indexing). The best suggestion any of the user forums had was to wait a
bit and try again, so we do that too. It's hand-waving, but sometimes it
works. :/
On POSIX systems, things are a little bit simpler. The modes of the files
to be deleted doesn't matter, only the modes of the directories containing
them are significant. As the directory tree is traversed, each directory
has its mode set appropriately before descending into it. This should
result in the entire tree being removed, with the possible exception of
*path itself, because nothing attempts to change the mode of its parent.
Doing so would be hazardous, as it's not a directory slated for removal.
In the ordinary case, this is not a problem: for our purposes, the user
will never lack write permission on *path's parent.
"""
file_path = os.path.join(*path)
if not os.path.exists(file_path):
return
if os.path.islink(file_path) or not os.path.isdir(file_path):
raise Error("RemoveDirectory asked to remove non-directory %s" % file_path)
has_win32api = False
if sys.platform == 'win32':
has_win32api = True
# Some people don't have the APIs installed. In that case we'll do without.
try:
win32api = __import__('win32api')
win32con = __import__('win32con')
except ImportError:
has_win32api = False
else:
# On POSIX systems, we need the x-bit set on the directory to access it,
# the r-bit to see its contents, and the w-bit to remove files from it.
# The actual modes of the files within the directory is irrelevant.
os.chmod(file_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
for fn in os.listdir(file_path):
fullpath = os.path.join(file_path, fn)
# If fullpath is a symbolic link that points to a directory, isdir will
# be True, but we don't want to descend into that as a directory, we just
# want to remove the link. Check islink and treat links as ordinary files
# would be treated regardless of what they reference.
if os.path.islink(fullpath) or not os.path.isdir(fullpath):
if sys.platform == 'win32':
os.chmod(fullpath, stat.S_IWRITE)
if has_win32api:
win32api.SetFileAttributes(fullpath, win32con.FILE_ATTRIBUTE_NORMAL)
try:
os.remove(fullpath)
except OSError, e:
if e.errno != errno.EACCES or sys.platform != 'win32':
raise
print 'Failed to delete %s: trying again' % fullpath
time.sleep(0.1)
os.remove(fullpath)
else:
RemoveDirectory(fullpath)
if sys.platform == 'win32':
os.chmod(file_path, stat.S_IWRITE)
if has_win32api:
win32api.SetFileAttributes(file_path, win32con.FILE_ATTRIBUTE_NORMAL)
try:
os.rmdir(file_path)
except OSError, e:
if e.errno != errno.EACCES or sys.platform != 'win32':
raise
print 'Failed to remove %s: trying again' % file_path
time.sleep(0.1)
os.rmdir(file_path)
def SubprocessCall(command, in_directory, fail_status=None):
"""Runs command, a list, in directory in_directory.
This function wraps SubprocessCallAndFilter, but does not perform the
filtering functions. See that function for a more complete usage
description.
"""
# Call subprocess and capture nothing:
SubprocessCallAndFilter(command, in_directory, True, True, fail_status)
def SubprocessCallAndFilter(command,
in_directory,
print_messages,
print_stdout,
fail_status=None, filter=None):
"""Runs command, a list, in directory in_directory.
If print_messages is true, a message indicating what is being done
is printed to stdout. If print_stdout is true, the command's stdout
is also forwarded to stdout.
If a filter function is specified, it is expected to take a single
string argument, and it will be called with each line of the
subprocess's output. Each line has had the trailing newline character
trimmed.
If the command fails, as indicated by a nonzero exit status, gclient will
exit with an exit status of fail_status. If fail_status is None (the
default), gclient will raise an Error exception.
"""
if print_messages:
print("\n________ running \'%s\' in \'%s\'"
% (' '.join(command), in_directory))
# *Sigh*: Windows needs shell=True, or else it won't search %PATH% for the
# executable, but shell=True makes subprocess on Linux fail when it's called
# with a list because it only tries to execute the first item in the list.
kid = subprocess.Popen(command, bufsize=0, cwd=in_directory,
shell=(sys.platform == 'win32'), stdout=subprocess.PIPE)
# 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:
# normally buffering is done for each line, but if svn requests input, no
# end-of-line character is output after the prompt and it would not show up.
in_byte = kid.stdout.read(1)
in_line = ""
while in_byte:
if in_byte != "\r":
if print_stdout:
sys.stdout.write(in_byte)
if in_byte != "\n":
in_line += in_byte
if in_byte == "\n" and filter:
filter(in_line)
in_line = ""
in_byte = kid.stdout.read(1)
rv = kid.wait()
if rv:
msg = "failed to run command: %s" % " ".join(command)
if fail_status != None:
print >>sys.stderr, msg
sys.exit(fail_status)
raise Error(msg)
def IsUsingGit(root, paths):
"""Returns True if we're using git to manage any of our checkouts.
|entries| is a list of paths to check."""
for path in paths:
if os.path.exists(os.path.join(root, path, '.git')):
return True
return False
......@@ -38,7 +38,7 @@ import warnings
# TODO(joi) Would be cleaner to factor out utils in gcl to separate module, but
# for now it would only be a couple of functions so hardly worth it.
import gcl
import gclient
import gclient_scm
import presubmit_canned_checks
......@@ -238,7 +238,7 @@ class InputApi(object):
Remember to check for the None case and show an appropriate error!
"""
local_path = gclient.CaptureSVNInfo(depot_path).get('Path')
local_path = gclient_scm.CaptureSVNInfo(depot_path).get('Path')
if local_path:
return local_path
......@@ -251,7 +251,7 @@ class InputApi(object):
Returns:
The depot path (SVN URL) of the file if mapped, otherwise None.
"""
depot_path = gclient.CaptureSVNInfo(local_path).get('URL')
depot_path = gclient_scm.CaptureSVNInfo(local_path).get('URL')
if depot_path:
return depot_path
......@@ -461,7 +461,7 @@ class SvnAffectedFile(AffectedFile):
def ServerPath(self):
if self._server_path is None:
self._server_path = gclient.CaptureSVNInfo(
self._server_path = gclient_scm.CaptureSVNInfo(
self.AbsoluteLocalPath()).get('URL', '')
return self._server_path
......@@ -473,7 +473,7 @@ class SvnAffectedFile(AffectedFile):
# querying subversion, especially on Windows.
self._is_directory = os.path.isdir(path)
else:
self._is_directory = gclient.CaptureSVNInfo(
self._is_directory = gclient_scm.CaptureSVNInfo(
path).get('Node Kind') in ('dir', 'directory')
return self._is_directory
......@@ -947,7 +947,7 @@ def Main(argv):
options.files = ParseFiles(args, options.recursive)
else:
# Grab modified files.
files = gclient.CaptureSVNStatus([options.root])
files = gclient_scm.CaptureSVNStatus([options.root])
else:
# Doesn't seem under source control.
change_class = Change
......
......@@ -13,6 +13,8 @@ import xml
import gcl
import gclient
import gclient_scm
import gclient_utils
class ModifiedFile(exceptions.Exception):
pass
......@@ -32,7 +34,7 @@ def UniqueFast(list):
def GetRepoBase():
"""Returns the repository base of the root local checkout."""
info = gclient.CaptureSVNInfo('.')
info = gclient_scm.CaptureSVNInfo('.')
root = info['Repository Root']
url = info['URL']
if not root or not url:
......@@ -46,8 +48,8 @@ def CaptureSVNLog(args):
command = ['log', '--xml']
if args:
command += args
output = gclient.CaptureSVN(command)
dom = gclient.ParseXML(output)
output = gclient_scm.CaptureSVN(command)
dom = gclient_utils.ParseXML(output)
entries = []
if dom:
# /log/logentry/
......@@ -66,8 +68,8 @@ def CaptureSVNLog(args):
paths.append(item)
entry = {
'revision': int(node.getAttribute('revision')),
'author': gclient.GetNamedNodeText(node, 'author'),
'date': gclient.GetNamedNodeText(node, 'date'),
'author': gclient_utils.GetNamedNodeText(node, 'author'),
'date': gclient_utils.GetNamedNodeText(node, 'date'),
'paths': paths,
}
entries.append(entry)
......@@ -144,7 +146,7 @@ def Revert(revisions, force=False, commit=True, send_email=True, message=None,
print ""
# Make sure these files are unmodified with svn status.
status = gclient.CaptureSVNStatus(files)
status = gclient_scm.CaptureSVNStatus(files)
if status:
if force:
# TODO(maruel): Use the tool to correctly revert '?' files.
......
......@@ -19,7 +19,7 @@ class GclTestsBase(super_mox.SuperMoxTestBase):
super_mox.SuperMoxTestBase.setUp(self)
self.fake_root_dir = self.RootDir()
self.mox.StubOutWithMock(gcl, 'RunShell')
self.mox.StubOutWithMock(gcl.gclient, 'CaptureSVNInfo')
self.mox.StubOutWithMock(gcl.gclient_scm, 'CaptureSVNInfo')
self.mox.StubOutWithMock(gcl.os, 'getcwd')
self.mox.StubOutWithMock(gcl.os, 'chdir')
self.mox.StubOutWithMock(gcl.os, 'close')
......@@ -55,7 +55,7 @@ class GclUnittest(GclTestsBase):
'PresubmitCL', 'ReadFile', 'REPOSITORY_ROOT', 'RunShell',
'RunShellWithReturnCode', 'SendToRietveld', 'TryChange',
'UnknownFiles', 'UploadCL', 'Warn', 'WriteFile',
'gclient', 'getpass', 'main', 'os', 'random', 're',
'gclient_scm', 'gclient_utils', 'getpass', 'main', 'os', 'random', 're',
'shutil', 'string', 'subprocess', 'sys', 'tempfile',
'upload', 'urllib2', 'xml',
]
......@@ -80,7 +80,7 @@ class GclUnittest(GclTestsBase):
result = {
"Repository Root": ""
}
gcl.gclient.CaptureSVNInfo("/bleh/prout", print_error=False).AndReturn(
gcl.gclient_scm.CaptureSVNInfo("/bleh/prout", print_error=False).AndReturn(
result)
self.mox.ReplayAll()
self.assertRaises(Exception, gcl.GetRepositoryRoot)
......@@ -90,10 +90,11 @@ class GclUnittest(GclTestsBase):
root_path = gcl.os.path.join('bleh', 'prout', 'pouet')
gcl.os.getcwd().AndReturn(root_path)
result1 = { "Repository Root": "Some root" }
gcl.gclient.CaptureSVNInfo(root_path, print_error=False).AndReturn(result1)
gcl.gclient_scm.CaptureSVNInfo(root_path,
print_error=False).AndReturn(result1)
gcl.os.getcwd().AndReturn(root_path)
results2 = { "Repository Root": "A different root" }
gcl.gclient.CaptureSVNInfo(
gcl.gclient_scm.CaptureSVNInfo(
gcl.os.path.dirname(root_path),
print_error=False).AndReturn(results2)
self.mox.ReplayAll()
......
This diff is collapsed.
......@@ -59,7 +59,7 @@ def CheckChangeOnUpload(input_api, output_api):
presubmit.os.path.abspath = MockAbsPath
presubmit.os.path.commonprefix = os_path_commonprefix
self.fake_root_dir = self.RootDir()
self.mox.StubOutWithMock(presubmit.gclient, 'CaptureSVNInfo')
self.mox.StubOutWithMock(presubmit.gclient_scm, 'CaptureSVNInfo')
self.mox.StubOutWithMock(presubmit.gcl, 'GetSVNFileProperty')
self.mox.StubOutWithMock(presubmit.gcl, 'ReadFile')
......@@ -75,7 +75,7 @@ class PresubmitUnittest(PresubmitTestsBase):
'OutputApi', 'ParseFiles', 'PresubmitExecuter', 'ScanSubDirs',
'SvnAffectedFile', 'SvnChange',
'cPickle', 'cStringIO', 'exceptions',
'fnmatch', 'gcl', 'gclient', 'glob', 'logging', 'marshal', 'normpath',
'fnmatch', 'gcl', 'gclient_scm', 'glob', 'logging', 'marshal', 'normpath',
'optparse', 'os', 'pickle',
'presubmit_canned_checks', 'random', 're', 'subprocess', 'sys', 'time',
'tempfile', 'traceback', 'types', 'unittest', 'urllib2', 'warnings',
......@@ -151,19 +151,19 @@ class PresubmitUnittest(PresubmitTestsBase):
presubmit.os.path.exists(notfound).AndReturn(True)
presubmit.os.path.isdir(notfound).AndReturn(False)
presubmit.os.path.exists(flap).AndReturn(False)
presubmit.gclient.CaptureSVNInfo(flap
presubmit.gclient_scm.CaptureSVNInfo(flap
).AndReturn({'Node Kind': 'file'})
presubmit.gcl.GetSVNFileProperty(blat, 'svn:mime-type').AndReturn(None)
presubmit.gcl.GetSVNFileProperty(
binary, 'svn:mime-type').AndReturn('application/octet-stream')
presubmit.gcl.GetSVNFileProperty(
notfound, 'svn:mime-type').AndReturn('')
presubmit.gclient.CaptureSVNInfo(blat).AndReturn(
presubmit.gclient_scm.CaptureSVNInfo(blat).AndReturn(
{'URL': 'svn:/foo/foo/blat.cc'})
presubmit.gclient.CaptureSVNInfo(binary).AndReturn(
presubmit.gclient_scm.CaptureSVNInfo(binary).AndReturn(
{'URL': 'svn:/foo/binary.dll'})
presubmit.gclient.CaptureSVNInfo(notfound).AndReturn({})
presubmit.gclient.CaptureSVNInfo(flap).AndReturn(
presubmit.gclient_scm.CaptureSVNInfo(notfound).AndReturn({})
presubmit.gclient_scm.CaptureSVNInfo(flap).AndReturn(
{'URL': 'svn:/foo/boo/flap.h'})
presubmit.gcl.ReadFile(blat).AndReturn('boo!\nahh?')
presubmit.gcl.ReadFile(notfound).AndReturn('look!\nthere?')
......@@ -520,9 +520,9 @@ class InputApiUnittest(PresubmitTestsBase):
self.compareMembers(presubmit.InputApi(None, './.', False), members)
def testDepotToLocalPath(self):
presubmit.gclient.CaptureSVNInfo('svn://foo/smurf').AndReturn(
presubmit.gclient_scm.CaptureSVNInfo('svn://foo/smurf').AndReturn(
{'Path': 'prout'})
presubmit.gclient.CaptureSVNInfo('svn:/foo/notfound/burp').AndReturn({})
presubmit.gclient_scm.CaptureSVNInfo('svn:/foo/notfound/burp').AndReturn({})
self.mox.ReplayAll()
path = presubmit.InputApi(None, './p', False).DepotToLocalPath(
......@@ -533,8 +533,9 @@ class InputApiUnittest(PresubmitTestsBase):
self.failUnless(path == None)
def testLocalToDepotPath(self):
presubmit.gclient.CaptureSVNInfo('smurf').AndReturn({'URL': 'svn://foo'})
presubmit.gclient.CaptureSVNInfo('notfound-food').AndReturn({})
presubmit.gclient_scm.CaptureSVNInfo('smurf').AndReturn({'URL':
'svn://foo'})
presubmit.gclient_scm.CaptureSVNInfo('notfound-food').AndReturn({})
self.mox.ReplayAll()
path = presubmit.InputApi(None, './p', False).LocalToDepotPath('smurf')
......@@ -585,8 +586,8 @@ class InputApiUnittest(PresubmitTestsBase):
presubmit.os.path.exists(notfound).AndReturn(False)
presubmit.os.path.exists(flap).AndReturn(True)
presubmit.os.path.isdir(flap).AndReturn(False)
presubmit.gclient.CaptureSVNInfo(beingdeleted).AndReturn({})
presubmit.gclient.CaptureSVNInfo(notfound).AndReturn({})
presubmit.gclient_scm.CaptureSVNInfo(beingdeleted).AndReturn({})
presubmit.gclient_scm.CaptureSVNInfo(notfound).AndReturn({})
presubmit.gcl.GetSVNFileProperty(blat, 'svn:mime-type').AndReturn(None)
presubmit.gcl.GetSVNFileProperty(readme, 'svn:mime-type').AndReturn(None)
presubmit.gcl.GetSVNFileProperty(binary, 'svn:mime-type').AndReturn(
......@@ -910,7 +911,7 @@ class AffectedFileUnittest(PresubmitTestsBase):
presubmit.os.path.exists(path).AndReturn(True)
presubmit.os.path.isdir(path).AndReturn(False)
presubmit.gcl.ReadFile(path).AndReturn('whatever\ncookie')
presubmit.gclient.CaptureSVNInfo(path).AndReturn(
presubmit.gclient_scm.CaptureSVNInfo(path).AndReturn(
{'URL': 'svn:/foo/foo/blat.cc'})
self.mox.ReplayAll()
af = presubmit.SvnAffectedFile('foo/blat.cc', 'M')
......@@ -934,7 +935,7 @@ class AffectedFileUnittest(PresubmitTestsBase):
def testIsDirectoryNotExists(self):
presubmit.os.path.exists('foo.cc').AndReturn(False)
presubmit.gclient.CaptureSVNInfo('foo.cc').AndReturn({})
presubmit.gclient_scm.CaptureSVNInfo('foo.cc').AndReturn({})
self.mox.ReplayAll()
affected_file = presubmit.SvnAffectedFile('foo.cc', 'A')
# Verify cache coherency.
......
......@@ -20,6 +20,7 @@ class RevertTestsBase(super_mox.SuperMoxTestBase):
super_mox.SuperMoxTestBase.setUp(self)
self.mox.StubOutWithMock(revert, 'gcl')
self.mox.StubOutWithMock(revert, 'gclient')
self.mox.StubOutWithMock(revert, 'gclient_scm')
self.mox.StubOutWithMock(revert, 'os')
self.mox.StubOutWithMock(revert.os, 'path')
self.mox.StubOutWithMock(revert.sys, 'stdout')
......@@ -35,7 +36,8 @@ class RevertUnittest(RevertTestsBase):
members = [
'CaptureSVNLog', 'GetRepoBase', 'Main', 'ModifiedFile', 'NoBlameList',
'NoModifiedFile', 'OutsideOfCheckout', 'Revert', 'UniqueFast',
'exceptions', 'gcl', 'gclient', 'optparse', 'os', 'sys', 'xml'
'exceptions', 'gcl', 'gclient', 'gclient_scm', 'gclient_utils',
'optparse', 'os', 'sys', 'xml'
]
# If this test fails, you should add the relevant test.
self.compareMembers(revert, members)
......@@ -45,7 +47,6 @@ class RevertMainUnittest(RevertTestsBase):
def setUp(self):
RevertTestsBase.setUp(self)
self.mox.StubOutWithMock(revert, 'gcl')
self.mox.StubOutWithMock(revert, 'gclient')
self.mox.StubOutWithMock(revert, 'os')
self.mox.StubOutWithMock(revert.os, 'path')
self.mox.StubOutWithMock(revert, 'sys')
......@@ -78,7 +79,7 @@ class RevertRevertUnittest(RevertTestsBase):
}]
revert.CaptureSVNLog(['-r', '42', '-v']).AndReturn(entries)
revert.GetRepoBase().AndReturn('proto://fqdn/repo/')
revert.gclient.CaptureSVNStatus(['random_file']).AndReturn([])
revert.gclient_scm.CaptureSVNStatus(['random_file']).AndReturn([])
revert.gcl.RunShell(['svn', 'up', 'random_file'])
revert.os.path.isdir('random_file').AndReturn(False)
status = """--- Reverse-merging r42 into '.':
......
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