changeset 14:f6f0fd01b34a

Preliminary support for reading multiple input files.
author Greg Ward <greg-hg@gerg.ca>
date Thu, 02 Apr 2009 17:16:02 -0400
parents 9c7d88b94b08
children e19d2ce18eeb
files fastimport/__init__.py fastimport/processor.py
diffstat 2 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/fastimport/__init__.py	Thu Apr 02 17:14:03 2009 -0400
+++ b/fastimport/__init__.py	Thu Apr 02 17:16:02 2009 -0400
@@ -4,17 +4,23 @@
 import hgechoprocessor
 import hgimport
 
-def fastimport(ui, repo, source, **opts):
-    ui.write("Source is %s\n" % source)
-    f = open(source)
+def fastimport(ui, repo, *sources, **opts):
     proc = hgimport.HgImportProcessor(ui, repo, **opts)
     #proc = hgechoprocessor.HgEchoProcessor(ui, repo, **opts)
-    p = parser.ImportParser(f)
-    proc.process(p.iter_commands)
+    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()
 
 cmdtable = {
     "fastimport":
         (fastimport,
          [],
-         'hg fastimport SOURCE')
+         'hg fastimport SOURCE ...')
 }
--- a/fastimport/processor.py	Thu Apr 02 17:14:03 2009 -0400
+++ b/fastimport/processor.py	Thu Apr 02 17:16:02 2009 -0400
@@ -32,11 +32,14 @@
     methods as appropriate.
     """
     
+    # XXX this is useless now that we process multiple input streams:
+    # we only want to call setup() and teardown() once for all of them!
     def process(self, command_iter):
         """Process the stream of commands.
 
         :param command_iter: an iterator providing commands
         """
+        raise RuntimeError("hey! who's calling this?!?")
         self.setup()
         try:
             self._process(command_iter)