Make 'gclient update' and 'gclient status' quieter by default - they don't

print messages unless the underlying commands actually generate output.
This is a more conservative version of r28271.

  BUG=none
  TEST=none
  R=maruel

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@30296 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
dpranke@google.com 16 years ago
parent b5fdbaad26
commit 22e29d4ec5

@ -892,7 +892,6 @@ def DoCleanup(options, args):
# Print out the .gclient file. This is longer than if we just printed the # Print out the .gclient file. This is longer than if we just printed the
# client dict, but more legible, and it might contain helpful comments. # client dict, but more legible, and it might contain helpful comments.
print(client.ConfigContent()) print(client.ConfigContent())
options.verbose = True
return client.RunOnDeps('cleanup', args) return client.RunOnDeps('cleanup', args)
@ -971,7 +970,6 @@ def DoPack(options, args):
# Print out the .gclient file. This is longer than if we just printed the # Print out the .gclient file. This is longer than if we just printed the
# client dict, but more legible, and it might contain helpful comments. # client dict, but more legible, and it might contain helpful comments.
print(client.ConfigContent()) print(client.ConfigContent())
options.verbose = True
return client.RunOnDeps('pack', args) return client.RunOnDeps('pack', args)
@ -988,7 +986,6 @@ def DoStatus(options, args):
# Print out the .gclient file. This is longer than if we just printed the # Print out the .gclient file. This is longer than if we just printed the
# client dict, but more legible, and it might contain helpful comments. # client dict, but more legible, and it might contain helpful comments.
print(client.ConfigContent()) print(client.ConfigContent())
options.verbose = True
return client.RunOnDeps('status', args) return client.RunOnDeps('status', args)
@ -1043,7 +1040,6 @@ def DoDiff(options, args):
# Print out the .gclient file. This is longer than if we just printed the # Print out the .gclient file. This is longer than if we just printed the
# client dict, but more legible, and it might contain helpful comments. # client dict, but more legible, and it might contain helpful comments.
print(client.ConfigContent()) print(client.ConfigContent())
options.verbose = True
return client.RunOnDeps('diff', args) return client.RunOnDeps('diff', args)

@ -251,7 +251,7 @@ class SVNWrapper(SCMWrapper):
command = ['checkout', url, checkout_path] command = ['checkout', url, checkout_path]
if revision: if revision:
command.extend(['--revision', str(revision)]) command.extend(['--revision', str(revision)])
RunSVNAndGetFileList(command, self._root_dir, file_list) RunSVNAndGetFileList(options, command, self._root_dir, file_list)
return return
# Get the existing scm url and the revision number of the current checkout. # Get the existing scm url and the revision number of the current checkout.
@ -309,7 +309,7 @@ class SVNWrapper(SCMWrapper):
command = ['checkout', url, checkout_path] command = ['checkout', url, checkout_path]
if revision: if revision:
command.extend(['--revision', str(revision)]) command.extend(['--revision', str(revision)])
RunSVNAndGetFileList(command, self._root_dir, file_list) RunSVNAndGetFileList(options, command, self._root_dir, file_list)
return return
@ -323,7 +323,7 @@ class SVNWrapper(SCMWrapper):
command = ["update", checkout_path] command = ["update", checkout_path]
if revision: if revision:
command.extend(['--revision', str(revision)]) command.extend(['--revision', str(revision)])
RunSVNAndGetFileList(command, self._root_dir, file_list) RunSVNAndGetFileList(options, command, self._root_dir, file_list)
def revert(self, options, args, file_list): def revert(self, options, args, file_list):
"""Reverts local modifications. Subversion specific. """Reverts local modifications. Subversion specific.
@ -374,7 +374,7 @@ class SVNWrapper(SCMWrapper):
try: try:
# svn revert is so broken we don't even use it. Using # svn revert is so broken we don't even use it. Using
# "svn up --revision BASE" achieve the same effect. # "svn up --revision BASE" achieve the same effect.
RunSVNAndGetFileList(['update', '--revision', 'BASE'], path, RunSVNAndGetFileList(options, ['update', '--revision', 'BASE'], path,
file_list) file_list)
except OSError, e: except OSError, e:
# Maybe the directory disapeared meanwhile. We don't want it to throw an # Maybe the directory disapeared meanwhile. We don't want it to throw an
@ -396,7 +396,7 @@ class SVNWrapper(SCMWrapper):
% (' '.join(command), path)) % (' '.join(command), path))
# There's no file list to retrieve. # There's no file list to retrieve.
else: else:
RunSVNAndGetFileList(command, path, file_list) RunSVNAndGetFileList(options, command, path, file_list)
def pack(self, options, args, file_list): def pack(self, options, args, file_list):
"""Generates a patch file which can be applied to the root of the """Generates a patch file which can be applied to the root of the
@ -546,7 +546,7 @@ def CaptureSVN(args, in_directory=None, print_error=True):
stderr=stderr).communicate()[0] stderr=stderr).communicate()[0]
def RunSVNAndGetFileList(args, in_directory, file_list): def RunSVNAndGetFileList(options, args, in_directory, file_list):
"""Runs svn checkout, update, or status, output to stdout. """Runs svn checkout, update, or status, output to stdout.
The first item in args must be either "checkout", "update", or "status". The first item in args must be either "checkout", "update", or "status".
@ -556,6 +556,7 @@ def RunSVNAndGetFileList(args, in_directory, file_list):
sys.stdout as in RunSVN. sys.stdout as in RunSVN.
Args: Args:
options: command line options to gclient
args: A sequence of command line parameters to be passed to svn. args: A sequence of command line parameters to be passed to svn.
in_directory: The directory where svn is to be run. in_directory: The directory where svn is to be run.
@ -595,7 +596,7 @@ def RunSVNAndGetFileList(args, in_directory, file_list):
RunSVNAndFilterOutput(args, RunSVNAndFilterOutput(args,
in_directory, in_directory,
True, options.verbose,
True, True,
CaptureMatchingLines) CaptureMatchingLines)

@ -183,8 +183,13 @@ def SubprocessCallAndFilter(command,
"""Runs command, a list, in directory in_directory. """Runs command, a list, in directory in_directory.
If print_messages is true, a message indicating what is being done 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 printed to stdout. If print_messages is false, the message is printed
is also forwarded to stdout. only if we actually need to print something else as well, so you can
get the context of the output. If print_messages is false and print_stdout
is false, no output at all is generated.
Also, 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 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 string argument, and it will be called with each line of the
@ -216,6 +221,10 @@ def SubprocessCallAndFilter(command,
if in_byte != "\r": if in_byte != "\r":
if print_stdout: if print_stdout:
sys.stdout.write(in_byte) sys.stdout.write(in_byte)
if not print_messages:
print("\n________ running \'%s\' in \'%s\'"
% (' '.join(command), in_directory))
print_messages = True
if in_byte != "\n": if in_byte != "\n":
in_line += in_byte in_line += in_byte
if in_byte == "\n" and filter: if in_byte == "\n" and filter:

@ -96,7 +96,7 @@ class SVNWrapperTestCase(gclient_test.GClientBaseTestCase):
# Checkout. # Checkout.
gclient.os.path.exists(base_path).AndReturn(False) gclient.os.path.exists(base_path).AndReturn(False)
files_list = self.mox.CreateMockAnything() files_list = self.mox.CreateMockAnything()
gclient_scm.RunSVNAndGetFileList(['checkout', self.url, base_path], gclient_scm.RunSVNAndGetFileList(options, ['checkout', self.url, base_path],
self.root_dir, files_list) self.root_dir, files_list)
self.mox.ReplayAll() self.mox.ReplayAll()
@ -109,7 +109,7 @@ class SVNWrapperTestCase(gclient_test.GClientBaseTestCase):
base_path = os.path.join(self.root_dir, self.relpath) base_path = os.path.join(self.root_dir, self.relpath)
gclient.os.path.isdir(base_path).AndReturn(True) gclient.os.path.isdir(base_path).AndReturn(True)
gclient_scm.CaptureSVNStatus(base_path).AndReturn([]) gclient_scm.CaptureSVNStatus(base_path).AndReturn([])
gclient_scm.RunSVNAndGetFileList(['update', '--revision', 'BASE'], gclient_scm.RunSVNAndGetFileList(options, ['update', '--revision', 'BASE'],
base_path, mox.IgnoreArg()) base_path, mox.IgnoreArg())
self.mox.ReplayAll() self.mox.ReplayAll()
@ -135,7 +135,7 @@ class SVNWrapperTestCase(gclient_test.GClientBaseTestCase):
gclient_scm.os.path.exists(file_path2).AndReturn(True) gclient_scm.os.path.exists(file_path2).AndReturn(True)
gclient_scm.os.path.isfile(file_path2).AndReturn(True) gclient_scm.os.path.isfile(file_path2).AndReturn(True)
gclient_scm.os.remove(file_path2) gclient_scm.os.remove(file_path2)
gclient_scm.RunSVNAndGetFileList(['update', '--revision', 'BASE'], gclient_scm.RunSVNAndGetFileList(options, ['update', '--revision', 'BASE'],
base_path, mox.IgnoreArg()) base_path, mox.IgnoreArg())
print(os.path.join(base_path, 'a')) print(os.path.join(base_path, 'a'))
print(os.path.join(base_path, 'b')) print(os.path.join(base_path, 'b'))
@ -161,7 +161,7 @@ class SVNWrapperTestCase(gclient_test.GClientBaseTestCase):
gclient_scm.os.path.isdir(file_path).AndReturn(True) gclient_scm.os.path.isdir(file_path).AndReturn(True)
gclient_utils.RemoveDirectory(file_path) gclient_utils.RemoveDirectory(file_path)
file_list1 = [] file_list1 = []
gclient_scm.RunSVNAndGetFileList(['update', '--revision', 'BASE'], gclient_scm.RunSVNAndGetFileList(options, ['update', '--revision', 'BASE'],
base_path, mox.IgnoreArg()) base_path, mox.IgnoreArg())
self.mox.ReplayAll() self.mox.ReplayAll()
@ -174,8 +174,8 @@ class SVNWrapperTestCase(gclient_test.GClientBaseTestCase):
options = self.Options(verbose=True) options = self.Options(verbose=True)
base_path = os.path.join(self.root_dir, self.relpath) base_path = os.path.join(self.root_dir, self.relpath)
gclient.os.path.isdir(base_path).AndReturn(True) gclient.os.path.isdir(base_path).AndReturn(True)
gclient_scm.RunSVNAndGetFileList(['status'] + self.args, base_path, gclient_scm.RunSVNAndGetFileList(options, ['status'] + self.args,
[]).AndReturn(None) base_path, []).AndReturn(None)
self.mox.ReplayAll() self.mox.ReplayAll()
scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
@ -198,8 +198,8 @@ class SVNWrapperTestCase(gclient_test.GClientBaseTestCase):
# Checkout. # Checkout.
gclient.os.path.exists(base_path).AndReturn(False) gclient.os.path.exists(base_path).AndReturn(False)
files_list = self.mox.CreateMockAnything() files_list = self.mox.CreateMockAnything()
gclient_scm.RunSVNAndGetFileList(['checkout', self.url, base_path], gclient_scm.RunSVNAndGetFileList(options, ['checkout', self.url,
self.root_dir, files_list) base_path], self.root_dir, files_list)
self.mox.ReplayAll() self.mox.ReplayAll()
scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
relpath=self.relpath) relpath=self.relpath)
@ -227,7 +227,8 @@ class SVNWrapperTestCase(gclient_test.GClientBaseTestCase):
if options.manually_grab_svn_rev: if options.manually_grab_svn_rev:
additional_args = ['--revision', str(file_info['Revision'])] additional_args = ['--revision', str(file_info['Revision'])]
files_list = [] files_list = []
gclient_scm.RunSVNAndGetFileList(['update', base_path] + additional_args, gclient_scm.RunSVNAndGetFileList(options,
['update', base_path] + additional_args,
self.root_dir, files_list) self.root_dir, files_list)
self.mox.ReplayAll() self.mox.ReplayAll()

Loading…
Cancel
Save