Add test repository that I forgot to commit with r5340.
[cvs2svn.git] / cvs2svn_lib / bzr_run_options.py
bloba352016386e82375f1e22dbb95834b5342609728
1 # (Be in -*- python -*- mode.)
3 # ====================================================================
4 # Copyright (c) 2000-2009 CollabNet. All rights reserved.
6 # This software is licensed as described in the file COPYING, which
7 # you should have received as part of this distribution. The terms
8 # are also available at http://subversion.tigris.org/license-1.html.
9 # If newer versions of this license are posted there, you may use a
10 # newer version instead, at your option.
12 # This software consists of voluntary contributions made by many
13 # individuals. For exact contribution history, see the revision
14 # history and logs, available at http://cvs2svn.tigris.org/.
15 # ====================================================================
17 """This module manages cvs2bzr run options."""
20 from cvs2svn_lib.common import FatalError
21 from cvs2svn_lib.context import Ctx
22 from cvs2svn_lib.dvcs_common import DVCSRunOptions
23 from cvs2svn_lib.run_options import ContextOption
24 from cvs2svn_lib.run_options import IncompatibleOption
25 from cvs2svn_lib.run_options import not_both
26 from cvs2svn_lib.revision_manager import NullRevisionCollector
27 from cvs2svn_lib.rcs_revision_manager import RCSRevisionReader
28 from cvs2svn_lib.cvs_revision_manager import CVSRevisionReader
29 from cvs2svn_lib.output_option import NullOutputOption
30 from cvs2svn_lib.git_output_option import GitRevisionInlineWriter
31 from cvs2svn_lib.bzr_output_option import BzrOutputOption
34 class BzrRunOptions(DVCSRunOptions):
36 short_desc = 'convert a cvs repository into a Bazaar repository'
38 synopsis = """\
39 .B cvs2bzr
40 [\\fIOPTION\\fR]... \\fIOUTPUT-OPTIONS CVS-REPOS-PATH\\fR
41 .br
42 .B cvs2bzr
43 [\\fIOPTION\\fR]... \\fI--options=PATH\\fR
44 """
46 long_desc = """\
47 Create a new Bazaar repository based on the version history stored in a
48 CVS repository. Each CVS commit will be mirrored in the Bazaar
49 repository, including such information as date of commit and id of the
50 committer.
52 The output of this program is a "fast-import dumpfile", which
53 can be loaded into a Bazaar repository using the Bazaar FastImport
54 Plugin, available from https://launchpad.net/bzr-fastimport.
57 \\fICVS-REPOS-PATH\\fR is the filesystem path of the part of the CVS
58 repository that you want to convert. This path doesn't have to be the
59 top level directory of a CVS repository; it can point at a project
60 within a repository, in which case only that project will be
61 converted. This path or one of its parent directories has to contain
62 a subdirectory called CVSROOT (though the CVSROOT directory can be
63 empty).
65 It is not possible directly to convert a CVS repository to which you
66 only have remote access, but the FAQ describes tools that may be used
67 to create a local copy of a remote CVS repository.
68 """
70 files = """\
71 A directory called \\fIcvs2svn-tmp\\fR (or the directory specified by
72 \\fB--tmpdir\\fR) is used as scratch space for temporary data files.
73 """
75 see_also = [
76 ('cvs', '1'),
77 ('bzr', '1'),
81 def _get_output_options_group(self):
82 group = super(BzrRunOptions, self)._get_output_options_group()
84 group.add_option(IncompatibleOption(
85 '--dumpfile', type='string',
86 action='store',
87 help='path to which the data should be written',
88 man_help=(
89 'Write the blobs and revision data to \\fIpath\\fR.'
91 metavar='PATH',
93 group.add_option(ContextOption(
94 '--dry-run',
95 action='store_true',
96 help=(
97 'do not create any output; just print what would happen.'
99 man_help=(
100 'Do not create any output; just print what would happen.'
104 return group
106 def _get_extraction_options_group(self):
107 group = super(BzrRunOptions, self)._get_extraction_options_group()
108 self._add_use_cvs_option(group)
109 self._add_use_rcs_option(group)
110 return group
112 def process_extraction_options(self):
113 """Process options related to extracting data from the CVS repository."""
115 ctx = Ctx()
116 options = self.options
118 not_both(options.use_rcs, '--use-rcs',
119 options.use_cvs, '--use-cvs')
121 # cvs2bzr defers acting on extraction options to process_output_options
123 def process_output_options(self):
124 """Process options related to fastimport output."""
125 ctx = Ctx()
126 options = self.options
128 if options.use_rcs:
129 revision_reader = RCSRevisionReader(
130 co_executable=options.co_executable
132 else:
133 # --use-cvs is the default:
134 revision_reader = CVSRevisionReader(
135 cvs_executable=options.cvs_executable
138 if not ctx.dry_run and not options.dumpfile:
139 raise FatalError("must pass '--dry-run' or '--dumpfile' option.")
141 # See cvs2bzr-example.options for explanations of these
142 ctx.revision_collector = NullRevisionCollector()
143 ctx.revision_reader = None
145 if ctx.dry_run:
146 ctx.output_option = NullOutputOption()
147 else:
148 ctx.output_option = BzrOutputOption(
149 options.dumpfile,
150 GitRevisionInlineWriter(revision_reader),
151 # Optional map from CVS author names to bzr author names:
152 author_transforms={}, # FIXME