From 9cb6216728fdaf0f8aa5b232571ed435bd0c844d Mon Sep 17 00:00:00 2001 From: mhagger Date: Mon, 24 Jan 2011 05:18:25 +0000 Subject: [PATCH] Add a NullOutputOption. Use it to implement --dry-run functionality for cvs2git and cvs2bzr. This should fix RedHat bug 621411: https://bugzilla.redhat.com/show_bug.cgi?id=621411 This commit is the equivalent of r5317 from branch 2.3.x. git-svn-id: http://cvs2svn.tigris.org/svn/cvs2svn/trunk@5318 be7e6eca-30d4-0310-a8e5-ac0d63af7087 --- cvs2svn_lib/bzr_run_options.py | 16 ++++++++++------ cvs2svn_lib/git_run_options.py | 16 ++++++++++------ cvs2svn_lib/output_option.py | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/cvs2svn_lib/bzr_run_options.py b/cvs2svn_lib/bzr_run_options.py index 11d16bc5..a3520163 100644 --- a/cvs2svn_lib/bzr_run_options.py +++ b/cvs2svn_lib/bzr_run_options.py @@ -26,6 +26,7 @@ from cvs2svn_lib.run_options import not_both from cvs2svn_lib.revision_manager import NullRevisionCollector from cvs2svn_lib.rcs_revision_manager import RCSRevisionReader from cvs2svn_lib.cvs_revision_manager import CVSRevisionReader +from cvs2svn_lib.output_option import NullOutputOption from cvs2svn_lib.git_output_option import GitRevisionInlineWriter from cvs2svn_lib.bzr_output_option import BzrOutputOption @@ -141,9 +142,12 @@ A directory called \\fIcvs2svn-tmp\\fR (or the directory specified by ctx.revision_collector = NullRevisionCollector() ctx.revision_reader = None - ctx.output_option = BzrOutputOption( - options.dumpfile, - GitRevisionInlineWriter(revision_reader), - # Optional map from CVS author names to bzr author names: - author_transforms={}, # FIXME - ) + if ctx.dry_run: + ctx.output_option = NullOutputOption() + else: + ctx.output_option = BzrOutputOption( + options.dumpfile, + GitRevisionInlineWriter(revision_reader), + # Optional map from CVS author names to bzr author names: + author_transforms={}, # FIXME + ) diff --git a/cvs2svn_lib/git_run_options.py b/cvs2svn_lib/git_run_options.py index 2b401061..70979e28 100644 --- a/cvs2svn_lib/git_run_options.py +++ b/cvs2svn_lib/git_run_options.py @@ -28,6 +28,7 @@ from cvs2svn_lib.rcs_revision_manager import RCSRevisionReader from cvs2svn_lib.cvs_revision_manager import CVSRevisionReader from cvs2svn_lib.git_revision_collector import GitRevisionCollector from cvs2svn_lib.external_blob_generator import ExternalBlobGenerator +from cvs2svn_lib.output_option import NullOutputOption from cvs2svn_lib.git_output_option import GitRevisionMarkWriter from cvs2svn_lib.git_output_option import GitOutputOption @@ -184,9 +185,12 @@ A directory called \\fIcvs2svn-tmp\\fR (or the directory specified by def process_output_options(self): """Process options related to fastimport output.""" ctx = Ctx() - ctx.output_option = GitOutputOption( - self.options.dumpfile, - GitRevisionMarkWriter(), - # Optional map from CVS author names to git author names: - author_transforms={}, # FIXME - ) + if ctx.dry_run: + ctx.output_option = NullOutputOption() + else: + ctx.output_option = GitOutputOption( + self.options.dumpfile, + GitRevisionMarkWriter(), + # Optional map from CVS author names to git author names: + author_transforms={}, # FIXME + ) diff --git a/cvs2svn_lib/output_option.py b/cvs2svn_lib/output_option.py index ebd7d802..1adfe862 100644 --- a/cvs2svn_lib/output_option.py +++ b/cvs2svn_lib/output_option.py @@ -110,3 +110,36 @@ class OutputOption: raise NotImplementedError() +class NullOutputOption(OutputOption): + """An OutputOption that doesn't do anything.""" + + name = 'null' + + def check(self): + pass + + def check_symbols(self, symbol_map): + pass + + def setup(self, svn_rev_count): + pass + + def process_initial_project_commit(self, svn_commit): + pass + + def process_primary_commit(self, svn_commit): + pass + + def process_post_commit(self, svn_commit): + pass + + def process_branch_commit(self, svn_commit): + pass + + def process_tag_commit(self, svn_commit): + pass + + def cleanup(self): + pass + + -- 2.11.4.GIT