Add a way to specify the MimeMapper mappings to its constructor directly.
[cvs2svn.git] / cvs2svn_lib / bzr_run_options.py
blob9c5f090815d56ea4f6dabc008345b8732e7209d4
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 import sys
21 import datetime
22 import codecs
24 from cvs2svn_lib.version import VERSION
25 from cvs2svn_lib.common import FatalError
26 from cvs2svn_lib.context import Ctx
27 from cvs2svn_lib.run_options import not_both
28 from cvs2svn_lib.run_options import RunOptions
29 from cvs2svn_lib.run_options import ContextOption
30 from cvs2svn_lib.run_options import IncompatibleOption
31 from cvs2svn_lib.man_writer import ManWriter
32 from cvs2svn_lib.rcs_revision_manager import RCSRevisionReader
33 from cvs2svn_lib.cvs_revision_manager import CVSRevisionReader
34 from cvs2svn_lib.git_run_options import GitRunOptions
35 from cvs2svn_lib.git_output_option import GitRevisionInlineWriter
36 from cvs2svn_lib.git_output_option import GitOutputOption
37 from cvs2svn_lib.revision_manager import NullRevisionCollector
40 description="""\
41 Convert a CVS repository into a Bazaar repository, including history.
43 """
45 class BzrRunOptions(GitRunOptions):
47 short_desc = 'convert a cvs repository into a Bazaar repository'
49 synopsis = """\
50 .B cvs2bzr
51 [\\fIOPTION\\fR]... \\fIOUTPUT-OPTIONS CVS-REPOS-PATH\\fR
52 .br
53 .B cvs2bzr
54 [\\fIOPTION\\fR]... \\fI--options=PATH\\fR
55 """
57 long_desc = """\
58 Create a new Bazaar repository based on the version history stored in a
59 CVS repository. Each CVS commit will be mirrored in the Bazaar
60 repository, including such information as date of commit and id of the
61 committer.
63 The output of this program is a "fast-import dumpfile", which
64 can be loaded into a Bazaar repository using the Bazaar FastImport
65 Plugin, available from https://launchpad.net/bzr-fastimport.
68 \\fICVS-REPOS-PATH\\fR is the filesystem path of the part of the CVS
69 repository that you want to convert. This path doesn't have to be the
70 top level directory of a CVS repository; it can point at a project
71 within a repository, in which case only that project will be
72 converted. This path or one of its parent directories has to contain
73 a subdirectory called CVSROOT (though the CVSROOT directory can be
74 empty).
76 It is not possible directly to convert a CVS repository to which you
77 only have remote access, but the FAQ describes tools that may be used
78 to create a local copy of a remote CVS repository.
79 """
81 files = """\
82 A directory called \\fIcvs2svn-tmp\\fR (or the directory specified by
83 \\fB--tmpdir\\fR) is used as scratch space for temporary data files.
84 """
86 see_also = [
87 ('cvs', '1'),
88 ('bzr', '1'),
92 def get_description(self):
93 return description
95 def _get_output_options_group(self):
96 group = RunOptions._get_output_options_group(self)
98 group.add_option(IncompatibleOption(
99 '--dumpfile', type='string',
100 action='store',
101 help='path to which the data should be written',
102 man_help=(
103 'Write the blobs and revision data to \\fIpath\\fR.'
105 metavar='PATH',
107 group.add_option(ContextOption(
108 '--dry-run',
109 action='store_true',
110 help=(
111 'do not create any output; just print what would happen.'
113 man_help=(
114 'Do not create any output; just print what would happen.'
118 return group
120 def process_io_options(self):
121 """Process input/output options.
123 Process options related to extracting data from the CVS repository
124 and writing to a Bazaar-friendly fast-import file."""
126 ctx = Ctx()
127 options = self.options
129 not_both(options.use_rcs, '--use-rcs',
130 options.use_cvs, '--use-cvs')
132 if options.use_rcs:
133 revision_reader = RCSRevisionReader(
134 co_executable=options.co_executable
136 else:
137 # --use-cvs is the default:
138 revision_reader = CVSRevisionReader(
139 cvs_executable=options.cvs_executable
142 if not ctx.dry_run and not options.dumpfile:
143 raise FatalError("must pass '--dry-run' or '--dumpfile' option.")
145 ctx.revision_collector = NullRevisionCollector()
146 ctx.revision_reader = None
148 ctx.output_option = GitOutputOption(
149 options.dumpfile,
150 GitRevisionInlineWriter(revision_reader),
151 # Optional map from CVS author names to bzr author names:
152 author_transforms={}, # FIXME