summaryrefslogtreecommitdiff
path: root/lib/git/utils.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-03 23:20:34 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-03 23:20:34 +0200
commit1e2b46138ba58033738a24dadccc265748fce2ca (patch)
tree0f2a625a371c16cc95e53e024e007d8b89d87c92 /lib/git/utils.py
parent4b4a514e51fbc7dc6ddcb27c188159d57b5d1fa9 (diff)
downloadgitpython-1e2b46138ba58033738a24dadccc265748fce2ca.tar.gz
commit.create_from_tree now uses pure python implementation, fixed message parsing which truncated newlines although it was ilegitimate. Its up to the reader to truncate therse, nowhere in the git code I could find anyone adding newlines to commits where it is written
Added performance tests for serialization, it does about 5k commits per second if writing to tmpfs
Diffstat (limited to 'lib/git/utils.py')
-rw-r--r--lib/git/utils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/git/utils.py b/lib/git/utils.py
index 360c77c9..60a7de48 100644
--- a/lib/git/utils.py
+++ b/lib/git/utils.py
@@ -27,6 +27,21 @@ def make_sha(source=''):
sha1 = sha.sha(source)
return sha1
+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."""