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 InternalRevisionRecorder
32 from cvs2svn_lib
.checkout_internal
import InternalRevisionExcluder
33 from cvs2svn_lib
.checkout_internal
import InternalRevisionReader
34 from cvs2svn_lib
.hg_output_option
import HgOutputOption
37 class HgRunOptions(DVCSRunOptions
):
39 short_desc
= 'convert a cvs repository into a Mercurial repository'
43 [\\fIOPTION\\fR]... \\fIOUTPUT-OPTION CVS-REPOS-PATH\\fR
46 [\\fIOPTION\\fR]... \\fI--options=PATH\\fR
49 # XXX paragraph 2 copied straight from svn_run_options.py
51 Create a new Mercurial repository based on the version history stored in
52 a CVS repository. Each CVS commit will be mirrored in the Mercurial
53 repository, including commit time and author (with optional remapping to
54 Mercurial-style long usernames).
56 \\fICVS-REPOS-PATH\\fR is the filesystem path of the part of the CVS
57 repository that you want to convert. It is not possible to convert a
58 CVS repository to which you only have remote access; see the FAQ for
59 more information. This path doesn't have to be the top level
60 directory of a CVS repository; it can point at a project within a
61 repository, in which case only that project will be converted. This
62 path or one of its parent directories has to contain a subdirectory
63 called CVSROOT (though the CVSROOT directory can be empty).
65 Unlike CVS or Subversion, Mercurial expects each repository to hold
66 one independent project. If your CVS repository contains multiple
67 independent projects, you should probably convert them to multiple
68 independent Mercurial repositories with multiple runs of
72 # XXX copied from svn_run_options.py
74 A directory called \\fIcvs2svn-tmp\\fR (or the directory specified by
75 \\fB--tmpdir\\fR) is used as scratch space for temporary data files.
78 # XXX the cvs2{svn,git,bzr,hg} man pages should probably reference
85 def __init__(self
, *args
, **kwargs
):
86 # Override some default values
88 ctx
.username
= "cvs2hg"
89 ctx
.symbol_commit_message
= (
90 "artificial changeset to create "
91 "%(symbol_type)s '%(symbol_name)s'")
92 ctx
.post_commit_message
= (
93 "artificial changeset: compensate for changes in %(revnum)s "
94 "(on non-trunk default branch in CVS)")
96 super(HgRunOptions
, self
).__init
__(*args
, **kwargs
)
98 # This is a straight copy of SVNRunOptions._get_extraction_options_group();
99 # would be nice to refactor, but it's a bit awkward because GitRunOptions
100 # doesn't support --use-internal-co option.
101 def _get_extraction_options_group(self
):
102 group
= DVCSRunOptions
._get
_extraction
_options
_group
(self
)
103 self
._add
_use
_internal
_co
_option
(group
)
104 self
._add
_use
_cvs
_option
(group
)
105 self
._add
_use
_rcs
_option
(group
)
108 def _get_output_options_group(self
):
109 group
= super(HgRunOptions
, self
)._get
_output
_options
_group
()
111 # XXX what if the hg repo already exists? die, clobber, or append?
112 # (currently we die at the start of OutputPass)
113 group
.add_option(IncompatibleOption(
114 '--hgrepos', type='string',
116 help='create Mercurial repository in PATH',
118 'Convert to a Mercurial repository in \\fIpath\\fR. This creates '
119 'a new Mercurial repository at \\fIpath\\fR. \\fIpath\\fR must '
129 def process_extraction_options(self
):
130 """Process options related to extracting data from the CVS repository."""
131 self
.process_all_extraction_options()
133 def process_output_options(self
):
134 Ctx().output_option
= HgOutputOption(
135 self
.options
.hgrepos
,
136 author_transforms
={},