# HG changeset patch # User Scott Chacon <schacon@gmail.com> # Date 1241841273 25200 # Fri May 08 20:54:33 2009 -0700 # Node ID 52b4be85151da39ad52a0f53a73c773346328185 # Parent babc85201dc4a84d79d2c14a1ddd1c369e9eee15 fixed some small compatability issues with the dulwich update diff --git a/dulwich/client.py b/dulwich/client.py --- 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, ) diff --git a/dulwich/index.py b/dulwich/index.py --- 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, diff --git a/dulwich/object_store.py b/dulwich/object_store.py --- 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 diff --git a/dulwich/objects.py b/dulwich/objects.py --- 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 diff --git a/dulwich/repo.py b/dulwich/repo.py --- 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): diff --git a/git_handler.py b/git_handler.py --- 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]