changeset 88:52b4be85151d

fixed some small compatability issues with the dulwich update
author Scott Chacon <schacon@gmail.com>
date Fri, 08 May 2009 20:54:33 -0700
parents babc85201dc4
children e35ed99fa691
files dulwich/client.py dulwich/index.py dulwich/object_store.py dulwich/objects.py dulwich/repo.py git_handler.py
diffstat 6 files changed, 24 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/dulwich/client.py
+++ b/dulwich/client.py
@@ -26,15 +26,15 @@
 import socket
 import subprocess
 
-from dulwich.errors import (
+from errors import (
     ChecksumMismatch,
     )
-from dulwich.protocol import (
+from protocol import (
     Protocol,
     TCP_GIT_PORT,
     extract_capabilities,
     )
-from dulwich.pack import (
+from pack import (
     write_pack_data,
     )
 
--- a/dulwich/index.py
+++ b/dulwich/index.py
@@ -22,7 +22,7 @@
 import stat
 import struct
 
-from dulwich.objects import (
+from objects import (
     Tree,
     hex_to_sha,
     sha_to_hex,
--- a/dulwich/object_store.py
+++ b/dulwich/object_store.py
@@ -260,8 +260,8 @@
         fd, path = tempfile.mkstemp(dir=self.pack_dir, suffix=".pack")
         f = os.fdopen(fd, 'w')
         def commit():
-            os.fsync(fd)
-            f.close()
+            #os.fsync(fd)
+            #f.close()
             if os.path.getsize(path) > 0:
                 self.move_in_thin_pack(path)
         return f, commit
@@ -275,8 +275,8 @@
         fd, path = tempfile.mkstemp(dir=self.pack_dir, suffix=".pack")
         f = os.fdopen(fd, 'w')
         def commit():
-            os.fsync(fd)
-            f.close()
+            #os.fsync(fd)
+            #f.close()
             if os.path.getsize(path) > 0:
                 self.move_in_pack(path)
         return f, commit
--- a/dulwich/objects.py
+++ b/dulwich/objects.py
@@ -428,6 +428,12 @@
         del self._entries[name]
         self._needs_serialization = True
 
+    def entry(self, name):
+        try:
+            return self._entries[name]
+        except:
+            return (None, None)
+        
     def add(self, mode, name, hexsha):
         assert type(mode) == int
         assert type(name) == str
@@ -648,7 +654,7 @@
 
 try:
     # Try to import C versions
-    from dulwich._objects import hex_to_sha, sha_to_hex, parse_tree
+    from _objects import hex_to_sha, sha_to_hex
 except ImportError:
     pass
 
--- a/dulwich/repo.py
+++ b/dulwich/repo.py
@@ -31,7 +31,7 @@
     NotGitRepository,
     NotTreeError,
     )
-from object_store import ObjectStore
+from object_store import DiskObjectStore
 from objects import (
     Blob,
     Commit,
@@ -119,7 +119,7 @@
 
     def open_index(self):
         """Open the index for this repository."""
-        from dulwich.index import Index
+        from index import Index
         return Index(self.index_path())
 
     def has_index(self):
--- a/git_handler.py
+++ b/git_handler.py
@@ -321,9 +321,9 @@
             changed_refs = client.send_pack(path, changed, genpack)
             if changed_refs:
                 new_refs = {}
-                for old, new, ref in changed_refs:
-                    self.ui.status("    "+ remote_name + "::" + ref + " : GIT:" + old[0:8] + " => GIT:" + new[0:8] + "\n")
-                    new_refs[ref] = new
+                for ref, sha in changed_refs.iteritems():
+                    self.ui.status("    "+ remote_name + "::" + ref + " => GIT:" + sha[0:8] + "\n")
+                    new_refs[ref] = sha
                 self.git.set_remote_refs(new_refs, remote_name)
                 self.update_hg_bookmarks(remote_name)
         except:
@@ -336,13 +336,13 @@
     def get_changed_refs(self, refs):
         keys = refs.keys()
 
-        changed = []
+        changed = {}
         if not keys:
             return None
 
         # TODO : this is a huge hack
         if keys[0] == 'capabilities^{}': # nothing on the server yet - first push
-            changed.append(("0"*40, self.git.ref('master'), 'refs/heads/master'))
+            changed['refs/heads/master'] = self.git.ref('master')
 
         for ref_name in keys:
             parts = ref_name.split('/')
@@ -352,7 +352,7 @@
                     local_ref = self.git.ref(ref_name)
                     if local_ref:
                         if not local_ref == refs[ref_name]:
-                            changed.append((refs[ref_name], local_ref, ref_name))
+                            changed[ref_name] = local_ref
         return changed
 
     # takes a list of shas the server wants and shas the server has
@@ -509,7 +509,7 @@
             try:
                 (mode, sha, data) = self.git.get_file(commit, f)
                 e = self.convert_git_int_mode(mode)
-            except TypeError:
+            except TypeError, KeyError:
                 raise IOError()
             if f in hg_renames:
                 copied_path = hg_renames[f]