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