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."""
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
):
37 short_desc
= 'convert a cvs repository into a Bazaar repository'
41 [\\fIOPTION\\fR]... \\fIOUTPUT-OPTIONS CVS-REPOS-PATH\\fR
44 [\\fIOPTION\\fR]... \\fI--options=PATH\\fR
48 Create a new Bazaar repository based on the version history stored in a
49 CVS repository. Each CVS commit will be mirrored in the Bazaar
50 repository, including such information as date of commit and id of the
53 The output of this program is a "fast-import dumpfile", which
54 can be loaded into a Bazaar repository using the Bazaar FastImport
55 Plugin, available from https://launchpad.net/bzr-fastimport.
58 \\fICVS-REPOS-PATH\\fR is the filesystem path of the part of the CVS
59 repository that you want to convert. This path doesn't have to be the
60 top level directory of a CVS repository; it can point at a project
61 within a repository, in which case only that project will be
62 converted. This path or one of its parent directories has to contain
63 a subdirectory called CVSROOT (though the CVSROOT directory can be
66 It is not possible directly to convert a CVS repository to which you
67 only have remote access, but the FAQ describes tools that may be used
68 to create a local copy of a remote CVS repository.
72 A directory under \\fI%s\\fR (or the directory specified by
73 \\fB--tmpdir\\fR) is used as scratch space for temporary data files.
74 """ % (tempfile
.gettempdir(),)
81 DEFAULT_USERNAME
= 'cvs2bzr'
83 def _get_output_options_group(self
):
84 group
= super(BzrRunOptions
, self
)._get
_output
_options
_group
()
86 group
.add_option(IncompatibleOption(
87 '--dumpfile', type='string',
89 help='path to which the data should be written',
91 'Write the blobs and revision data to \\fIpath\\fR.'
95 group
.add_option(ContextOption(
99 'do not create any output; just print what would happen.'
102 'Do not create any output; just print what would happen.'
108 def _get_extraction_options_group(self
):
109 group
= super(BzrRunOptions
, self
)._get
_extraction
_options
_group
()
110 self
._add
_use
_cvs
_option
(group
)
111 self
._add
_use
_rcs
_option
(group
)
114 def process_extraction_options(self
):
115 """Process options related to extracting data from the CVS repository."""
117 options
= self
.options
119 not_both(options
.use_rcs
, '--use-rcs',
120 options
.use_cvs
, '--use-cvs')
122 # cvs2bzr defers acting on extraction options to process_output_options
124 def process_output_options(self
):
125 """Process options related to fastimport output."""
127 options
= self
.options
130 revision_reader
= RCSRevisionReader(
131 co_executable
=options
.co_executable
134 # --use-cvs is the default:
135 revision_reader
= CVSRevisionReader(
136 cvs_executable
=options
.cvs_executable
139 if not ctx
.dry_run
and not options
.dumpfile
:
140 raise FatalError("must pass '--dry-run' or '--dumpfile' option.")
142 # See cvs2bzr-example.options for explanations of these
143 ctx
.revision_collector
= NullRevisionCollector()
144 ctx
.revision_reader
= None
147 ctx
.output_option
= NullOutputOption()
149 ctx
.output_option
= BzrOutputOption(
151 GitRevisionInlineWriter(revision_reader
),
152 # Optional map from CVS author names to bzr author names:
153 author_transforms
={}, # FIXME