16 #log('oldsize=%d+%d adding=%d\n' % (len(self.data), self.start, len(s)))
18 self.data = buffer(self.data, self.start) + s
21 def peek(self, count):
22 return buffer(self.data, self.start, count)
28 v = buffer(self.data, self.start, count)
33 return len(self.data) - self.start
37 b = buf.peek(buf.used())
38 ofs = chashsplit.splitbuf(b)
41 return buffer(b, 0, ofs)
52 yield '' # EOF indicator
55 def autofiles(filenames):
63 def hashsplit_iter(files):
71 while blob or not eof:
72 if not eof and (buf.used() < BLOB_LWM or not blob):
75 #log('got %d, total %d\n' % (len(bnew), buf.used()))
80 blob = buf.get(buf.used())
81 if not blob and buf.used() >= BLOB_MAX:
82 blob = buf.get(buf.used()) # limit max blob size
83 if not blob and not eof:
87 yield (ofs, len(blob), git.hash_blob(blob))
90 nv = (ofs + buf.used())/1000000
97 def split_to_shalist(files):
101 for (ofs, size, sha) in hashsplit_iter(files):
102 #log('SPLIT @ %-8d size=%-8d\n' % (ofs, size))
103 # this silliness keeps chunk filenames "similar" when a file changes
108 #log('%x,%x,%x,%x\n' % (last_ofs,ofs,cn,bm))
109 if cn > last_ofs or ofs == last_ofs: break
113 yield ('100644', 'bup.chunk.%016x' % cn, sha)
116 def split_to_tree(files):
117 shalist = list(split_to_shalist(files))
118 tree = git.gen_tree(shalist)
119 return (shalist, tree)
122 def split_to_blob_or_tree(files):
123 (shalist, tree) = split_to_tree(files)
124 if len(shalist) == 1:
125 return (shalist[0][0], shalist[0][2])
126 elif len(shalist) == 0:
127 return ('100644', git.hash_blob(''))
129 return ('40000', tree)