From 0380707ce298354097e0e63027d5f3bb6882f3e1 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Mon, 16 Aug 2010 17:18:44 +0000 Subject: [PATCH] Remove 'options' usage from scm.py This is towards cleaning up the mess with 'options' in gclient_scm.py. Review URL: http://codereview.chromium.org/3106014 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@56213 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient_scm.py | 17 +++++++++++------ scm.py | 6 +++--- tests/gclient_scm_test.py | 18 +++++++++--------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/gclient_scm.py b/gclient_scm.py index 532fabc82e..3e554a7ba3 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -741,7 +741,8 @@ class SVNWrapper(SCMWrapper): # We need to checkout. command = ['checkout', url, checkout_path] command = self.AddAdditionalFlags(command, options, revision) - scm.SVN.RunAndGetFileList(options, command, self._root_dir, file_list) + scm.SVN.RunAndGetFileList(options.verbose, command, self._root_dir, + file_list) return # Get the existing scm url and the revision number of the current checkout. @@ -807,7 +808,8 @@ class SVNWrapper(SCMWrapper): # We need to checkout. command = ['checkout', url, checkout_path] command = self.AddAdditionalFlags(command, options, revision) - scm.SVN.RunAndGetFileList(options, command, self._root_dir, file_list) + scm.SVN.RunAndGetFileList(options.verbose, command, self._root_dir, + file_list) return @@ -820,7 +822,8 @@ class SVNWrapper(SCMWrapper): command = ["update", checkout_path] command = self.AddAdditionalFlags(command, options, revision) - scm.SVN.RunAndGetFileList(options, command, self._root_dir, file_list) + scm.SVN.RunAndGetFileList(options.verbose, command, self._root_dir, + file_list) def updatesingle(self, options, args, file_list): checkout_path = os.path.join(self._root_dir, self.relpath) @@ -834,7 +837,8 @@ class SVNWrapper(SCMWrapper): if os.path.exists(os.path.join(checkout_path, filename)): os.remove(os.path.join(checkout_path, filename)) command = ["update", filename] - scm.SVN.RunAndGetFileList(options, command, checkout_path, file_list) + scm.SVN.RunAndGetFileList(options.verbose, command, checkout_path, + file_list) # After the initial checkout, we can use update as if it were any other # dep. self.update(options, args, file_list) @@ -899,7 +903,8 @@ class SVNWrapper(SCMWrapper): try: # svn revert is so broken we don't even use it. Using # "svn up --revision BASE" achieve the same effect. - scm.SVN.RunAndGetFileList(options, ['update', '--revision', 'BASE'], path, + scm.SVN.RunAndGetFileList(options.verbose, + ['update', '--revision', 'BASE'], path, file_list) except OSError, e: # Maybe the directory disapeared meanwhile. We don't want it to throw an @@ -925,7 +930,7 @@ class SVNWrapper(SCMWrapper): % (' '.join(command), path)) # There's no file list to retrieve. else: - scm.SVN.RunAndGetFileList(options, command, path, file_list) + scm.SVN.RunAndGetFileList(options.verbose, command, path, file_list) def FullUrlForRelativeUrl(self, url): # Find the forth '/' and strip from there. A bit hackish. diff --git a/scm.py b/scm.py index 79432423b0..9fb03833ff 100644 --- a/scm.py +++ b/scm.py @@ -386,7 +386,7 @@ class SVN(object): stderr=stderr).communicate()[0] @staticmethod - def RunAndGetFileList(options, args, in_directory, file_list): + def RunAndGetFileList(verbose, args, in_directory, file_list): """Runs svn checkout, update, or status, output to stdout. The first item in args must be either "checkout", "update", or "status". @@ -396,7 +396,7 @@ class SVN(object): sys.stdout as in Run. Args: - options: command line options to gclient + verbose: If True, uses verbose output args: A sequence of command line parameters to be passed to svn. in_directory: The directory where svn is to be run. @@ -442,7 +442,7 @@ class SVN(object): try: SVN.RunAndFilterOutput(args, in_directory, - options.verbose, + verbose, True, CaptureMatchingLines) except gclient_utils.Error: diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py index 92ea2be91d..fa65a49ee4 100755 --- a/tests/gclient_scm_test.py +++ b/tests/gclient_scm_test.py @@ -125,7 +125,7 @@ class SVNWrapperTestCase(BaseTestCase): # Checkout. gclient_scm.os.path.exists(base_path).AndReturn(False) files_list = self.mox.CreateMockAnything() - gclient_scm.scm.SVN.RunAndGetFileList(options, + gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, ['checkout', self.url, base_path], self.root_dir, files_list) @@ -139,7 +139,7 @@ class SVNWrapperTestCase(BaseTestCase): base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) gclient_scm.os.path.isdir(base_path).AndReturn(True) gclient_scm.scm.SVN.CaptureStatus(base_path).AndReturn([]) - gclient_scm.scm.SVN.RunAndGetFileList(options, + gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, ['update', '--revision', 'BASE'], base_path, mox.IgnoreArg()) @@ -166,7 +166,7 @@ class SVNWrapperTestCase(BaseTestCase): gclient_scm.os.path.exists(file_path2).AndReturn(True) gclient_scm.os.path.isfile(file_path2).AndReturn(True) gclient_scm.os.remove(file_path2) - gclient_scm.scm.SVN.RunAndGetFileList(options, + gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, ['update', '--revision', 'BASE'], base_path, mox.IgnoreArg()) print(gclient_scm.os.path.join(base_path, 'a')) @@ -194,7 +194,7 @@ class SVNWrapperTestCase(BaseTestCase): gclient_scm.os.path.isdir(file_path).AndReturn(True) gclient_scm.gclient_utils.RemoveDirectory(file_path) file_list1 = [] - gclient_scm.scm.SVN.RunAndGetFileList(options, + gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, ['update', '--revision', 'BASE'], base_path, mox.IgnoreArg()) @@ -208,7 +208,7 @@ class SVNWrapperTestCase(BaseTestCase): options = self.Options(verbose=True) base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) gclient_scm.os.path.isdir(base_path).AndReturn(True) - gclient_scm.scm.SVN.RunAndGetFileList(options, + gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, ['status'] + self.args, base_path, []).AndReturn(None) @@ -234,7 +234,7 @@ class SVNWrapperTestCase(BaseTestCase): # Checkout. gclient_scm.os.path.exists(base_path).AndReturn(False) files_list = self.mox.CreateMockAnything() - gclient_scm.scm.SVN.RunAndGetFileList(options, + gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, ['checkout', self.url, base_path], self.root_dir, files_list) self.mox.ReplayAll() @@ -274,7 +274,7 @@ class SVNWrapperTestCase(BaseTestCase): additional_args.append('--force') files_list = [] gclient_scm.scm.SVN.RunAndGetFileList( - options, + options.verbose, ['update', base_path] + additional_args, self.root_dir, files_list) @@ -308,7 +308,7 @@ class SVNWrapperTestCase(BaseTestCase): files_list = self.mox.CreateMockAnything() gclient_scm.scm.SVN.Run( ['checkout', '--depth', 'empty', self.url, base_path], self.root_dir) - gclient_scm.scm.SVN.RunAndGetFileList(options, ['update', 'DEPS'], + gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, ['update', 'DEPS'], gclient_scm.os.path.join(self.root_dir, self.relpath), files_list) # Now we fall back on scm.update(). @@ -380,7 +380,7 @@ class SVNWrapperTestCase(BaseTestCase): files_list = self.mox.CreateMockAnything() gclient_scm.scm.SVN.Run( ['checkout', '--depth', 'empty', self.url, base_path], self.root_dir) - gclient_scm.scm.SVN.RunAndGetFileList(options, ['update', 'DEPS'], + gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, ['update', 'DEPS'], gclient_scm.os.path.join(self.root_dir, self.relpath), files_list) # Now we fall back on scm.update().