# HG changeset patch # User Scott Chacon # Date 1241031056 25200 # Node ID 5deb5cbd86aae38b5d32b2fadd9671712061f689 # Parent 87d462a6b796c3d7efd0b96f0587fa5f8a9a486e respecting file modes on git import diff --git a/TODO.txt b/TODO.txt --- a/TODO.txt +++ b/TODO.txt @@ -1,6 +1,5 @@ GENERAL ========== -* respect file modes on conversions * explicit file renames * integrate as native protocol handler (hg push git://...) * more tests diff --git a/dulwich/repo.py b/dulwich/repo.py --- a/dulwich/repo.py +++ b/dulwich/repo.py @@ -417,6 +417,7 @@ changes = list() csha = None ctree = None + cmode = None if basetree: for (bmode, bname, bsha) in basetree.entries(): if bmode == 57344: # TODO : properly handle submodules @@ -425,7 +426,7 @@ bobj = self.get_object(bsha) if comptree: (cmode, csha) = comptree.entry(bname) - if csha != bsha: + if not ((csha == bsha) and (cmode == bmode)): if isinstance (bobj, Blob): changes.append (prefix + bname) elif isinstance(bobj, Tree): diff --git a/git_handler.py b/git_handler.py --- a/git_handler.py +++ b/git_handler.py @@ -424,6 +424,15 @@ except AttributeError: self.repo.ui.warn('creating bookmarks failed, do you have' ' bookmarks enabled?\n') + + def convert_git_int_mode(self, mode): + convert = { + 33188: '', + 40960: 'l', + 33261: 'e'} + if mode in convert: + return convert[mode] + return '' def import_git_commit(self, commit): print "importing: " + commit.id @@ -435,10 +444,10 @@ # get_file call for removed files def getfilectx(repo, memctx, f): try: - (e, sha, data) = self.git.get_file(commit, f) + (mode, sha, data) = self.git.get_file(commit, f) + e = self.convert_git_int_mode(mode) except TypeError: raise IOError() - e = '' # TODO : make this a real mode return context.memfilectx(f, data, 'l' in e, 'x' in e, None) p1 = "0" * 40