changeset 53:5deb5cbd86aa

respecting file modes on git import
author Scott Chacon <schacon@gmail.com>
date Wed, 29 Apr 2009 11:50:56 -0700
parents 87d462a6b796
children f6e11b9d7562
files TODO.txt dulwich/repo.py git_handler.py
diffstat 3 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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):
--- 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