| Index: git_common.py
|
| diff --git a/git_common.py b/git_common.py
|
| index fa6d3fc75556b1e4a9a61724315eee4ab4fd9f7c..71db99a8489fea82219c43204384c80adc426927 100644
|
| --- a/git_common.py
|
| +++ b/git_common.py
|
| @@ -153,7 +153,7 @@ def ScopedPool(*args, **kwargs):
|
|
|
| class ProgressPrinter(object):
|
| """Threaded single-stat status message printer."""
|
| - def __init__(self, fmt, enabled=None, stream=sys.stderr, period=0.5):
|
| + def __init__(self, fmt, enabled=None, fout=sys.stderr, period=0.5):
|
| """Create a ProgressPrinter.
|
|
|
| Use it as a context manager which produces a simple 'increment' method:
|
| @@ -169,7 +169,7 @@ class ProgressPrinter(object):
|
| should go.
|
| enabled (bool) - If this is None, will default to True if
|
| logging.getLogger() is set to INFO or more verbose.
|
| - stream (file-like) - The stream to print status messages to.
|
| + fout (file-like) - The stream to print status messages to.
|
| period (float) - The time in seconds for the printer thread to wait
|
| between printing.
|
| """
|
| @@ -182,7 +182,7 @@ class ProgressPrinter(object):
|
| self._count = 0
|
| self._dead = False
|
| self._dead_cond = threading.Condition()
|
| - self._stream = stream
|
| + self._stream = fout
|
| self._thread = threading.Thread(target=self._run)
|
| self._period = period
|
|
|
| @@ -256,17 +256,26 @@ def run(*cmd, **kwargs):
|
|
|
| kwargs
|
| autostrip (bool) - Strip the output. Defaults to True.
|
| - Output string is always strip()'d.
|
| """
|
| autostrip = kwargs.pop('autostrip', True)
|
| - cmd = (GIT_EXE,) + cmd
|
| - logging.debug('Running %s', ' '.join(repr(tok) for tok in cmd))
|
| - ret = subprocess2.check_output(cmd, stderr=subprocess2.PIPE, **kwargs)
|
| + ret = stream(*cmd, **kwargs).read()
|
| if autostrip:
|
| ret = (ret or '').strip()
|
| return ret
|
|
|
|
|
| +def stream(*cmd, **kwargs):
|
| + """Runs a git command. Returns stdout as a file.
|
| +
|
| + If logging is DEBUG, we'll print the command before we run it.
|
| + """
|
| + cmd = (GIT_EXE,) + cmd
|
| + logging.debug('Running %s', ' '.join(repr(tok) for tok in cmd))
|
| + proc = subprocess2.Popen(cmd, stderr=subprocess2.VOID,
|
| + stdout=subprocess2.PIPE, **kwargs)
|
| + return proc.stdout
|
| +
|
| +
|
| def hash_one(reflike):
|
| return run('rev-parse', reflike)
|
|
|
|
|