Mercurial > hg > hg-fastimport
diff hgfastimport/hgimport.py @ 62:76bd0ea8add3
Update to cope with API differences.
| author | Jelmer Vernooij <jelmer@samba.org> |
|---|---|
| date | Thu, 10 Nov 2011 23:09:10 +0100 |
| parents | a88f0dd05e92 |
| children | ae32828c68d7 |
line wrap: on
line diff
--- 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)
