run-tests.py: Only pass the --svnadmin option to cvs2svn when needed.
[cvs2svn.git] / cvs2svn_lib / hg_run_options.py
blob819add970a7f350319f822cebd133f948694c93a
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 # ====================================================================
17 import tempfile
19 from cvs2svn_lib.context import Ctx
20 from cvs2svn_lib.run_options import IncompatibleOption
21 from cvs2svn_lib.dvcs_common import DVCSRunOptions
22 from cvs2svn_lib.hg_output_option import HgOutputOption
25 class HgRunOptions(DVCSRunOptions):
27 short_desc = 'convert a cvs repository into a Mercurial repository'
29 synopsis = """\
30 .B cvs2hg
31 [\\fIOPTION\\fR]... \\fIOUTPUT-OPTION CVS-REPOS-PATH\\fR
32 .br
33 .B cvs2hg
34 [\\fIOPTION\\fR]... \\fI--options=PATH\\fR
35 """
37 # XXX paragraph 2 copied straight from svn_run_options.py
38 long_desc = """\
39 Create a new Mercurial repository based on the version history stored in
40 a CVS repository. Each CVS commit will be mirrored in the Mercurial
41 repository, including commit time and author (with optional remapping to
42 Mercurial-style long usernames).
44 \\fICVS-REPOS-PATH\\fR is the filesystem path of the part of the CVS
45 repository that you want to convert. It is not possible to convert a
46 CVS repository to which you only have remote access; see the FAQ for
47 more information. This path doesn't have to be the top level
48 directory of a CVS repository; it can point at a project within a
49 repository, in which case only that project will be converted. This
50 path or one of its parent directories has to contain a subdirectory
51 called CVSROOT (though the CVSROOT directory can be empty).
53 Unlike CVS or Subversion, Mercurial expects each repository to hold
54 one independent project. If your CVS repository contains multiple
55 independent projects, you should probably convert them to multiple
56 independent Mercurial repositories with multiple runs of
57 .B cvs2hg.
58 """
60 # XXX copied from svn_run_options.py
61 files = """\
62 A directory under \\fI%s\\fR (or the directory specified by
63 \\fB--tmpdir\\fR) is used as scratch space for temporary data files.
64 """ % (tempfile.gettempdir(),)
66 # XXX the cvs2{svn,git,bzr,hg} man pages should probably reference
67 # each other
68 see_also = [
69 ('cvs', '1'),
70 ('hg', '1'),
73 DEFAULT_USERNAME = 'cvs2hg'
75 def __init__(self, *args, **kwargs):
76 # Override some default values
77 ctx = Ctx()
78 ctx.symbol_commit_message = (
79 "artificial changeset to create "
80 "%(symbol_type)s '%(symbol_name)s'")
81 ctx.post_commit_message = (
82 "artificial changeset: compensate for changes in %(revnum)s "
83 "(on non-trunk default branch in CVS)")
85 super(HgRunOptions, self).__init__(*args, **kwargs)
87 # This is a straight copy of SVNRunOptions._get_extraction_options_group();
88 # would be nice to refactor, but it's a bit awkward because GitRunOptions
89 # doesn't support --use-internal-co option.
90 def _get_extraction_options_group(self):
91 group = DVCSRunOptions._get_extraction_options_group(self)
92 self._add_use_internal_co_option(group)
93 self._add_use_cvs_option(group)
94 self._add_use_rcs_option(group)
95 return group
97 def _get_output_options_group(self):
98 group = super(HgRunOptions, self)._get_output_options_group()
100 # XXX what if the hg repo already exists? die, clobber, or append?
101 # (currently we die at the start of OutputPass)
102 group.add_option(IncompatibleOption(
103 '--hgrepos', type='string',
104 action='store',
105 help='create Mercurial repository in PATH',
106 man_help=(
107 'Convert to a Mercurial repository in \\fIpath\\fR. This creates '
108 'a new Mercurial repository at \\fIpath\\fR. \\fIpath\\fR must '
109 'not already exist.'
111 metavar='PATH',
114 # XXX --dry-run?
116 return group
118 def process_extraction_options(self):
119 """Process options related to extracting data from the CVS repository."""
120 self.process_all_extraction_options()
122 def process_output_options(self):
123 Ctx().output_option = HgOutputOption(
124 self.options.hgrepos,
125 author_transforms={},