From f8bd00b1556543d24b2af13a797bb5e520d5fa59 Mon Sep 17 00:00:00 2001 From: mhagger Date: Tue, 1 Sep 2009 07:17:15 +0000 Subject: [PATCH] Factor out some duplication between SVNRunOptions and GitRunOptions. Patch by: Greg Ward Specifically, extract common code from the two _get_extraction_options_group() methods. * cvs2svn_lib/run_options.py: Add methods _add_use_internal_co_option(), _add_use_cvs_option(), and _add_use_rcs_option() to RunOptions. * cvs2svn_lib/git_run_options.py: Collapse _get_extraction_options_group(). * cvs2svn_lib/svn_run_options.py: Collapse _get_extraction_options_group(). git-svn-id: http://cvs2svn.tigris.org/svn/cvs2svn/trunk@4906 be7e6eca-30d4-0310-a8e5-ac0d63af7087 --- cvs2svn_lib/git_run_options.py | 32 ++------------------------- cvs2svn_lib/run_options.py | 49 ++++++++++++++++++++++++++++++++++++++++++ cvs2svn_lib/svn_run_options.py | 48 +++-------------------------------------- 3 files changed, 54 insertions(+), 75 deletions(-) diff --git a/cvs2svn_lib/git_run_options.py b/cvs2svn_lib/git_run_options.py index 6cf8ef48..1bd1e7d9 100644 --- a/cvs2svn_lib/git_run_options.py +++ b/cvs2svn_lib/git_run_options.py @@ -124,38 +124,10 @@ class GitRunOptions(DVCSRunOptions): return group - # XXX shouldn't this be the same as -- or, better, shared with -- - # SVNRunOptions? def _get_extraction_options_group(self): group = RunOptions._get_extraction_options_group(self) - - self.parser.set_default('use_cvs', False) - group.add_option(IncompatibleOption( - '--use-cvs', - action='store_true', - help=( - 'use CVS to extract revision contents (slower than ' - '--use-rcs but more reliable) (default)' - ), - man_help=( - 'Use CVS to extract revision contents. This option is slower ' - 'than \\fB--use-rcs\\fR but more reliable.' - ), - )) - self.parser.set_default('use_rcs', False) - group.add_option(IncompatibleOption( - '--use-rcs', - action='store_true', - help=( - 'use RCS to extract revision contents (faster than ' - '--use-cvs but fails in some cases)' - ), - man_help=( - 'Use RCS \'co\' to extract revision contents. This option is ' - 'faster than \\fB--use-cvs\\fR but fails in some cases.' - ), - )) - + self._add_use_cvs_option(group) + self._add_use_rcs_option(group) return group def callback_manpage(self, option, opt_str, value, parser): diff --git a/cvs2svn_lib/run_options.py b/cvs2svn_lib/run_options.py index 27d2ea68..98d5b426 100644 --- a/cvs2svn_lib/run_options.py +++ b/cvs2svn_lib/run_options.py @@ -642,6 +642,55 @@ class RunOptions(object): return group + def _add_use_internal_co_option(self, group): + self.parser.set_default('use_internal_co', False) + group.add_option(IncompatibleOption( + '--use-internal-co', + action='store_true', + help=( + 'use internal code to extract revision contents ' + '(fastest but disk space intensive) (default)' + ), + man_help=( + 'Use internal code to extract revision contents. This ' + 'is up to 50% faster than using \\fB--use-rcs\\fR, but needs ' + 'a lot of disk space: roughly the size of your CVS repository ' + 'plus the peak size of a complete checkout of the repository ' + 'with all branches that existed and still had commits pending ' + 'at a given time. This option is the default.' + ), + )) + + def _add_use_cvs_option(self, group): + self.parser.set_default('use_cvs', False) + group.add_option(IncompatibleOption( + '--use-cvs', + action='store_true', + help=( + 'use CVS to extract revision contents (slower than ' + '--use-internal-co or --use-rcs)' + ), + man_help=( + 'Use CVS to extract revision contents. This option is slower ' + 'than \\fB--use-internal-co\\fR or \\fB--use-rcs\\fR.' + ), + )) + + def _add_use_rcs_option(self, group): + self.parser.set_default('use_rcs', False) + group.add_option(IncompatibleOption( + '--use-rcs', + action='store_true', + help=( + 'use RCS to extract revision contents (faster than ' + '--use-cvs but fails in some cases)' + ), + man_help=( + 'Use RCS \'co\' to extract revision contents. This option is ' + 'faster than \\fB--use-cvs\\fR but fails in some cases.' + ), + )) + def _get_environment_options_group(self): group = OptionGroup(self.parser, 'Environment options') group.add_option(ContextOption( diff --git a/cvs2svn_lib/svn_run_options.py b/cvs2svn_lib/svn_run_options.py index e7577307..4f20c958 100644 --- a/cvs2svn_lib/svn_run_options.py +++ b/cvs2svn_lib/svn_run_options.py @@ -277,51 +277,9 @@ class SVNRunOptions(RunOptions): def _get_extraction_options_group(self): group = RunOptions._get_extraction_options_group(self) - - self.parser.set_default('use_internal_co', False) - group.add_option(IncompatibleOption( - '--use-internal-co', - action='store_true', - help=( - 'use internal code to extract revision contents ' - '(fastest but disk space intensive) (default)' - ), - man_help=( - 'Use internal code to extract revision contents. This ' - 'is up to 50% faster than using \\fB--use-rcs\\fR, but needs ' - 'a lot of disk space: roughly the size of your CVS repository ' - 'plus the peak size of a complete checkout of the repository ' - 'with all branches that existed and still had commits pending ' - 'at a given time. This option is the default.' - ), - )) - self.parser.set_default('use_cvs', False) - group.add_option(IncompatibleOption( - '--use-cvs', - action='store_true', - help=( - 'use CVS to extract revision contents (slower than ' - '--use-internal-co or --use-rcs)' - ), - man_help=( - 'Use CVS to extract revision contents. This option is slower ' - 'than \\fB--use-internal-co\\fR or \\fB--use-rcs\\fR.' - ), - )) - self.parser.set_default('use_rcs', False) - group.add_option(IncompatibleOption( - '--use-rcs', - action='store_true', - help=( - 'use RCS to extract revision contents (faster than ' - '--use-cvs but fails in some cases)' - ), - man_help=( - 'Use RCS \'co\' to extract revision contents. This option is ' - 'faster than \\fB--use-cvs\\fR but fails in some cases.' - ), - )) - + self._add_use_internal_co_option(group) + self._add_use_cvs_option(group) + self._add_use_rcs_option(group) return group def _get_environment_options_group(self): -- 2.11.4.GIT