# HG changeset patch # User Jelmer Vernooij # Date 1320962950 -3600 # Node ID 76bd0ea8add33897e207da6899e9ec7459ab87a2 # Parent a1558739bd5e010efde1a6a5cee906aded22e93a Update to cope with API differences. diff -r a1558739bd5e -r 76bd0ea8add3 hgfastimport/__init__.py --- a/hgfastimport/__init__.py Thu Nov 10 23:02:14 2011 +0100 +++ b/hgfastimport/__init__.py Thu Nov 10 23:09:10 2011 +0100 @@ -1,8 +1,7 @@ -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): diff -r a1558739bd5e -r 76bd0ea8add3 hgfastimport/hgimport.py --- a/hgfastimport/hgimport.py Thu Nov 10 23:02:14 2011 +0100 +++ b/hgfastimport/hgimport.py Thu Nov 10 23:09:10 2011 +0100 @@ -22,6 +22,8 @@ import os import shutil +import stat +import sys from hgext.convert import common, hg as converthg @@ -123,9 +125,20 @@ 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): @@ -303,8 +316,7 @@ 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]) @@ -400,12 +412,12 @@ 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)