From 7f61350080cf766007525ed8007658d3ba1ace3f Mon Sep 17 00:00:00 2001 From: "szager@google.com" Date: Mon, 3 Oct 2011 21:46:28 +0000 Subject: [PATCH] http://codereview.chromium.org/8052025/ git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@103787 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient_scm.py | 22 ++++++++++++++++++---- gclient_utils.py | 3 +++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gclient_scm.py b/gclient_scm.py index e2a0bdd65..b64bf2686 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -494,7 +494,7 @@ class GitWrapper(SCMWrapper): # to stdout print('') - clone_cmd = ['clone'] + clone_cmd = ['clone', '--progress'] if revision.startswith('refs/heads/'): clone_cmd.extend(['-b', revision.replace('refs/heads/', '')]) detach_head = False @@ -510,9 +510,20 @@ class GitWrapper(SCMWrapper): if not os.path.exists(parent_dir): os.makedirs(parent_dir) + percent_re = re.compile('.* ([0-9]{1,2})% .*') + def _GitFilter(line): + # git uses an escape sequence to clear the line; elide it. + esc = line.find(unichr(033)) + if esc > -1: + line = line[:esc] + match = percent_re.match(line) + if not match or not int(match.group(1)) % 10: + print '%s' % line + for _ in range(3): try: - self._Run(clone_cmd, options, cwd=self._root_dir) + self._Run(clone_cmd, options, cwd=self._root_dir, filter_fn=_GitFilter, + print_stdout=False) break except subprocess2.CalledProcessError, e: # Too bad we don't have access to the actual output yet. @@ -679,8 +690,11 @@ class GitWrapper(SCMWrapper): def _Run(self, args, options, **kwargs): kwargs.setdefault('cwd', self.checkout_path) - gclient_utils.CheckCallAndFilterAndHeader(['git'] + args, - always=options.verbose, **kwargs) + kwargs.setdefault('print_stdout', True) + stdout = kwargs.get('stdout', sys.stdout) + stdout.write('\n________ running \'%s\' in \'%s\'\n' % ( + ' '.join(args), kwargs['cwd'])) + gclient_utils.CheckCallAndFilter(['git'] + args, **kwargs) class SVNWrapper(SCMWrapper): diff --git a/gclient_utils.py b/gclient_utils.py index 2402519a3..7404f37ae 100644 --- a/gclient_utils.py +++ b/gclient_utils.py @@ -358,6 +358,9 @@ def CheckCallAndFilter(args, stdout=None, filter_fn=None, else: filter_fn(in_line) in_line = '' + else: + filter_fn(in_line) + in_line = '' in_byte = kid.stdout.read(1) # Flush the rest of buffered output. This is only an issue with # stdout/stderr not ending with a \n.