Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1517)

Unified Diff: gclient_scm.py

Issue 164823002: Create "git cache" command. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Shallow fetches and other improvements Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gclient_utils.py » ('j') | git-cache » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_scm.py
diff --git a/gclient_scm.py b/gclient_scm.py
index 2a15abe5f810357d94dc68b58f5df181ff9576eb..dc2fc87c3966b99e783c7623ece4e631b1ecadaf 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -12,7 +12,6 @@ import re
import sys
import tempfile
import threading
-import time
import urlparse
import download_from_google_storage
@@ -142,43 +141,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'
@@ -1032,7 +994,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/
« no previous file with comments | « no previous file | gclient_utils.py » ('j') | git-cache » ('J')

Powered by Google App Engine
This is Rietveld 408576698