diff --git a/gclient.py b/gclient.py index 3137093f5..90b75d9a2 100755 --- a/gclient.py +++ b/gclient.py @@ -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 diff --git a/gclient_scm.py b/gclient_scm.py index 71fecd09f..4573a484b 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -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() diff --git a/gclient_utils.py b/gclient_utils.py index 52bc6cdda..ddcce9b17 100644 --- a/gclient_utils.py +++ b/gclient_utils.py @@ -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. diff --git a/scm.py b/scm.py index d920e9e51..47a7c6e0c 100644 --- a/scm.py +++ b/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' diff --git a/testing_support/trial_dir.py b/testing_support/trial_dir.py index 1f2c9285a..b5b83f7bb 100644 --- a/testing_support/trial_dir.py +++ b/testing_support/trial_dir.py @@ -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) diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py index 8f3b3f93d..f9a29bbfa 100755 --- a/tests/gclient_scm_test.py +++ b/tests/gclient_scm_test.py @@ -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, diff --git a/tests/gclient_utils_test.py b/tests/gclient_utils_test.py index 050dc7440..2703e5d95 100755 --- a/tests/gclient_utils_test.py +++ b/tests/gclient_utils_test.py @@ -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',