cvs2git: Make the --blobfile argument optional.
[cvs2svn.git] / cvs2svn_lib / hg_run_options.py
blobac01f09ed00d7f414f570d6940203b400e27bdb6
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\\fR [\\fICVS-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). If
52 omitted, the repository path defaults to the current directory.
54 Unlike CVS or Subversion, Mercurial expects each repository to hold
55 one independent project. If your CVS repository contains multiple
56 independent projects, you should probably convert them to multiple
57 independent Mercurial repositories with multiple runs of
58 .B cvs2hg.
59 """
61 # XXX copied from svn_run_options.py
62 files = """\
63 A directory under \\fI%s\\fR (or the directory specified by
64 \\fB--tmpdir\\fR) is used as scratch space for temporary data files.
65 """ % (tempfile.gettempdir(),)
67 # XXX the cvs2{svn,git,bzr,hg} man pages should probably reference
68 # each other
69 see_also = [
70 ('cvs', '1'),
71 ('hg', '1'),
74 DEFAULT_USERNAME = 'cvs2hg'
76 def __init__(self, *args, **kwargs):
77 # Override some default values
78 ctx = Ctx()
79 ctx.symbol_commit_message = (
80 "artificial changeset to create "
81 "%(symbol_type)s '%(symbol_name)s'")
82 ctx.post_commit_message = (
83 "artificial changeset: compensate for changes in %(revnum)s "
84 "(on non-trunk default branch in CVS)")
86 DVCSRunOptions.__init__(self, *args, **kwargs)
88 # This is a straight copy of SVNRunOptions._get_extraction_options_group();
89 # would be nice to refactor, but it's a bit awkward because GitRunOptions
90 # doesn't support --use-internal-co option.
91 def _get_extraction_options_group(self):
92 group = DVCSRunOptions._get_extraction_options_group(self)
93 self._add_use_internal_co_option(group)
94 self._add_use_cvs_option(group)
95 self._add_use_rcs_option(group)
96 return group
98 def _get_output_options_group(self):
99 group = DVCSRunOptions._get_output_options_group(self)
101 # XXX what if the hg repo already exists? die, clobber, or append?
102 # (currently we die at the start of OutputPass)
103 group.add_option(IncompatibleOption(
104 '--hgrepos', type='string',
105 action='store',
106 help='create Mercurial repository in PATH',
107 man_help=(
108 'Convert to a Mercurial repository in \\fIpath\\fR. This creates '
109 'a new Mercurial repository at \\fIpath\\fR. \\fIpath\\fR must '
110 'not already exist.'
112 metavar='PATH',
115 # XXX --dry-run?
117 return group
119 def process_extraction_options(self):
120 """Process options related to extracting data from the CVS repository."""
121 self.process_all_extraction_options()
123 def process_output_options(self):
124 Ctx().output_option = HgOutputOption(
125 self.options.hgrepos,
126 author_transforms={},