hgext/convert/git.py
branchstable
changeset 21868 3420346174b1
parent 20373 e8203629371b
child 21873 cf599f8a2da8
--- a/hgext/convert/git.py	Mon Jul 14 12:44:45 2014 -0500
+++ b/hgext/convert/git.py	Mon Jul 14 23:33:59 2014 +0900
@@ -104,6 +104,8 @@
         return data
 
     def getfile(self, name, rev):
+        if rev == hex(nullid):
+            raise IOError
         if name == '.hgsub':
             data = '\n'.join([m.hgsub() for m in self.submoditer()])
             mode = ''
@@ -155,6 +157,7 @@
         seen = set()
         entry = None
         subexists = False
+        subdeleted = False
         for l in fh.read().split('\x00'):
             if not entry:
                 if not l.startswith(':'):
@@ -171,7 +174,11 @@
 
                 if f == '.gitmodules':
                     subexists = True
-                    changes.append(('.hgsub', ''))
+                    if entry[4] == 'D':
+                        subdeleted = True
+                        changes.append(('.hgsub', hex(nullid)))
+                    else:
+                        changes.append(('.hgsub', ''))
                 elif entry[1] == '160000' or entry[0] == ':160000':
                     subexists = True
                 else:
@@ -182,8 +189,11 @@
             raise util.Abort(_('cannot read changes in %s') % version)
 
         if subexists:
-            self.retrievegitmodules(version)
-            changes.append(('.hgsubstate', ''))
+            if subdeleted:
+                changes.append(('.hgsubstate', hex(nullid)))
+            else:
+                self.retrievegitmodules(version)
+                changes.append(('.hgsubstate', ''))
         return (changes, {})
 
     def getcommit(self, version):