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 cvs2git run options."""
24 from cvs2svn_lib
.version
import VERSION
25 from cvs2svn_lib
.common
import error_prefix
26 from cvs2svn_lib
.common
import FatalError
27 from cvs2svn_lib
.context
import Ctx
28 from cvs2svn_lib
.dvcs_common
import DVCSRunOptions
29 from cvs2svn_lib
.run_options
import RunOptions
30 from cvs2svn_lib
.run_options
import ContextOption
31 from cvs2svn_lib
.run_options
import IncompatibleOption
32 from cvs2svn_lib
.run_options
import not_both
33 from cvs2svn_lib
.man_writer
import ManWriter
34 from cvs2svn_lib
.revision_manager
import NullRevisionRecorder
35 from cvs2svn_lib
.revision_manager
import NullRevisionExcluder
36 from cvs2svn_lib
.rcs_revision_manager
import RCSRevisionReader
37 from cvs2svn_lib
.cvs_revision_manager
import CVSRevisionReader
38 from cvs2svn_lib
.git_revision_recorder
import GitRevisionRecorder
39 from cvs2svn_lib
.git_output_option
import GitRevisionMarkWriter
40 from cvs2svn_lib
.git_output_option
import GitOutputOption
41 from cvs2svn_lib
.fulltext_revision_recorder \
42 import SimpleFulltextRevisionRecorderAdapter
45 class GitRunOptions(DVCSRunOptions
):
47 short_desc
= 'convert a cvs repository into a git repository'
51 [\\fIOPTION\\fR]... \\fIOUTPUT-OPTIONS CVS-REPOS-PATH\\fR
54 [\\fIOPTION\\fR]... \\fI--options=PATH\\fR
58 Create a new git repository based on the version history stored in a
59 CVS repository. Each CVS commit will be mirrored in the git
60 repository, including such information as date of commit and id of the
63 The output of this program are a "blobfile" and a "dumpfile", which
64 together can be loaded into a git repository using "git fast-import".
66 \\fICVS-REPOS-PATH\\fR is the filesystem path of the part of the CVS
67 repository that you want to convert. This path doesn't have to be the
68 top level directory of a CVS repository; it can point at a project
69 within a repository, in which case only that project will be
70 converted. This path or one of its parent directories has to contain
71 a subdirectory called CVSROOT (though the CVSROOT directory can be
74 It is not possible directly to convert a CVS repository to which you
75 only have remote access, but the FAQ describes tools that may be used
76 to create a local copy of a remote CVS repository.
80 A directory called \\fIcvs2svn-tmp\\fR (or the directory specified by
81 \\fB--tmpdir\\fR) is used as scratch space for temporary data files.
87 ('git-fast-import', '1'),
91 def _get_output_options_group(self
):
92 group
= super(GitRunOptions
, self
)._get
_output
_options
_group
()
94 group
.add_option(IncompatibleOption(
95 '--blobfile', type='string',
97 help='path to which the "blob" data should be written',
99 'Write the "blob" data (containing revision contents) to '
104 group
.add_option(IncompatibleOption(
105 '--dumpfile', type='string',
107 help='path to which the revision data should be written',
109 'Write the revision data (branches and commits) to \\fIpath\\fR.'
113 group
.add_option(ContextOption(
117 'do not create any output; just print what would happen.'
120 'Do not create any output; just print what would happen.'
126 def _get_extraction_options_group(self
):
127 group
= super(GitRunOptions
, self
)._get
_extraction
_options
_group
()
128 self
._add
_use
_cvs
_option
(group
)
129 self
._add
_use
_rcs
_option
(group
)
132 # XXX not quite the same as same method in SVNRunOptions, but it
134 def process_extraction_options(self
):
135 """Process options related to extracting data from the CVS
138 options
= self
.options
140 not_both(options
.use_rcs
, '--use-rcs',
141 options
.use_cvs
, '--use-cvs')
144 revision_reader
= RCSRevisionReader(
145 co_executable
=options
.co_executable
148 # --use-cvs is the default:
149 revision_reader
= CVSRevisionReader(
150 cvs_executable
=options
.cvs_executable
154 ctx
.revision_recorder
= NullRevisionRecorder()
156 if not (options
.blobfile
and options
.dumpfile
):
157 raise FatalError("must pass '--blobfile' and '--dumpfile' options.")
158 ctx
.revision_recorder
= SimpleFulltextRevisionRecorderAdapter(
160 GitRevisionRecorder(options
.blobfile
),
163 ctx
.revision_excluder
= NullRevisionExcluder()
164 ctx
.revision_reader
= None
166 def process_output_options(self
):
167 """Process options related to fastimport output."""
169 ctx
.output_option
= GitOutputOption(
170 self
.options
.dumpfile
,
171 GitRevisionMarkWriter(),
172 # Optional map from CVS author names to git author names:
173 author_transforms
={}, # FIXME