Mercurial > hg > hg-fastimport
diff hgfastimport/__init__.py @ 47:7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
fastimport no longer stages changes in the repository's working copy;
instead, it now works like any other convert source: the imported
history is kept in memory (except for file contents) and then
processed by the 'convert' extension.
| author | Greg Ward <greg-hg@gerg.ca> |
|---|---|
| date | Sat, 16 May 2009 12:57:22 -0400 |
| parents | 08e2157aaa9a |
| children | b027552d517b |
line wrap: on
line diff
--- a/hgfastimport/__init__.py Sun May 10 14:16:02 2009 -0400 +++ b/hgfastimport/__init__.py Sat May 16 12:57:22 2009 -0400 @@ -1,22 +1,42 @@ -from mercurial import commands +from mercurial import encoding +from hgext.convert import convcmd, hg from fastimport import parser -import hgechoprocessor -import hgimport +from hgfastimport.hgimport import fastimport_source def fastimport(ui, repo, *sources, **opts): - proc = hgimport.HgImportProcessor(ui, repo, **opts) - #proc = hgechoprocessor.HgEchoProcessor(ui, repo, **opts) - proc.setup() - try: - for source in sources: - ui.write("Reading source: %s\n" % source) - f = open(source) - p = parser.ImportParser(f) - proc.process(p.iter_commands) - f.close() - finally: - proc.teardown() + """Convert a git fastimport dump into Mercurial changesets. + + Reads a series of SOURCE fastimport dumps and adds the resulting + changes to the current Mercurial repository. + """ + # Would be nice to just call hgext.convert.convcmd.convert() and let + # it take care of things. But syntax and semantics are just a + # little mismatched: + # - fastimport takes multiple source paths (mainly because cvs2git + # produces 2 dump files) + # - fastimport's dest is implicitly the current repo + # + # So for the time being, I have copied bits of convert() over here. + # Boo, hiss. + + # assume fastimport metadata (usernames, commit messages) are + # encoded UTF-8 + convcmd.orig_encoding = encoding.encoding + encoding.encoding = 'UTF-8' + + # sink is the current repo, src is the list of fastimport streams + destc = hg.mercurial_sink(ui, repo.root) + srcc = fastimport_source(ui, repo, sources) + + # TEMP hack to keep old behaviour and minimize test churn + # (this should be an option to fastimport) + opts['datesort'] = True + + # not implemented: filemap, revmapfile + revmapfile = destc.revmapfile() + c = convcmd.converter(ui, srcc, destc, revmapfile, opts) + c.convert() cmdtable = { "fastimport":
