mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Remove gclient_utils.RemoveDirectory().
The 'RemoveDirectory()' function in gclient_utils is deprecated and rmtree() should be used instead for consistency. This patch modifies all clients in depot_tools to use rmtree() instead and removes the RemoveDirectory function. + The SVNWrapperTestCase.testRevertNoDotSvn() mocking expectation has been slightly changed. This was required because the test invokes code that used to call gclient_utils.RemoveDirectory() directly, while only gclient_utils.rmtree() was mocked. BUG=NONE R=maruel@chromium.org, ilevy@chromium.org TEST=manually run gclient_utils_test / gclient_smoketest / scm_unittest / gclient_scm_test Review URL: https://chromiumcodereview.appspot.com/14134010 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@196133 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@@ -1167,7 +1167,7 @@ solutions = [
|
||||
# Delete the entry
|
||||
print('\n________ deleting \'%s\' in \'%s\'' % (
|
||||
entry_fixed, self.root_dir))
|
||||
gclient_utils.RemoveDirectory(e_dir)
|
||||
gclient_utils.rmtree(e_dir)
|
||||
# record the current list of entries for next time
|
||||
self._SaveEntries()
|
||||
return 0
|
||||
|
||||
@@ -526,7 +526,7 @@ class GitWrapper(SCMWrapper):
|
||||
full_path = os.path.join(self.checkout_path, path)
|
||||
if not os.path.islink(full_path):
|
||||
print('\n_____ removing unversioned directory %s' % path)
|
||||
gclient_utils.RemoveDirectory(full_path)
|
||||
gclient_utils.rmtree(full_path)
|
||||
|
||||
|
||||
def revert(self, options, args, file_list):
|
||||
@@ -1080,7 +1080,7 @@ class SVNWrapper(SCMWrapper):
|
||||
'try again.') % (url, self.checkout_path))
|
||||
# Ok delete it.
|
||||
print('\n_____ switching %s to a new checkout' % self.relpath)
|
||||
gclient_utils.RemoveDirectory(self.checkout_path)
|
||||
gclient_utils.rmtree(self.checkout_path)
|
||||
# We need to checkout.
|
||||
command = ['checkout', url, self.checkout_path]
|
||||
command = self._AddAdditionalUpdateFlags(command, options, revision)
|
||||
@@ -1106,7 +1106,7 @@ class SVNWrapper(SCMWrapper):
|
||||
and os.path.isdir(full_path)
|
||||
and not os.path.islink(full_path)):
|
||||
print('\n_____ removing unversioned directory %s' % status[1])
|
||||
gclient_utils.RemoveDirectory(full_path)
|
||||
gclient_utils.rmtree(full_path)
|
||||
|
||||
def updatesingle(self, options, args, file_list):
|
||||
filename = args.pop()
|
||||
|
||||
@@ -158,9 +158,6 @@ def rmtree(path):
|
||||
|
||||
remove(os.rmdir, path)
|
||||
|
||||
# TODO(maruel): Rename the references.
|
||||
RemoveDirectory = rmtree
|
||||
|
||||
|
||||
def safe_makedirs(tree):
|
||||
"""Creates the directory in a safe manner.
|
||||
|
||||
8
scm.py
8
scm.py
@@ -567,7 +567,7 @@ class SVN(object):
|
||||
# Warning: It's bad, it assumes args[2] is the directory
|
||||
# argument.
|
||||
if os.path.isdir(args[2]):
|
||||
gclient_utils.RemoveDirectory(args[2])
|
||||
gclient_utils.rmtree(args[2])
|
||||
else:
|
||||
# Progress was made, convert to update since an aborted checkout
|
||||
# is now an update.
|
||||
@@ -856,7 +856,7 @@ class SVN(object):
|
||||
buf.close()
|
||||
return result
|
||||
finally:
|
||||
gclient_utils.RemoveDirectory(bogus_dir)
|
||||
gclient_utils.rmtree(bogus_dir)
|
||||
|
||||
@staticmethod
|
||||
def _DiffItemInternal(filename, cwd, info, bogus_dir, full_move, revision):
|
||||
@@ -1054,8 +1054,8 @@ class SVN(object):
|
||||
logging.info('os.remove(%s)' % file_path)
|
||||
os.remove(file_path)
|
||||
elif os.path.isdir(file_path):
|
||||
logging.info('RemoveDirectory(%s)' % file_path)
|
||||
gclient_utils.RemoveDirectory(file_path)
|
||||
logging.info('rmtree(%s)' % file_path)
|
||||
gclient_utils.rmtree(file_path)
|
||||
else:
|
||||
logging.critical(
|
||||
('No idea what is %s.\nYou just found a bug in gclient'
|
||||
|
||||
@@ -43,14 +43,14 @@ class TrialDir(object):
|
||||
TrialDir.TRIAL_ROOT = os.path.realpath(tempfile.mkdtemp(prefix='trial'))
|
||||
atexit.register(self._clean)
|
||||
self.root_dir = os.path.join(TrialDir.TRIAL_ROOT, self.subdir)
|
||||
gclient_utils.RemoveDirectory(self.root_dir)
|
||||
gclient_utils.rmtree(self.root_dir)
|
||||
os.makedirs(self.root_dir)
|
||||
|
||||
def tear_down(self):
|
||||
"""Cleans the trial subdirectory for this instance."""
|
||||
if not self.leak:
|
||||
logging.debug('Removing %s' % self.root_dir)
|
||||
gclient_utils.RemoveDirectory(self.root_dir)
|
||||
gclient_utils.rmtree(self.root_dir)
|
||||
else:
|
||||
logging.error('Leaking %s' % self.root_dir)
|
||||
self.root_dir = None
|
||||
@@ -60,7 +60,7 @@ class TrialDir(object):
|
||||
"""Cleans the root trial directory."""
|
||||
if not TrialDir.SHOULD_LEAK:
|
||||
logging.debug('Removing %s' % TrialDir.TRIAL_ROOT)
|
||||
gclient_utils.RemoveDirectory(TrialDir.TRIAL_ROOT)
|
||||
gclient_utils.rmtree(TrialDir.TRIAL_ROOT)
|
||||
else:
|
||||
logging.error('Leaking %s' % TrialDir.TRIAL_ROOT)
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class BaseTestCase(GCBaseTestCase, SuperMoxTestBase):
|
||||
'CheckCallAndFilterAndHeader')
|
||||
self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileRead')
|
||||
self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileWrite')
|
||||
self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'RemoveDirectory')
|
||||
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')
|
||||
@@ -210,7 +210,6 @@ class SVNWrapperTestCase(BaseTestCase):
|
||||
gclient_scm.os.path.isdir(join(self.base_path, '.git')).AndReturn(False)
|
||||
gclient_scm.os.path.isdir(join(self.base_path, '.hg')).AndReturn(False)
|
||||
# Checkout.
|
||||
gclient_scm.os.path.exists(self.base_path).AndReturn(False)
|
||||
gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
|
||||
gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
|
||||
gclient_scm.os.path.exists(self.base_path).AndReturn(False)
|
||||
@@ -226,7 +225,7 @@ class SVNWrapperTestCase(BaseTestCase):
|
||||
['checkout', self.url, self.base_path, '--force', '--ignore-externals'],
|
||||
cwd=self.root_dir,
|
||||
file_list=files_list)
|
||||
|
||||
gclient_scm.gclient_utils.rmtree(self.base_path)
|
||||
self.mox.ReplayAll()
|
||||
scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
|
||||
relpath=self.relpath)
|
||||
@@ -268,7 +267,7 @@ class SVNWrapperTestCase(BaseTestCase):
|
||||
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.gclient_utils.rmtree(file_path)
|
||||
gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
|
||||
gclient_scm.scm.SVN.RunAndGetFileList(
|
||||
options.verbose,
|
||||
@@ -293,13 +292,13 @@ class SVNWrapperTestCase(BaseTestCase):
|
||||
]
|
||||
gclient_scm.scm.SVN.CaptureStatus(
|
||||
None, self.base_path, no_ignore=False).AndReturn(items)
|
||||
# RemoveDirectory() doesn't work on path ending with '.', like 'foo/.'.
|
||||
# gclient_utils.rmtree() doesn't work on path ending with '.', like 'foo/.'.
|
||||
file_path = 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.gclient_utils.rmtree(file_path)
|
||||
# pylint: disable=E1120
|
||||
gclient_scm.os.path.isdir(self.base_path).AndReturn(False)
|
||||
gclient_scm.SVNWrapper.update(options, [], ['.'])
|
||||
@@ -463,7 +462,7 @@ class SVNWrapperTestCase(BaseTestCase):
|
||||
gclient_scm.os.path.isdir(join(self.base_path, 'dir')).AndReturn(True)
|
||||
gclient_scm.os.path.isdir(join(self.base_path, 'file')).AndReturn(False)
|
||||
gclient_scm.os.path.islink(join(self.base_path, 'dir')).AndReturn(False)
|
||||
gclient_scm.gclient_utils.RemoveDirectory(join(self.base_path, 'dir'))
|
||||
gclient_scm.gclient_utils.rmtree(join(self.base_path, 'dir'))
|
||||
|
||||
self.mox.ReplayAll()
|
||||
scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
|
||||
|
||||
@@ -34,7 +34,7 @@ class GclientUtilsUnittest(GclientUtilBase):
|
||||
'GetGClientRootAndEntries', 'GetEditor', 'IsDateRevision',
|
||||
'MakeDateRevision', 'MakeFileAutoFlush', 'MakeFileAnnotated',
|
||||
'PathDifference', 'ParseCodereviewSettingsContent', 'NumLocalCpus',
|
||||
'PrintableObject', 'RemoveDirectory', 'RunEditor',
|
||||
'PrintableObject', 'RunEditor',
|
||||
'SplitUrlRevision', 'SyntaxErrorToError', 'UpgradeToHttps', 'Wrapper',
|
||||
'WorkItem', 'codecs', 'lockedmethod', 'logging', 'os', 'Queue', 're',
|
||||
'rmtree', 'safe_makedirs', 'stat', 'subprocess', 'subprocess2', 'sys',
|
||||
|
||||
Reference in New Issue
Block a user