Update GCS' email address to the Debian one.
[cvs2svn.git] / cvs2svn_lib / bzr_run_options.py
blob2e1327c45de6bb5bff2318862f70d489beb8c95a
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."""
19 import tempfile
21 from cvs2svn_lib.common import FatalError
22 from cvs2svn_lib.context import Ctx
23 from cvs2svn_lib.dvcs_common import DVCSRunOptions
24 from cvs2svn_lib.run_options import ContextOption
25 from cvs2svn_lib.run_options import IncompatibleOption
26 from cvs2svn_lib.run_options import not_both
27 from cvs2svn_lib.revision_manager import NullRevisionCollector
28 from cvs2svn_lib.rcs_revision_manager import RCSRevisionReader
29 from cvs2svn_lib.cvs_revision_manager import CVSRevisionReader
30 from cvs2svn_lib.output_option import NullOutputOption
31 from cvs2svn_lib.git_output_option import GitRevisionInlineWriter
32 from cvs2svn_lib.bzr_output_option import BzrOutputOption
35 class BzrRunOptions(DVCSRunOptions):
36 description="""\
37 Convert a CVS repository into a Bazaar repository, including history.
38 """
40 short_desc = 'convert a CVS repository into a Bazaar repository'
42 synopsis = """\
43 .B cvs2bzr
44 [\\fIOPTION\\fR]... \\fIOUTPUT-OPTIONS\\fR [\\fICVS-REPOS-PATH\\fR]
45 .br
46 .B cvs2bzr
47 [\\fIOPTION\\fR]... \\fI--options=PATH\\fR
48 """
50 long_desc = """\
51 Create a new Bazaar repository based on the version history stored in a
52 CVS repository. Each CVS commit will be mirrored in the Bazaar
53 repository, including such information as date of commit and id of the
54 committer.
56 The output of this program is a "fast-import dumpfile", which
57 can be loaded into a Bazaar repository using the Bazaar FastImport
58 Plugin, available from https://launchpad.net/bzr-fastimport.
61 \\fICVS-REPOS-PATH\\fR is the filesystem path of the part of the CVS
62 repository that you want to convert. This path doesn't have to be the
63 top level directory of a CVS repository; it can point at a project
64 within a repository, in which case only that project will be
65 converted. This path or one of its parent directories has to contain
66 a subdirectory called CVSROOT (though the CVSROOT directory can be
67 empty). If omitted, the repository path defaults to the current directory.
70 It is not possible directly to convert a CVS repository to which you
71 only have remote access, but the FAQ describes tools that may be used
72 to create a local copy of a remote CVS repository.
73 """
75 files = """\
76 A directory under \\fI%s\\fR (or the directory specified by
77 \\fB--tmpdir\\fR) is used as scratch space for temporary data files.
78 """ % (tempfile.gettempdir(),)
80 see_also = [
81 ('cvs', '1'),
82 ('bzr', '1'),
85 DEFAULT_USERNAME = 'cvs2bzr'
87 def _get_output_options_group(self):
88 group = DVCSRunOptions._get_output_options_group(self)
90 group.add_option(IncompatibleOption(
91 '--dumpfile', type='string',
92 action='store',
93 help='path to which the data should be written',
94 man_help=(
95 'Write the blobs and revision data to \\fIpath\\fR.'
97 metavar='PATH',
99 group.add_option(ContextOption(
100 '--dry-run',
101 action='store_true',
102 help=(
103 'do not create any output; just print what would happen.'
105 man_help=(
106 'Do not create any output; just print what would happen.'
110 return group
112 def _get_extraction_options_group(self):
113 group = DVCSRunOptions._get_extraction_options_group(self)
114 self._add_use_cvs_option(group)
115 self._add_use_rcs_option(group)
116 return group
118 def process_extraction_options(self):
119 """Process options related to extracting data from the CVS repository."""
121 options = self.options
123 not_both(options.use_rcs, '--use-rcs',
124 options.use_cvs, '--use-cvs')
126 # cvs2bzr defers acting on extraction options to process_output_options
128 def process_output_options(self):
129 """Process options related to fastimport output."""
130 ctx = Ctx()
131 options = self.options
133 if options.use_rcs:
134 revision_reader = RCSRevisionReader(
135 co_executable=options.co_executable
137 else:
138 # --use-cvs is the default:
139 revision_reader = CVSRevisionReader(
140 cvs_executable=options.cvs_executable
143 if not ctx.dry_run and not options.dumpfile:
144 raise FatalError("must pass '--dry-run' or '--dumpfile' option.")
146 # See cvs2bzr-example.options for explanations of these
147 ctx.revision_collector = NullRevisionCollector()
148 ctx.revision_reader = None
150 if ctx.dry_run:
151 ctx.output_option = NullOutputOption()
152 else:
153 ctx.output_option = BzrOutputOption(
154 options.dumpfile,
155 GitRevisionInlineWriter(revision_reader),
156 # Optional map from CVS author names to bzr author names:
157 author_transforms={}, # FIXME