1 # (Be in -*- python -*- mode.)
3 # ====================================================================
4 # Copyright (c) 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 # ====================================================================
21 from cvs2svn_lib
.version
import VERSION
22 from cvs2svn_lib
.context
import Ctx
23 from cvs2svn_lib
.common
import FatalError
24 from cvs2svn_lib
.run_options
import IncompatibleOption
25 from cvs2svn_lib
.run_options
import not_both
26 from cvs2svn_lib
.dvcs_common
import DVCSRunOptions
27 from cvs2svn_lib
.revision_manager
import NullRevisionRecorder
28 from cvs2svn_lib
.revision_manager
import NullRevisionExcluder
29 from cvs2svn_lib
.rcs_revision_manager
import RCSRevisionReader
30 from cvs2svn_lib
.cvs_revision_manager
import CVSRevisionReader
31 from cvs2svn_lib
.checkout_internal
import InternalRevisionCollector
32 from cvs2svn_lib
.checkout_internal
import InternalRevisionReader
33 from cvs2svn_lib
.hg_output_option
import HgOutputOption
36 class HgRunOptions(DVCSRunOptions
):
38 short_desc
= 'convert a cvs repository into a Mercurial repository'
42 [\\fIOPTION\\fR]... \\fIOUTPUT-OPTION CVS-REPOS-PATH\\fR
45 [\\fIOPTION\\fR]... \\fI--options=PATH\\fR
48 # XXX paragraph 2 copied straight from svn_run_options.py
50 Create a new Mercurial repository based on the version history stored in
51 a CVS repository. Each CVS commit will be mirrored in the Mercurial
52 repository, including commit time and author (with optional remapping to
53 Mercurial-style long usernames).
55 \\fICVS-REPOS-PATH\\fR is the filesystem path of the part of the CVS
56 repository that you want to convert. It is not possible to convert a
57 CVS repository to which you only have remote access; see the FAQ for
58 more information. This path doesn't have to be the top level
59 directory of a CVS repository; it can point at a project within a
60 repository, in which case only that project will be converted. This
61 path or one of its parent directories has to contain a subdirectory
62 called CVSROOT (though the CVSROOT directory can be empty).
64 Unlike CVS or Subversion, Mercurial expects each repository to hold
65 one independent project. If your CVS repository contains multiple
66 independent projects, you should probably convert them to multiple
67 independent Mercurial repositories with multiple runs of
71 # XXX copied from svn_run_options.py
73 A directory called \\fIcvs2svn-tmp\\fR (or the directory specified by
74 \\fB--tmpdir\\fR) is used as scratch space for temporary data files.
77 # XXX the cvs2{svn,git,bzr,hg} man pages should probably reference
84 def __init__(self
, *args
, **kwargs
):
85 # Override some default values
87 ctx
.username
= "cvs2hg"
88 ctx
.symbol_commit_message
= (
89 "artificial changeset to create "
90 "%(symbol_type)s '%(symbol_name)s'")
91 ctx
.post_commit_message
= (
92 "artificial changeset: compensate for changes in %(revnum)s "
93 "(on non-trunk default branch in CVS)")
95 super(HgRunOptions
, self
).__init
__(*args
, **kwargs
)
97 # This is a straight copy of SVNRunOptions._get_extraction_options_group();
98 # would be nice to refactor, but it's a bit awkward because GitRunOptions
99 # doesn't support --use-internal-co option.
100 def _get_extraction_options_group(self
):
101 group
= DVCSRunOptions
._get
_extraction
_options
_group
(self
)
102 self
._add
_use
_internal
_co
_option
(group
)
103 self
._add
_use
_cvs
_option
(group
)
104 self
._add
_use
_rcs
_option
(group
)
107 def _get_output_options_group(self
):
108 group
= super(HgRunOptions
, self
)._get
_output
_options
_group
()
110 # XXX what if the hg repo already exists? die, clobber, or append?
111 # (currently we die at the start of OutputPass)
112 group
.add_option(IncompatibleOption(
113 '--hgrepos', type='string',
115 help='create Mercurial repository in PATH',
117 'Convert to a Mercurial repository in \\fIpath\\fR. This creates '
118 'a new Mercurial repository at \\fIpath\\fR. \\fIpath\\fR must '
128 def process_extraction_options(self
):
129 """Process options related to extracting data from the CVS repository."""
130 self
.process_all_extraction_options()
132 def process_output_options(self
):
133 Ctx().output_option
= HgOutputOption(
134 self
.options
.hgrepos
,
135 author_transforms
={},