def test_simple(self): stream = BytesIO(simple_fast_import_stream) outf = StringIO() proc = info_processor.InfoProcessor(outf=outf) p = parser.ImportParser(stream) proc.process(p.iter_commands) self.maxDiff = None self.assertEqual(outf.getvalue(), """Command counts: \t0\tblob \t0\tcheckpoint \t1\tcommit \t0\tfeature \t0\tprogress \t0\treset \t0\ttag File command counts: \t0\tfilemodify \t0\tfiledelete \t0\tfilecopy \t0\tfilerename \t0\tfiledeleteall Parent counts: \t1\tparents-0 \t0\ttotal revisions merged Commit analysis: \tno\tblobs referenced by SHA \tno\texecutables \tno\tseparate authors found \tno\tsymlinks Head analysis: \t:1\trefs/heads/master Merges: """)
def _generate_info(self, source): from io import StringIO from fastimport import parser from fastimport.errors import ParsingError from ...errors import CommandError from fastimport.processors import info_processor stream = _get_source_stream(source) output = StringIO() try: proc = info_processor.InfoProcessor(verbose=True, outf=output) p = parser.ImportParser(stream) try: return_code = proc.process(p.iter_commands) except ParsingError as e: raise CommandError("%d: Parse error: %s" % (e.lineno, e)) lines = output.getvalue().splitlines() finally: output.close() stream.seek(0) return lines