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