Skip to content

Commit

Permalink
merge trivial fixes from Abderrahim.
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed Jul 29, 2009
2 parents b3edb70 + 5bed9d2 commit 10aa4eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions dulwich/objects.py
Expand Up @@ -430,6 +430,7 @@ def __delitem__(self, name):
self._needs_serialization = True self._needs_serialization = True


def __len__(self): def __len__(self):
self._ensure_parsed()
return len(self._entries) return len(self._entries)


def add(self, mode, name, hexsha): def add(self, mode, name, hexsha):
Expand Down
10 changes: 5 additions & 5 deletions dulwich/pack.py
Expand Up @@ -774,9 +774,9 @@ def write_pack_object(f, type, object):
""" """
offset = f.tell() offset = f.tell()
packed_data_hdr = "" packed_data_hdr = ""
if type == 6: # ref delta if type == 6: # offset delta
(delta_base_offset, object) = object (delta_base_offset, object) = object
elif type == 7: # offset delta elif type == 7: # ref delta
(basename, object) = object (basename, object) = object
size = len(object) size = len(object)
c = (type << 4) | (size & 15) c = (type << 4) | (size & 15)
Expand Down Expand Up @@ -891,7 +891,7 @@ def write_pack_index_v1(filename, entries, pack_checksum):


def create_delta(base_buf, target_buf): def create_delta(base_buf, target_buf):
"""Use python difflib to work out how to transform base_buf to target_buf. """Use python difflib to work out how to transform base_buf to target_buf.
:param base_buf: Base buffer :param base_buf: Base buffer
:param target_buf: Target buffer :param target_buf: Target buffer
""" """
Expand Down Expand Up @@ -925,12 +925,12 @@ def encode_size(size):
o = i1 o = i1
for i in range(4): for i in range(4):
if o & 0xff << i*8: if o & 0xff << i*8:
scratch += chr(o >> i) scratch += chr((o >> i*8) & 0xff)
op |= 1 << i op |= 1 << i
s = i2 - i1 s = i2 - i1
for i in range(2): for i in range(2):
if s & 0xff << i*8: if s & 0xff << i*8:
scratch += chr(s >> i) scratch += chr((s >> i*8) & 0xff)
op |= 1 << (4+i) op |= 1 << (4+i)
out_buf += chr(op) out_buf += chr(op)
out_buf += scratch out_buf += scratch
Expand Down

0 comments on commit 10aa4eb

Please sign in to comment.