conn.ok()
return
+ sha = conn.read(20)
+ n -= 20
buf = conn.read(n) # object sizes in bup are reasonably small
#debug2('read %d bytes\n' % n)
if len(buf) < n:
w.abort()
raise Exception('object read: expected %d bytes, got %d\n'
% (n, len(buf)))
- (type, content) = git._decode_packobj(buf)
- sha = git.calc_hash(type, content)
oldpack = w.exists(sha)
# FIXME: we only suggest a single index per cycle, because the client
# is currently too dumb to download more than one per cycle anyway.
def abort(self):
raise GitError("don't know how to abort remote pack writing")
- def _raw_write(self, datalist):
+ def _raw_write(self, datalist, sha=''):
assert(self.file)
if not self._packopen:
self._open()
self.ensure_busy()
data = ''.join(datalist)
assert(len(data))
- outbuf = struct.pack('!I', len(data)) + data
+ outbuf = ''.join((struct.pack('!I', len(data)+len(sha)), sha, data))
(self._bwcount, self._bwtime) = \
_raw_write_bwlimit(self.file, outbuf, self._bwcount, self._bwtime)
self.outbytes += len(data)
if self.suggest_pack:
self.suggest_pack(idxname)
self.objcache.refresh()
+
+ def _write(self, bin, type, content):
+ if git.verbose:
+ log('>')
+ sha = git.calc_hash(type, content)
+ enc = git._encode_packobj(type, content)
+ self._raw_write(enc, sha=sha)
+ return bin