Permalink
Browse files

Merge fixes from abderrahim.

  • Loading branch information...
2 parents 15c10cb + 2b66c38 commit 8a15645c08a8bd8b61fe1fbc84162b952343f6ec @jelmer jelmer committed Jul 22, 2009
Showing with 26 additions and 14 deletions.
  1. +6 −0 NEWS
  2. +2 −5 bin/dulwich
  3. +2 −1 dulwich/object_store.py
  4. +3 −0 dulwich/objects.py
  5. +2 −2 dulwich/pack.py
  6. +7 −6 dulwich/server.py
  7. +4 −0 dulwich/tests/test_objects.py
View
6 NEWS
@@ -1,3 +1,9 @@
+0.3.3 UNRELEASED
+
+ FEATURES
+
+ * Implement ShaFile.__hash__().
+
0.3.2 2009-05-20
BUG FIXES
View
@@ -43,12 +43,9 @@ def cmd_fetch_pack(args):
graphwalker = r.get_graph_walker()
f, commit = r.object_store.add_pack()
try:
- client.fetch_pack(path, determine_wants, graphwalker, f.write, sys.stdout.write)
- f.close()
+ client.fetch_pack(path, determine_wants, graphwalker, f.write, sys.stdout.write)
+ finally:
commit()
- except:
- f.close()
- raise
def cmd_log(args):
View
@@ -36,6 +36,7 @@
Tree,
hex_to_sha,
sha_to_hex,
+ S_ISGITLINK,
)
from dulwich.pack import (
Pack,
@@ -505,7 +506,7 @@ def add_todo(self, entries):
self.objects_to_send.update([e for e in entries if not e[0] in self.sha_done])
def parse_tree(self, tree):
- self.add_todo([(sha, name, not stat.S_ISDIR(mode)) for (mode, name, sha) in tree.entries()])
+ self.add_todo([(sha, name, not stat.S_ISDIR(mode)) for (mode, name, sha) in tree.entries() if not S_ISGITLINK(mode)])
def parse_commit(self, commit):
self.add_todo([(commit.tree, "", False)])
View
@@ -128,6 +128,9 @@ def as_raw_string(self):
def __str__(self):
return self.as_raw_string()
+ def __hash__(self):
+ return hash(self.id)
+
def as_pretty_string(self):
return self.as_raw_string()
View
@@ -772,7 +772,7 @@ def write_pack_object(f, type, object):
:param o: Object to write
:return: Tuple with offset at which the object was written, and crc32
"""
- ret = f.tell()
+ offset = f.tell()
packed_data_hdr = ""
if type == 6: # ref delta
(delta_base_offset, object) = object
@@ -799,7 +799,7 @@ def write_pack_object(f, type, object):
packed_data_hdr += basename
packed_data = packed_data_hdr + zlib.compress(object)
f.write(packed_data)
- return (f.tell(), (zlib.crc32(packed_data) & 0xffffffff))
+ return (offset, (zlib.crc32(packed_data) & 0xffffffff))
def write_pack(filename, objects, num_objects):
View
@@ -77,16 +77,17 @@ def __init__(self, gitdir=None):
self.get_refs = self.repo.get_refs
def apply_pack(self, refs, read):
- fd, commit = self.repo.object_store.add_thin_pack()
- fd.write(read())
- fd.close()
- commit()
+ f, commit = self.repo.object_store.add_thin_pack()
+ try:
+ f.write(read())
+ finally:
+ commit()
for oldsha, sha, ref in refs:
if ref == "0" * 40:
- self.repo.remove_ref(ref)
+ del self.repo.refs[ref]
else:
- self.repo.set_ref(ref, sha)
+ self.repo.refs[ref] = sha
print "pack applied"
@@ -66,6 +66,10 @@ def test_decompress_simple_blob(self):
self.assertEqual(b.data, 'test 1\n')
self.assertEqual(b.sha().hexdigest(), a_sha)
+ def test_hash(self):
+ b = self.get_blob(a_sha)
+ self.assertEqual(hash(b.id), hash(b))
+
def test_parse_empty_blob_object(self):
sha = 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'
b = self.get_blob(sha)

0 comments on commit 8a15645

Please sign in to comment.