Ejemplo n.º 1
0
 def gc_action(sha, obj):
     idx[sha] = off[0]
     t = babygit.obj_type(obj)
     s = babygit.obj_size(obj)
     enc_t_s = self.encode_type_and_size(t, s)
     pack.write(enc_t_s)
     off[0] += len(enc_t_s)
     compressed = zlib.compress(babygit.obj_contents(obj))
     pack.write(compressed)
     off[0] += len(compressed)
Ejemplo n.º 2
0
 def gc_action(sha, obj):
     idx[sha] = off[0]
     t = babygit.obj_type(obj)
     s = babygit.obj_size(obj)
     enc_t_s = self.encode_type_and_size(t, s)
     pack.write(enc_t_s)
     off[0] += len(enc_t_s)
     compressed = zlib.compress(babygit.obj_contents(obj))
     pack.write(compressed)
     off[0] += len(compressed)
Ejemplo n.º 3
0
 def send_packfile(self, objs, out):
     m = hashlib.sha1()
     header = 'PACK' + struct.pack('>II', 2, len(objs))
     out.write(header)
     m.update(header)
     for ref, obj in objs:
         t = babygit.obj_type(obj)
         s = babygit.obj_size(obj)
         #if s != len(babygit.obj_contents(obj)):
         #    logging.debug('size mismatch')
         enc_t_s = self.encode_type_and_size(t, s)
         out.write(enc_t_s)
         m.update(enc_t_s)
         compressed = zlib.compress(babygit.obj_contents(obj))
         out.write(compressed)
         m.update(compressed)
     out.write(m.digest())
Ejemplo n.º 4
0
 def send_packfile(self, objs, out):
     m = hashlib.sha1()
     header = 'PACK' + struct.pack('>II', 2, len(objs))
     out.write(header)
     m.update(header)
     for ref, obj in objs:
         t = babygit.obj_type(obj)
         s = babygit.obj_size(obj)
         #if s != len(babygit.obj_contents(obj)):
         #    logging.debug('size mismatch')
         enc_t_s = self.encode_type_and_size(t, s)
         out.write(enc_t_s)
         m.update(enc_t_s)
         compressed = zlib.compress(babygit.obj_contents(obj))
         out.write(compressed)
         m.update(compressed)
     out.write(m.digest())