From e4e439b7bba4b6e26bfd2cc4904242ea120aace5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Oct 2011 16:21:02 -0700 Subject: Some refactoring of exporter. --- cmds.py | 10 +++++++--- exporter.py | 10 ++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cmds.py b/cmds.py index 06dc1f7..7e20a1d 100644 --- a/cmds.py +++ b/cmds.py @@ -663,13 +663,17 @@ class cmd_fast_export(Command): import_marks=None, export_marks=None, revision=None, plain=True, rewrite_tag_names=False): load_fastimport() + from bzrlib.branch import Branch from bzrlib.plugins.fastimport import exporter if marks: import_marks = export_marks = marks - exporter = exporter.BzrFastExporter(source, - destination=destination, - git_branch=git_branch, checkpoint=checkpoint, + + # Open the source + branch = Branch.open_containing(source)[0] + outf = exporter._get_output_stream(destination) + exporter = exporter.BzrFastExporter(branch, + outf=outf, git_branch=git_branch, checkpoint=checkpoint, import_marks_file=import_marks, export_marks_file=export_marks, revision=revision, verbose=verbose, plain_format=plain, rewrite_tags=rewrite_tag_names) diff --git a/exporter.py b/exporter.py index 7848c52..e4b5132 100644 --- a/exporter.py +++ b/exporter.py @@ -143,9 +143,10 @@ def sanitize_ref_name_for_git(refname): "_", refname) return new_refname + class BzrFastExporter(object): - def __init__(self, source, destination, git_branch=None, checkpoint=-1, + def __init__(self, source, outf, git_branch=None, checkpoint=-1, import_marks_file=None, export_marks_file=None, revision=None, verbose=False, plain_format=False, rewrite_tags=False): """Export branch data in fast import format. @@ -159,8 +160,8 @@ class BzrFastExporter(object): Otherwise tags which aren't valid for git will be skipped if plain_format is set. """ - self.source = source - self.outf = _get_output_stream(destination) + self.branch = source + self.outf = outf self.git_branch = git_branch self.checkpoint = checkpoint self.import_marks_file = import_marks_file @@ -215,9 +216,6 @@ class BzrFastExporter(object): return list(view_revisions) def run(self): - # Open the source - self.branch = bzrlib.branch.Branch.open_containing(self.source)[0] - # Export the data self.branch.repository.lock_read() try: -- cgit v1.2.1