##// END OF EJS Templates
convert: split docstring lists for easier translation
Martin Geisler -
r12923:7d384a37 default
parent child Browse files
Show More
@@ -1,325 +1,336
1 1 # convert.py Foreign SCM converter
2 2 #
3 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 '''import revisions from foreign VCS repositories into Mercurial'''
9 9
10 10 import convcmd
11 11 import cvsps
12 12 import subversion
13 13 from mercurial import commands
14 14 from mercurial.i18n import _
15 15
16 16 # Commands definition was moved elsewhere to ease demandload job.
17 17
18 18 def convert(ui, src, dest=None, revmapfile=None, **opts):
19 19 """convert a foreign SCM repository to a Mercurial one.
20 20
21 21 Accepted source formats [identifiers]:
22 22
23 23 - Mercurial [hg]
24 24 - CVS [cvs]
25 25 - Darcs [darcs]
26 26 - git [git]
27 27 - Subversion [svn]
28 28 - Monotone [mtn]
29 29 - GNU Arch [gnuarch]
30 30 - Bazaar [bzr]
31 31 - Perforce [p4]
32 32
33 33 Accepted destination formats [identifiers]:
34 34
35 35 - Mercurial [hg]
36 36 - Subversion [svn] (history on branches is not preserved)
37 37
38 38 If no revision is given, all revisions will be converted.
39 39 Otherwise, convert will only import up to the named revision
40 40 (given in a format understood by the source).
41 41
42 42 If no destination directory name is specified, it defaults to the
43 43 basename of the source with ``-hg`` appended. If the destination
44 44 repository doesn't exist, it will be created.
45 45
46 46 By default, all sources except Mercurial will use --branchsort.
47 47 Mercurial uses --sourcesort to preserve original revision numbers
48 48 order. Sort modes have the following effects:
49 49
50 50 --branchsort convert from parent to child revision when possible,
51 51 which means branches are usually converted one after
52 52 the other. It generates more compact repositories.
53 53
54 54 --datesort sort revisions by date. Converted repositories have
55 55 good-looking changelogs but are often an order of
56 56 magnitude larger than the same ones generated by
57 57 --branchsort.
58 58
59 59 --sourcesort try to preserve source revisions order, only
60 60 supported by Mercurial sources.
61 61
62 62 If <REVMAP> isn't given, it will be put in a default location
63 63 (<dest>/.hg/shamap by default). The <REVMAP> is a simple text file
64 64 that maps each source commit ID to the destination ID for that
65 65 revision, like so::
66 66
67 67 <source ID> <destination ID>
68 68
69 69 If the file doesn't exist, it's automatically created. It's
70 70 updated on each commit copied, so :hg:`convert` can be interrupted
71 71 and can be run repeatedly to copy new commits.
72 72
73 73 The authormap is a simple text file that maps each source commit
74 74 author to a destination commit author. It is handy for source SCMs
75 75 that use unix logins to identify authors (eg: CVS). One line per
76 76 author mapping and the line format is::
77 77
78 78 source author = destination author
79 79
80 80 Empty lines and lines starting with a ``#`` are ignored.
81 81
82 82 The filemap is a file that allows filtering and remapping of files
83 83 and directories. Each line can contain one of the following
84 84 directives::
85 85
86 86 include path/to/file-or-dir
87 87
88 88 exclude path/to/file-or-dir
89 89
90 90 rename path/to/source path/to/destination
91 91
92 92 Comment lines start with ``#``. A specified path matches if it
93 93 equals the full relative name of a file or one of its parent
94 94 directories. The ``include`` or ``exclude`` directive with the
95 95 longest matching path applies, so line order does not matter.
96 96
97 97 The ``include`` directive causes a file, or all files under a
98 98 directory, to be included in the destination repository, and the
99 99 exclusion of all other files and directories not explicitly
100 100 included. The ``exclude`` directive causes files or directories to
101 101 be omitted. The ``rename`` directive renames a file or directory if
102 102 it is converted. To rename from a subdirectory into the root of
103 103 the repository, use ``.`` as the path to rename to.
104 104
105 105 The splicemap is a file that allows insertion of synthetic
106 106 history, letting you specify the parents of a revision. This is
107 107 useful if you want to e.g. give a Subversion merge two parents, or
108 108 graft two disconnected series of history together. Each entry
109 109 contains a key, followed by a space, followed by one or two
110 110 comma-separated values::
111 111
112 112 key parent1, parent2
113 113
114 114 The key is the revision ID in the source
115 115 revision control system whose parents should be modified (same
116 116 format as a key in .hg/shamap). The values are the revision IDs
117 117 (in either the source or destination revision control system) that
118 118 should be used as the new parents for that node. For example, if
119 119 you have merged "release-1.0" into "trunk", then you should
120 120 specify the revision on "trunk" as the first parent and the one on
121 121 the "release-1.0" branch as the second.
122 122
123 123 The branchmap is a file that allows you to rename a branch when it is
124 124 being brought in from whatever external repository. When used in
125 125 conjunction with a splicemap, it allows for a powerful combination
126 126 to help fix even the most badly mismanaged repositories and turn them
127 127 into nicely structured Mercurial repositories. The branchmap contains
128 128 lines of the form::
129 129
130 130 original_branch_name new_branch_name
131 131
132 132 where "original_branch_name" is the name of the branch in the
133 133 source repository, and "new_branch_name" is the name of the branch
134 134 is the destination repository. No whitespace is allowed in the
135 135 branch names. This can be used to (for instance) move code in one
136 136 repository from "default" to a named branch.
137 137
138 138 Mercurial Source
139 139 ''''''''''''''''
140 140
141 141 The Mercurial source recognizes the following configuration
142 142 options, which you can set on the command line with ``--config``:
143 143
144 :convert.hg.ignoreerrors: ignore integrity
145 errors when reading. Use it to fix Mercurial repositories with
146 missing revlogs, by converting from and to Mercurial. Default
147 is False.
148 :convert.hg.saverev: store original.
149 revision ID in changeset (forces target IDs to change). It takes and
150 boolean argument and defaults to False.
151 :convert.hg.startrev: convert
152 start revision and its descendants. It takes a hg revision identifier
153 and defaults to 0.
144 :convert.hg.ignoreerrors: ignore integrity errors when reading.
145 Use it to fix Mercurial repositories with missing revlogs, by
146 converting from and to Mercurial. Default is False.
147
148 :convert.hg.saverev: store original. revision ID in changeset
149 (forces target IDs to change). It takes and boolean argument
150 and defaults to False.
151
152 :convert.hg.startrev: convert start revision and its descendants.
153 It takes a hg revision identifier and defaults to 0.
154 154
155 155 CVS Source
156 156 ''''''''''
157 157
158 158 CVS source will use a sandbox (i.e. a checked-out copy) from CVS
159 159 to indicate the starting point of what will be converted. Direct
160 160 access to the repository files is not needed, unless of course the
161 161 repository is :local:. The conversion uses the top level directory
162 162 in the sandbox to find the CVS repository, and then uses CVS rlog
163 163 commands to find files to convert. This means that unless a
164 164 filemap is given, all files under the starting directory will be
165 165 converted, and that any directory reorganization in the CVS
166 166 sandbox is ignored.
167 167
168 168 The following options can be used with ``--config``:
169 169
170 :convert.cvsps.cache: Set to False to disable
171 remote log caching, for testing and debugging purposes. Default is True.
172 :convert.cvsps.fuzz: Specify the maximum
173 time (in seconds) that is allowed between commits with identical user
174 and log message in a single changeset. When very large files were
175 checked in as part of a changeset then the default may not be long
176 enough. The default is 60.
177 :convert.cvsps.mergeto: Specify a
178 regular expression to which commit log messages are matched. If a
179 match occurs, then the conversion process will insert a dummy
180 revision merging the branch on which this log message occurs to the
181 branch indicated in the regex. Default is ``{{mergetobranch ([-\\w]+)}}``
182 :convert.cvsps.mergefrom: Specify a
183 regular expression to which commit log messages are matched. If a
184 match occurs, then the conversion process will add the most recent
185 revision on the branch indicated in the regex as the second parent of
186 the changeset. Default is ``{{mergefrombranch ([-\\w]+)}}``
170 :convert.cvsps.cache: Set to False to disable remote log caching,
171 for testing and debugging purposes. Default is True.
172
173 :convert.cvsps.fuzz: Specify the maximum time (in seconds) that is
174 allowed between commits with identical user and log message in
175 a single changeset. When very large files were checked in as
176 part of a changeset then the default may not be long enough.
177 The default is 60.
178
179 :convert.cvsps.mergeto: Specify a regular expression to which
180 commit log messages are matched. If a match occurs, then the
181 conversion process will insert a dummy revision merging the
182 branch on which this log message occurs to the branch
183 indicated in the regex. Default is ``{{mergetobranch
184 ([-\\w]+)}}``
185
186 :convert.cvsps.mergefrom: Specify a regular expression to which
187 commit log messages are matched. If a match occurs, then the
188 conversion process will add the most recent revision on the
189 branch indicated in the regex as the second parent of the
190 changeset. Default is ``{{mergefrombranch ([-\\w]+)}}``
191
187 192 :hook.cvslog: Specify a Python function to be called at the end of
188 gathering the CVS log. The function is passed a list with the log
189 entries, and can modify the entries in-place, or add or delete them.
190 :hook.cvschangesets: Specify a Python function to be called after the
191 changesets are calculated from the the CVS log. The function is passed
192 a list with the changeset entries, and can modify the changesets
193 in-place, or add or delete them.
193 gathering the CVS log. The function is passed a list with the
194 log entries, and can modify the entries in-place, or add or
195 delete them.
196
197 :hook.cvschangesets: Specify a Python function to be called after
198 the changesets are calculated from the the CVS log. The
199 function is passed a list with the changeset entries, and can
200 modify the changesets in-place, or add or delete them.
194 201
195 202 An additional "debugcvsps" Mercurial command allows the builtin
196 203 changeset merging code to be run without doing a conversion. Its
197 204 parameters and output are similar to that of cvsps 2.1. Please see
198 205 the command help for more details.
199 206
200 207 Subversion Source
201 208 '''''''''''''''''
202 209
203 210 Subversion source detects classical trunk/branches/tags layouts.
204 211 By default, the supplied "svn://repo/path/" source URL is
205 212 converted as a single branch. If "svn://repo/path/trunk" exists it
206 213 replaces the default branch. If "svn://repo/path/branches" exists,
207 214 its subdirectories are listed as possible branches. If
208 215 "svn://repo/path/tags" exists, it is looked for tags referencing
209 216 converted branches. Default "trunk", "branches" and "tags" values
210 217 can be overridden with following options. Set them to paths
211 218 relative to the source URL, or leave them blank to disable auto
212 219 detection.
213 220
214 221 The following options can be set with ``--config``:
215 222
216 :convert.svn.branches: specify the directory
217 containing branches. The defaults is branches.
218 :convert.svn.tags: specify the directory
219 containing tags. The default is tags.
220 :convert.svn.trunk: specify the name of
221 the trunk branch The defauls is trunk.
223 :convert.svn.branches: specify the directory containing branches.
224 The defaults is branches.
225
226 :convert.svn.tags: specify the directory containing tags. The
227 default is tags.
228
229 :convert.svn.trunk: specify the name of the trunk branch The
230 defauls is trunk.
222 231
223 232 Source history can be retrieved starting at a specific revision,
224 233 instead of being integrally converted. Only single branch
225 234 conversions are supported.
226 235
227 :convert.svn.startrev: specify start
228 Subversion revision number. The default is 0.
236 :convert.svn.startrev: specify start Subversion revision number.
237 The default is 0.
229 238
230 239 Perforce Source
231 240 '''''''''''''''
232 241
233 242 The Perforce (P4) importer can be given a p4 depot path or a
234 243 client specification as source. It will convert all files in the
235 244 source to a flat Mercurial repository, ignoring labels, branches
236 245 and integrations. Note that when a depot path is given you then
237 246 usually should specify a target directory, because otherwise the
238 247 target may be named ...-hg.
239 248
240 249 It is possible to limit the amount of source history to be
241 250 converted by specifying an initial Perforce revision:
242 251
243 :convert.p4.startrev: specify
244 initial Perforce revision, a Perforce changelist number).
252 :convert.p4.startrev: specify initial Perforce revision, a
253 Perforce changelist number).
245 254
246 255 Mercurial Destination
247 256 '''''''''''''''''''''
248 257
249 258 The following options are supported:
250 259
251 :convert.hg.clonebranches: dispatch source
252 branches in separate clones. The default is False.
260 :convert.hg.clonebranches: dispatch source branches in separate
261 clones. The default is False.
262
253 263 :convert.hg.tagsbranch: branch name for tag revisions, defaults to
254 264 ``default``.
255 :convert.hg.usebranchnames: preserve branch names. The default is True
256 265
266 :convert.hg.usebranchnames: preserve branch names. The default is
267 True
257 268 """
258 269 return convcmd.convert(ui, src, dest, revmapfile, **opts)
259 270
260 271 def debugsvnlog(ui, **opts):
261 272 return subversion.debugsvnlog(ui, **opts)
262 273
263 274 def debugcvsps(ui, *args, **opts):
264 275 '''create changeset information from CVS
265 276
266 277 This command is intended as a debugging tool for the CVS to
267 278 Mercurial converter, and can be used as a direct replacement for
268 279 cvsps.
269 280
270 281 Hg debugcvsps reads the CVS rlog for current directory (or any
271 282 named directory) in the CVS repository, and converts the log to a
272 283 series of changesets based on matching commit log entries and
273 284 dates.'''
274 285 return cvsps.debugcvsps(ui, *args, **opts)
275 286
276 287 commands.norepo += " convert debugsvnlog debugcvsps"
277 288
278 289 cmdtable = {
279 290 "convert":
280 291 (convert,
281 292 [('', 'authors', '',
282 293 _('username mapping filename (DEPRECATED, use --authormap instead)'),
283 294 _('FILE')),
284 295 ('s', 'source-type', '',
285 296 _('source repository type'), _('TYPE')),
286 297 ('d', 'dest-type', '',
287 298 _('destination repository type'), _('TYPE')),
288 299 ('r', 'rev', '',
289 300 _('import up to target revision REV'), _('REV')),
290 301 ('A', 'authormap', '',
291 302 _('remap usernames using this file'), _('FILE')),
292 303 ('', 'filemap', '',
293 304 _('remap file names using contents of file'), _('FILE')),
294 305 ('', 'splicemap', '',
295 306 _('splice synthesized history into place'), _('FILE')),
296 307 ('', 'branchmap', '',
297 308 _('change branch names while converting'), _('FILE')),
298 309 ('', 'branchsort', None, _('try to sort changesets by branches')),
299 310 ('', 'datesort', None, _('try to sort changesets by date')),
300 311 ('', 'sourcesort', None, _('preserve source changesets order'))],
301 312 _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]')),
302 313 "debugsvnlog":
303 314 (debugsvnlog,
304 315 [],
305 316 'hg debugsvnlog'),
306 317 "debugcvsps":
307 318 (debugcvsps,
308 319 [
309 320 # Main options shared with cvsps-2.1
310 321 ('b', 'branches', [], _('only return changes on specified branches')),
311 322 ('p', 'prefix', '', _('prefix to remove from file names')),
312 323 ('r', 'revisions', [],
313 324 _('only return changes after or between specified tags')),
314 325 ('u', 'update-cache', None, _("update cvs log cache")),
315 326 ('x', 'new-cache', None, _("create new cvs log cache")),
316 327 ('z', 'fuzz', 60, _('set commit time fuzz in seconds')),
317 328 ('', 'root', '', _('specify cvsroot')),
318 329 # Options specific to builtin cvsps
319 330 ('', 'parents', '', _('show parent changesets')),
320 331 ('', 'ancestors', '', _('show current changeset in ancestor branches')),
321 332 # Options that are ignored for compatibility with cvsps-2.1
322 333 ('A', 'cvs-direct', None, _('ignored for compatibility')),
323 334 ],
324 335 _('hg debugcvsps [OPTION]... [PATH]...')),
325 336 }
General Comments 0
You need to be logged in to leave comments. Login now