Commits

Jelmer Vernooij committed 76bd0ea

Update to cope with API differences.

Comments (0)

Files changed (2)

hgfastimport/__init__.py

-from mercurial import encoding
+from mercurial import encoding, util
 from mercurial.i18n import _
 from hgext.convert import convcmd, hg
 
-from fastimport import parser
 from hgfastimport.hgimport import fastimport_source
 
 def fastimport(ui, repo, *sources, **opts):

hgfastimport/hgimport.py

 
 import os
 import shutil
+import stat
+import sys
 
 from hgext.convert import common, hg as converthg
 
     def _parse(self):
         if self.parsed:
             return
-        processor.parseMany(self.sources, parser.ImportParser, self.processor)
+        for source in self.sources:
+            if source == "-":
+                infile = sys.stdin
+            else:
+                infile = open(source, 'rb')
+            try:
+                p = parser.ImportParser(infile)
+                self.processor.process(p.iter_commands)
+            finally:
+                if infile is not sys.stdin:
+                    infile.close()
         self.parsed = True
 
+
 class HgImportProcessor(processor.ImportProcessor):
     
     def __init__(self, ui, repo):
         else:
             user = "%s <%s>" % (userinfo[0], userinfo[1])
 
-        assert type(cmd.message) is unicode
-        text = cmd.message.encode("utf-8")
+        text = cmd.message
         date = self.convert_date(userinfo)
 
         parents = filter(None, [first_parent, second_parent])
         fileid = (self.command.id, blobid)
 
         self.modified.append((filecmd.path, fileid))
-        if filecmd.mode.endswith("644"): # normal file
+        if stat.S_ISLNK(filecmd.mode): # link
+            mode = 'l'
+        elif filecmd.mode & 0111: # executable
+            mode = 'x'
+        elif stat.S_ISREG(filecmd.mode): # regular file
             mode = ''
-        elif filecmd.mode.endswith("755"): # executable
-            mode = 'x'
-        elif filecmd.mode == "120000":  # symlink
-            mode = 'l'
         else:
             raise RuntimeError("mode %r unsupported" % filecmd.mode)