summaryrefslogtreecommitdiff
path: root/lib/git/utils.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-18 16:20:27 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-18 16:20:27 +0200
commitb82dbf538ac0d03968a0f5b7e2318891abefafaa (patch)
tree3ee7f95497cba4bdfc19c65e5677f7b0489affb8 /lib/git/utils.py
parente837b901dcfac82e864f806c80f4a9cbfdb9c9f3 (diff)
downloadgitpython-b82dbf538ac0d03968a0f5b7e2318891abefafaa.tar.gz
GitCmd implementation of gitdb base moved to git-python where it belongs. Previously it was located in gitdb, which doesn't have any facilities to use the git command
Diffstat (limited to 'lib/git/utils.py')
-rw-r--r--lib/git/utils.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/git/utils.py b/lib/git/utils.py
index bd7cc0f3..3fb7fbf8 100644
--- a/lib/git/utils.py
+++ b/lib/git/utils.py
@@ -10,7 +10,6 @@ import time
import tempfile
from gitdb.util import (
- stream_copy,
make_sha,
FDStreamWrapper,
LockedFD,
@@ -19,6 +18,21 @@ from gitdb.util import (
)
+def stream_copy(source, destination, chunk_size=512*1024):
+ """Copy all data from the source stream into the destination stream in chunks
+ of size chunk_size
+
+ :return: amount of bytes written"""
+ br = 0
+ while True:
+ chunk = source.read(chunk_size)
+ destination.write(chunk)
+ br += len(chunk)
+ if len(chunk) < chunk_size:
+ break
+ # END reading output stream
+ return br
+
def join_path(a, *p):
"""Join path tokens together similar to os.path.join, but always use
'/' instead of possibly '\' on windows."""