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