Index: gclient_scm.py |
diff --git a/gclient_scm.py b/gclient_scm.py |
index 4befa33386cf5780de454a076e5bd6d67e8ae041..0389f466203b86413e0253ab9095d4cd422fe8ad 100644 |
--- a/gclient_scm.py |
+++ b/gclient_scm.py |
@@ -12,7 +12,6 @@ import re |
import sys |
import tempfile |
import threading |
-import time |
import traceback |
import urlparse |
@@ -143,43 +142,6 @@ class SCMWrapper(object): |
return getattr(self, command)(options, args, file_list) |
-class GitFilter(object): |
- """A filter_fn implementation for quieting down git output messages. |
- |
- Allows a custom function to skip certain lines (predicate), and will throttle |
- the output of percentage completed lines to only output every X seconds. |
- """ |
- PERCENT_RE = re.compile('.* ([0-9]{1,2})% .*') |
- |
- def __init__(self, time_throttle=0, predicate=None): |
- """ |
- Args: |
- time_throttle (int): GitFilter will throttle 'noisy' output (such as the |
- XX% complete messages) to only be printed at least |time_throttle| |
- seconds apart. |
- predicate (f(line)): An optional function which is invoked for every line. |
- The line will be skipped if predicate(line) returns False. |
- """ |
- self.last_time = 0 |
- self.time_throttle = time_throttle |
- self.predicate = predicate |
- |
- def __call__(self, line): |
- # git uses an escape sequence to clear the line; elide it. |
- esc = line.find(unichr(033)) |
- if esc > -1: |
- line = line[:esc] |
- if self.predicate and not self.predicate(line): |
- return |
- now = time.time() |
- match = self.PERCENT_RE.match(line) |
- if not match: |
- self.last_time = 0 |
- if (now - self.last_time) >= self.time_throttle: |
- self.last_time = now |
- print line |
- |
- |
class GitWrapper(SCMWrapper): |
"""Wrapper for Git""" |
name = 'git' |
@@ -1064,7 +1026,7 @@ class GitWrapper(SCMWrapper): |
kwargs.setdefault('cwd', self.checkout_path) |
git_filter = not options.verbose |
if git_filter: |
- kwargs['filter_fn'] = GitFilter(kwargs.get('filter_fn')) |
+ kwargs['filter_fn'] = gclient_utils.GitFilter(kwargs.get('filter_fn')) |
kwargs.setdefault('print_stdout', False) |
# Don't prompt for passwords; just fail quickly and noisily. |
# By default, git will use an interactive terminal prompt when a username/ |