##// END OF EJS Templates
convert: correct the documentation about whitespace in branchmap branches...
Matt Harbison -
r32755:3a57bfd3 default
parent child Browse files
Show More
@@ -1,503 +1,503
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 from __future__ import absolute_import
11 11
12 12 from mercurial.i18n import _
13 13 from mercurial import (
14 14 registrar,
15 15 )
16 16
17 17 from . import (
18 18 convcmd,
19 19 cvsps,
20 20 subversion,
21 21 )
22 22
23 23 cmdtable = {}
24 24 command = registrar.command(cmdtable)
25 25 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
26 26 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
27 27 # be specifying the version(s) of Mercurial they are tested with, or
28 28 # leave the attribute unspecified.
29 29 testedwith = 'ships-with-hg-core'
30 30
31 31 # Commands definition was moved elsewhere to ease demandload job.
32 32
33 33 @command('convert',
34 34 [('', 'authors', '',
35 35 _('username mapping filename (DEPRECATED) (use --authormap instead)'),
36 36 _('FILE')),
37 37 ('s', 'source-type', '', _('source repository type'), _('TYPE')),
38 38 ('d', 'dest-type', '', _('destination repository type'), _('TYPE')),
39 39 ('r', 'rev', [], _('import up to source revision REV'), _('REV')),
40 40 ('A', 'authormap', '', _('remap usernames using this file'), _('FILE')),
41 41 ('', 'filemap', '', _('remap file names using contents of file'),
42 42 _('FILE')),
43 43 ('', 'full', None,
44 44 _('apply filemap changes by converting all files again')),
45 45 ('', 'splicemap', '', _('splice synthesized history into place'),
46 46 _('FILE')),
47 47 ('', 'branchmap', '', _('change branch names while converting'),
48 48 _('FILE')),
49 49 ('', 'branchsort', None, _('try to sort changesets by branches')),
50 50 ('', 'datesort', None, _('try to sort changesets by date')),
51 51 ('', 'sourcesort', None, _('preserve source changesets order')),
52 52 ('', 'closesort', None, _('try to reorder closed revisions'))],
53 53 _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]'),
54 54 norepo=True)
55 55 def convert(ui, src, dest=None, revmapfile=None, **opts):
56 56 """convert a foreign SCM repository to a Mercurial one.
57 57
58 58 Accepted source formats [identifiers]:
59 59
60 60 - Mercurial [hg]
61 61 - CVS [cvs]
62 62 - Darcs [darcs]
63 63 - git [git]
64 64 - Subversion [svn]
65 65 - Monotone [mtn]
66 66 - GNU Arch [gnuarch]
67 67 - Bazaar [bzr]
68 68 - Perforce [p4]
69 69
70 70 Accepted destination formats [identifiers]:
71 71
72 72 - Mercurial [hg]
73 73 - Subversion [svn] (history on branches is not preserved)
74 74
75 75 If no revision is given, all revisions will be converted.
76 76 Otherwise, convert will only import up to the named revision
77 77 (given in a format understood by the source).
78 78
79 79 If no destination directory name is specified, it defaults to the
80 80 basename of the source with ``-hg`` appended. If the destination
81 81 repository doesn't exist, it will be created.
82 82
83 83 By default, all sources except Mercurial will use --branchsort.
84 84 Mercurial uses --sourcesort to preserve original revision numbers
85 85 order. Sort modes have the following effects:
86 86
87 87 --branchsort convert from parent to child revision when possible,
88 88 which means branches are usually converted one after
89 89 the other. It generates more compact repositories.
90 90
91 91 --datesort sort revisions by date. Converted repositories have
92 92 good-looking changelogs but are often an order of
93 93 magnitude larger than the same ones generated by
94 94 --branchsort.
95 95
96 96 --sourcesort try to preserve source revisions order, only
97 97 supported by Mercurial sources.
98 98
99 99 --closesort try to move closed revisions as close as possible
100 100 to parent branches, only supported by Mercurial
101 101 sources.
102 102
103 103 If ``REVMAP`` isn't given, it will be put in a default location
104 104 (``<dest>/.hg/shamap`` by default). The ``REVMAP`` is a simple
105 105 text file that maps each source commit ID to the destination ID
106 106 for that revision, like so::
107 107
108 108 <source ID> <destination ID>
109 109
110 110 If the file doesn't exist, it's automatically created. It's
111 111 updated on each commit copied, so :hg:`convert` can be interrupted
112 112 and can be run repeatedly to copy new commits.
113 113
114 114 The authormap is a simple text file that maps each source commit
115 115 author to a destination commit author. It is handy for source SCMs
116 116 that use unix logins to identify authors (e.g.: CVS). One line per
117 117 author mapping and the line format is::
118 118
119 119 source author = destination author
120 120
121 121 Empty lines and lines starting with a ``#`` are ignored.
122 122
123 123 The filemap is a file that allows filtering and remapping of files
124 124 and directories. Each line can contain one of the following
125 125 directives::
126 126
127 127 include path/to/file-or-dir
128 128
129 129 exclude path/to/file-or-dir
130 130
131 131 rename path/to/source path/to/destination
132 132
133 133 Comment lines start with ``#``. A specified path matches if it
134 134 equals the full relative name of a file or one of its parent
135 135 directories. The ``include`` or ``exclude`` directive with the
136 136 longest matching path applies, so line order does not matter.
137 137
138 138 The ``include`` directive causes a file, or all files under a
139 139 directory, to be included in the destination repository. The default
140 140 if there are no ``include`` statements is to include everything.
141 141 If there are any ``include`` statements, nothing else is included.
142 142 The ``exclude`` directive causes files or directories to
143 143 be omitted. The ``rename`` directive renames a file or directory if
144 144 it is converted. To rename from a subdirectory into the root of
145 145 the repository, use ``.`` as the path to rename to.
146 146
147 147 ``--full`` will make sure the converted changesets contain exactly
148 148 the right files with the right content. It will make a full
149 149 conversion of all files, not just the ones that have
150 150 changed. Files that already are correct will not be changed. This
151 151 can be used to apply filemap changes when converting
152 152 incrementally. This is currently only supported for Mercurial and
153 153 Subversion.
154 154
155 155 The splicemap is a file that allows insertion of synthetic
156 156 history, letting you specify the parents of a revision. This is
157 157 useful if you want to e.g. give a Subversion merge two parents, or
158 158 graft two disconnected series of history together. Each entry
159 159 contains a key, followed by a space, followed by one or two
160 160 comma-separated values::
161 161
162 162 key parent1, parent2
163 163
164 164 The key is the revision ID in the source
165 165 revision control system whose parents should be modified (same
166 166 format as a key in .hg/shamap). The values are the revision IDs
167 167 (in either the source or destination revision control system) that
168 168 should be used as the new parents for that node. For example, if
169 169 you have merged "release-1.0" into "trunk", then you should
170 170 specify the revision on "trunk" as the first parent and the one on
171 171 the "release-1.0" branch as the second.
172 172
173 173 The branchmap is a file that allows you to rename a branch when it is
174 174 being brought in from whatever external repository. When used in
175 175 conjunction with a splicemap, it allows for a powerful combination
176 176 to help fix even the most badly mismanaged repositories and turn them
177 177 into nicely structured Mercurial repositories. The branchmap contains
178 178 lines of the form::
179 179
180 180 original_branch_name new_branch_name
181 181
182 182 where "original_branch_name" is the name of the branch in the
183 183 source repository, and "new_branch_name" is the name of the branch
184 is the destination repository. No whitespace is allowed in the
185 branch names. This can be used to (for instance) move code in one
184 is the destination repository. No whitespace is allowed in the new
185 branch name. This can be used to (for instance) move code in one
186 186 repository from "default" to a named branch.
187 187
188 188 Mercurial Source
189 189 ################
190 190
191 191 The Mercurial source recognizes the following configuration
192 192 options, which you can set on the command line with ``--config``:
193 193
194 194 :convert.hg.ignoreerrors: ignore integrity errors when reading.
195 195 Use it to fix Mercurial repositories with missing revlogs, by
196 196 converting from and to Mercurial. Default is False.
197 197
198 198 :convert.hg.saverev: store original revision ID in changeset
199 199 (forces target IDs to change). It takes a boolean argument and
200 200 defaults to False.
201 201
202 202 :convert.hg.startrev: specify the initial Mercurial revision.
203 203 The default is 0.
204 204
205 205 :convert.hg.revs: revset specifying the source revisions to convert.
206 206
207 207 CVS Source
208 208 ##########
209 209
210 210 CVS source will use a sandbox (i.e. a checked-out copy) from CVS
211 211 to indicate the starting point of what will be converted. Direct
212 212 access to the repository files is not needed, unless of course the
213 213 repository is ``:local:``. The conversion uses the top level
214 214 directory in the sandbox to find the CVS repository, and then uses
215 215 CVS rlog commands to find files to convert. This means that unless
216 216 a filemap is given, all files under the starting directory will be
217 217 converted, and that any directory reorganization in the CVS
218 218 sandbox is ignored.
219 219
220 220 The following options can be used with ``--config``:
221 221
222 222 :convert.cvsps.cache: Set to False to disable remote log caching,
223 223 for testing and debugging purposes. Default is True.
224 224
225 225 :convert.cvsps.fuzz: Specify the maximum time (in seconds) that is
226 226 allowed between commits with identical user and log message in
227 227 a single changeset. When very large files were checked in as
228 228 part of a changeset then the default may not be long enough.
229 229 The default is 60.
230 230
231 231 :convert.cvsps.mergeto: Specify a regular expression to which
232 232 commit log messages are matched. If a match occurs, then the
233 233 conversion process will insert a dummy revision merging the
234 234 branch on which this log message occurs to the branch
235 235 indicated in the regex. Default is ``{{mergetobranch
236 236 ([-\\w]+)}}``
237 237
238 238 :convert.cvsps.mergefrom: Specify a regular expression to which
239 239 commit log messages are matched. If a match occurs, then the
240 240 conversion process will add the most recent revision on the
241 241 branch indicated in the regex as the second parent of the
242 242 changeset. Default is ``{{mergefrombranch ([-\\w]+)}}``
243 243
244 244 :convert.localtimezone: use local time (as determined by the TZ
245 245 environment variable) for changeset date/times. The default
246 246 is False (use UTC).
247 247
248 248 :hooks.cvslog: Specify a Python function to be called at the end of
249 249 gathering the CVS log. The function is passed a list with the
250 250 log entries, and can modify the entries in-place, or add or
251 251 delete them.
252 252
253 253 :hooks.cvschangesets: Specify a Python function to be called after
254 254 the changesets are calculated from the CVS log. The
255 255 function is passed a list with the changeset entries, and can
256 256 modify the changesets in-place, or add or delete them.
257 257
258 258 An additional "debugcvsps" Mercurial command allows the builtin
259 259 changeset merging code to be run without doing a conversion. Its
260 260 parameters and output are similar to that of cvsps 2.1. Please see
261 261 the command help for more details.
262 262
263 263 Subversion Source
264 264 #################
265 265
266 266 Subversion source detects classical trunk/branches/tags layouts.
267 267 By default, the supplied ``svn://repo/path/`` source URL is
268 268 converted as a single branch. If ``svn://repo/path/trunk`` exists
269 269 it replaces the default branch. If ``svn://repo/path/branches``
270 270 exists, its subdirectories are listed as possible branches. If
271 271 ``svn://repo/path/tags`` exists, it is looked for tags referencing
272 272 converted branches. Default ``trunk``, ``branches`` and ``tags``
273 273 values can be overridden with following options. Set them to paths
274 274 relative to the source URL, or leave them blank to disable auto
275 275 detection.
276 276
277 277 The following options can be set with ``--config``:
278 278
279 279 :convert.svn.branches: specify the directory containing branches.
280 280 The default is ``branches``.
281 281
282 282 :convert.svn.tags: specify the directory containing tags. The
283 283 default is ``tags``.
284 284
285 285 :convert.svn.trunk: specify the name of the trunk branch. The
286 286 default is ``trunk``.
287 287
288 288 :convert.localtimezone: use local time (as determined by the TZ
289 289 environment variable) for changeset date/times. The default
290 290 is False (use UTC).
291 291
292 292 Source history can be retrieved starting at a specific revision,
293 293 instead of being integrally converted. Only single branch
294 294 conversions are supported.
295 295
296 296 :convert.svn.startrev: specify start Subversion revision number.
297 297 The default is 0.
298 298
299 299 Git Source
300 300 ##########
301 301
302 302 The Git importer converts commits from all reachable branches (refs
303 303 in refs/heads) and remotes (refs in refs/remotes) to Mercurial.
304 304 Branches are converted to bookmarks with the same name, with the
305 305 leading 'refs/heads' stripped. Git submodules are converted to Git
306 306 subrepos in Mercurial.
307 307
308 308 The following options can be set with ``--config``:
309 309
310 310 :convert.git.similarity: specify how similar files modified in a
311 311 commit must be to be imported as renames or copies, as a
312 312 percentage between ``0`` (disabled) and ``100`` (files must be
313 313 identical). For example, ``90`` means that a delete/add pair will
314 314 be imported as a rename if more than 90% of the file hasn't
315 315 changed. The default is ``50``.
316 316
317 317 :convert.git.findcopiesharder: while detecting copies, look at all
318 318 files in the working copy instead of just changed ones. This
319 319 is very expensive for large projects, and is only effective when
320 320 ``convert.git.similarity`` is greater than 0. The default is False.
321 321
322 322 :convert.git.renamelimit: perform rename and copy detection up to this
323 323 many changed files in a commit. Increasing this will make rename
324 324 and copy detection more accurate but will significantly slow down
325 325 computation on large projects. The option is only relevant if
326 326 ``convert.git.similarity`` is greater than 0. The default is
327 327 ``400``.
328 328
329 329 :convert.git.committeractions: list of actions to take when processing
330 330 author and committer values.
331 331
332 332 Git commits have separate author (who wrote the commit) and committer
333 333 (who applied the commit) fields. Not all destinations support separate
334 334 author and committer fields (including Mercurial). This config option
335 335 controls what to do with these author and committer fields during
336 336 conversion.
337 337
338 338 A value of ``messagedifferent`` will append a ``committer: ...``
339 339 line to the commit message if the Git committer is different from the
340 340 author. The prefix of that line can be specified using the syntax
341 341 ``messagedifferent=<prefix>``. e.g. ``messagedifferent=git-committer:``.
342 342 When a prefix is specified, a space will always be inserted between the
343 343 prefix and the value.
344 344
345 345 ``messagealways`` behaves like ``messagedifferent`` except it will
346 346 always result in a ``committer: ...`` line being appended to the commit
347 347 message. This value is mutually exclusive with ``messagedifferent``.
348 348
349 349 ``dropcommitter`` will remove references to the committer. Only
350 350 references to the author will remain. Actions that add references
351 351 to the committer will have no effect when this is set.
352 352
353 353 ``replaceauthor`` will replace the value of the author field with
354 354 the committer. Other actions that add references to the committer
355 355 will still take effect when this is set.
356 356
357 357 The default is ``messagedifferent``.
358 358
359 359 :convert.git.extrakeys: list of extra keys from commit metadata to copy to
360 360 the destination. Some Git repositories store extra metadata in commits.
361 361 By default, this non-default metadata will be lost during conversion.
362 362 Setting this config option can retain that metadata. Some built-in
363 363 keys such as ``parent`` and ``branch`` are not allowed to be copied.
364 364
365 365 :convert.git.remoteprefix: remote refs are converted as bookmarks with
366 366 ``convert.git.remoteprefix`` as a prefix followed by a /. The default
367 367 is 'remote'.
368 368
369 369 :convert.git.saverev: whether to store the original Git commit ID in the
370 370 metadata of the destination commit. The default is True.
371 371
372 372 :convert.git.skipsubmodules: does not convert root level .gitmodules files
373 373 or files with 160000 mode indicating a submodule. Default is False.
374 374
375 375 Perforce Source
376 376 ###############
377 377
378 378 The Perforce (P4) importer can be given a p4 depot path or a
379 379 client specification as source. It will convert all files in the
380 380 source to a flat Mercurial repository, ignoring labels, branches
381 381 and integrations. Note that when a depot path is given you then
382 382 usually should specify a target directory, because otherwise the
383 383 target may be named ``...-hg``.
384 384
385 385 The following options can be set with ``--config``:
386 386
387 387 :convert.p4.encoding: specify the encoding to use when decoding standard
388 388 output of the Perforce command line tool. The default is default system
389 389 encoding.
390 390
391 391 :convert.p4.startrev: specify initial Perforce revision (a
392 392 Perforce changelist number).
393 393
394 394 Mercurial Destination
395 395 #####################
396 396
397 397 The Mercurial destination will recognize Mercurial subrepositories in the
398 398 destination directory, and update the .hgsubstate file automatically if the
399 399 destination subrepositories contain the <dest>/<sub>/.hg/shamap file.
400 400 Converting a repository with subrepositories requires converting a single
401 401 repository at a time, from the bottom up.
402 402
403 403 .. container:: verbose
404 404
405 405 An example showing how to convert a repository with subrepositories::
406 406
407 407 # so convert knows the type when it sees a non empty destination
408 408 $ hg init converted
409 409
410 410 $ hg convert orig/sub1 converted/sub1
411 411 $ hg convert orig/sub2 converted/sub2
412 412 $ hg convert orig converted
413 413
414 414 The following options are supported:
415 415
416 416 :convert.hg.clonebranches: dispatch source branches in separate
417 417 clones. The default is False.
418 418
419 419 :convert.hg.tagsbranch: branch name for tag revisions, defaults to
420 420 ``default``.
421 421
422 422 :convert.hg.usebranchnames: preserve branch names. The default is
423 423 True.
424 424
425 425 :convert.hg.sourcename: records the given string as a 'convert_source' extra
426 426 value on each commit made in the target repository. The default is None.
427 427
428 428 All Destinations
429 429 ################
430 430
431 431 All destination types accept the following options:
432 432
433 433 :convert.skiptags: does not convert tags from the source repo to the target
434 434 repo. The default is False.
435 435 """
436 436 return convcmd.convert(ui, src, dest, revmapfile, **opts)
437 437
438 438 @command('debugsvnlog', [], 'hg debugsvnlog', norepo=True)
439 439 def debugsvnlog(ui, **opts):
440 440 return subversion.debugsvnlog(ui, **opts)
441 441
442 442 @command('debugcvsps',
443 443 [
444 444 # Main options shared with cvsps-2.1
445 445 ('b', 'branches', [], _('only return changes on specified branches')),
446 446 ('p', 'prefix', '', _('prefix to remove from file names')),
447 447 ('r', 'revisions', [],
448 448 _('only return changes after or between specified tags')),
449 449 ('u', 'update-cache', None, _("update cvs log cache")),
450 450 ('x', 'new-cache', None, _("create new cvs log cache")),
451 451 ('z', 'fuzz', 60, _('set commit time fuzz in seconds')),
452 452 ('', 'root', '', _('specify cvsroot')),
453 453 # Options specific to builtin cvsps
454 454 ('', 'parents', '', _('show parent changesets')),
455 455 ('', 'ancestors', '', _('show current changeset in ancestor branches')),
456 456 # Options that are ignored for compatibility with cvsps-2.1
457 457 ('A', 'cvs-direct', None, _('ignored for compatibility')),
458 458 ],
459 459 _('hg debugcvsps [OPTION]... [PATH]...'),
460 460 norepo=True)
461 461 def debugcvsps(ui, *args, **opts):
462 462 '''create changeset information from CVS
463 463
464 464 This command is intended as a debugging tool for the CVS to
465 465 Mercurial converter, and can be used as a direct replacement for
466 466 cvsps.
467 467
468 468 Hg debugcvsps reads the CVS rlog for current directory (or any
469 469 named directory) in the CVS repository, and converts the log to a
470 470 series of changesets based on matching commit log entries and
471 471 dates.'''
472 472 return cvsps.debugcvsps(ui, *args, **opts)
473 473
474 474 def kwconverted(ctx, name):
475 475 rev = ctx.extra().get('convert_revision', '')
476 476 if rev.startswith('svn:'):
477 477 if name == 'svnrev':
478 478 return str(subversion.revsplit(rev)[2])
479 479 elif name == 'svnpath':
480 480 return subversion.revsplit(rev)[1]
481 481 elif name == 'svnuuid':
482 482 return subversion.revsplit(rev)[0]
483 483 return rev
484 484
485 485 templatekeyword = registrar.templatekeyword()
486 486
487 487 @templatekeyword('svnrev')
488 488 def kwsvnrev(repo, ctx, **args):
489 489 """String. Converted subversion revision number."""
490 490 return kwconverted(ctx, 'svnrev')
491 491
492 492 @templatekeyword('svnpath')
493 493 def kwsvnpath(repo, ctx, **args):
494 494 """String. Converted subversion revision project path."""
495 495 return kwconverted(ctx, 'svnpath')
496 496
497 497 @templatekeyword('svnuuid')
498 498 def kwsvnuuid(repo, ctx, **args):
499 499 """String. Converted subversion revision repository identifier."""
500 500 return kwconverted(ctx, 'svnuuid')
501 501
502 502 # tell hggettext to extract docstrings from these functions:
503 503 i18nfunctions = [kwsvnrev, kwsvnpath, kwsvnuuid]
@@ -1,583 +1,610
1 1 $ cat >> $HGRCPATH <<EOF
2 2 > [extensions]
3 3 > convert=
4 4 > [convert]
5 5 > hg.saverev=False
6 6 > EOF
7 7 $ hg help convert
8 8 hg convert [OPTION]... SOURCE [DEST [REVMAP]]
9 9
10 10 convert a foreign SCM repository to a Mercurial one.
11 11
12 12 Accepted source formats [identifiers]:
13 13
14 14 - Mercurial [hg]
15 15 - CVS [cvs]
16 16 - Darcs [darcs]
17 17 - git [git]
18 18 - Subversion [svn]
19 19 - Monotone [mtn]
20 20 - GNU Arch [gnuarch]
21 21 - Bazaar [bzr]
22 22 - Perforce [p4]
23 23
24 24 Accepted destination formats [identifiers]:
25 25
26 26 - Mercurial [hg]
27 27 - Subversion [svn] (history on branches is not preserved)
28 28
29 29 If no revision is given, all revisions will be converted. Otherwise,
30 30 convert will only import up to the named revision (given in a format
31 31 understood by the source).
32 32
33 33 If no destination directory name is specified, it defaults to the basename
34 34 of the source with "-hg" appended. If the destination repository doesn't
35 35 exist, it will be created.
36 36
37 37 By default, all sources except Mercurial will use --branchsort. Mercurial
38 38 uses --sourcesort to preserve original revision numbers order. Sort modes
39 39 have the following effects:
40 40
41 41 --branchsort convert from parent to child revision when possible, which
42 42 means branches are usually converted one after the other.
43 43 It generates more compact repositories.
44 44 --datesort sort revisions by date. Converted repositories have good-
45 45 looking changelogs but are often an order of magnitude
46 46 larger than the same ones generated by --branchsort.
47 47 --sourcesort try to preserve source revisions order, only supported by
48 48 Mercurial sources.
49 49 --closesort try to move closed revisions as close as possible to parent
50 50 branches, only supported by Mercurial sources.
51 51
52 52 If "REVMAP" isn't given, it will be put in a default location
53 53 ("<dest>/.hg/shamap" by default). The "REVMAP" is a simple text file that
54 54 maps each source commit ID to the destination ID for that revision, like
55 55 so:
56 56
57 57 <source ID> <destination ID>
58 58
59 59 If the file doesn't exist, it's automatically created. It's updated on
60 60 each commit copied, so 'hg convert' can be interrupted and can be run
61 61 repeatedly to copy new commits.
62 62
63 63 The authormap is a simple text file that maps each source commit author to
64 64 a destination commit author. It is handy for source SCMs that use unix
65 65 logins to identify authors (e.g.: CVS). One line per author mapping and
66 66 the line format is:
67 67
68 68 source author = destination author
69 69
70 70 Empty lines and lines starting with a "#" are ignored.
71 71
72 72 The filemap is a file that allows filtering and remapping of files and
73 73 directories. Each line can contain one of the following directives:
74 74
75 75 include path/to/file-or-dir
76 76
77 77 exclude path/to/file-or-dir
78 78
79 79 rename path/to/source path/to/destination
80 80
81 81 Comment lines start with "#". A specified path matches if it equals the
82 82 full relative name of a file or one of its parent directories. The
83 83 "include" or "exclude" directive with the longest matching path applies,
84 84 so line order does not matter.
85 85
86 86 The "include" directive causes a file, or all files under a directory, to
87 87 be included in the destination repository. The default if there are no
88 88 "include" statements is to include everything. If there are any "include"
89 89 statements, nothing else is included. The "exclude" directive causes files
90 90 or directories to be omitted. The "rename" directive renames a file or
91 91 directory if it is converted. To rename from a subdirectory into the root
92 92 of the repository, use "." as the path to rename to.
93 93
94 94 "--full" will make sure the converted changesets contain exactly the right
95 95 files with the right content. It will make a full conversion of all files,
96 96 not just the ones that have changed. Files that already are correct will
97 97 not be changed. This can be used to apply filemap changes when converting
98 98 incrementally. This is currently only supported for Mercurial and
99 99 Subversion.
100 100
101 101 The splicemap is a file that allows insertion of synthetic history,
102 102 letting you specify the parents of a revision. This is useful if you want
103 103 to e.g. give a Subversion merge two parents, or graft two disconnected
104 104 series of history together. Each entry contains a key, followed by a
105 105 space, followed by one or two comma-separated values:
106 106
107 107 key parent1, parent2
108 108
109 109 The key is the revision ID in the source revision control system whose
110 110 parents should be modified (same format as a key in .hg/shamap). The
111 111 values are the revision IDs (in either the source or destination revision
112 112 control system) that should be used as the new parents for that node. For
113 113 example, if you have merged "release-1.0" into "trunk", then you should
114 114 specify the revision on "trunk" as the first parent and the one on the
115 115 "release-1.0" branch as the second.
116 116
117 117 The branchmap is a file that allows you to rename a branch when it is
118 118 being brought in from whatever external repository. When used in
119 119 conjunction with a splicemap, it allows for a powerful combination to help
120 120 fix even the most badly mismanaged repositories and turn them into nicely
121 121 structured Mercurial repositories. The branchmap contains lines of the
122 122 form:
123 123
124 124 original_branch_name new_branch_name
125 125
126 126 where "original_branch_name" is the name of the branch in the source
127 127 repository, and "new_branch_name" is the name of the branch is the
128 destination repository. No whitespace is allowed in the branch names. This
129 can be used to (for instance) move code in one repository from "default"
130 to a named branch.
128 destination repository. No whitespace is allowed in the new branch name.
129 This can be used to (for instance) move code in one repository from
130 "default" to a named branch.
131 131
132 132 Mercurial Source
133 133 ################
134 134
135 135 The Mercurial source recognizes the following configuration options, which
136 136 you can set on the command line with "--config":
137 137
138 138 convert.hg.ignoreerrors
139 139 ignore integrity errors when reading. Use it to fix
140 140 Mercurial repositories with missing revlogs, by converting
141 141 from and to Mercurial. Default is False.
142 142 convert.hg.saverev
143 143 store original revision ID in changeset (forces target IDs
144 144 to change). It takes a boolean argument and defaults to
145 145 False.
146 146 convert.hg.startrev
147 147 specify the initial Mercurial revision. The default is 0.
148 148 convert.hg.revs
149 149 revset specifying the source revisions to convert.
150 150
151 151 CVS Source
152 152 ##########
153 153
154 154 CVS source will use a sandbox (i.e. a checked-out copy) from CVS to
155 155 indicate the starting point of what will be converted. Direct access to
156 156 the repository files is not needed, unless of course the repository is
157 157 ":local:". The conversion uses the top level directory in the sandbox to
158 158 find the CVS repository, and then uses CVS rlog commands to find files to
159 159 convert. This means that unless a filemap is given, all files under the
160 160 starting directory will be converted, and that any directory
161 161 reorganization in the CVS sandbox is ignored.
162 162
163 163 The following options can be used with "--config":
164 164
165 165 convert.cvsps.cache
166 166 Set to False to disable remote log caching, for testing and
167 167 debugging purposes. Default is True.
168 168 convert.cvsps.fuzz
169 169 Specify the maximum time (in seconds) that is allowed
170 170 between commits with identical user and log message in a
171 171 single changeset. When very large files were checked in as
172 172 part of a changeset then the default may not be long enough.
173 173 The default is 60.
174 174 convert.cvsps.mergeto
175 175 Specify a regular expression to which commit log messages
176 176 are matched. If a match occurs, then the conversion process
177 177 will insert a dummy revision merging the branch on which
178 178 this log message occurs to the branch indicated in the
179 179 regex. Default is "{{mergetobranch ([-\w]+)}}"
180 180 convert.cvsps.mergefrom
181 181 Specify a regular expression to which commit log messages
182 182 are matched. If a match occurs, then the conversion process
183 183 will add the most recent revision on the branch indicated in
184 184 the regex as the second parent of the changeset. Default is
185 185 "{{mergefrombranch ([-\w]+)}}"
186 186 convert.localtimezone
187 187 use local time (as determined by the TZ environment
188 188 variable) for changeset date/times. The default is False
189 189 (use UTC).
190 190 hooks.cvslog Specify a Python function to be called at the end of
191 191 gathering the CVS log. The function is passed a list with
192 192 the log entries, and can modify the entries in-place, or add
193 193 or delete them.
194 194 hooks.cvschangesets
195 195 Specify a Python function to be called after the changesets
196 196 are calculated from the CVS log. The function is passed a
197 197 list with the changeset entries, and can modify the
198 198 changesets in-place, or add or delete them.
199 199
200 200 An additional "debugcvsps" Mercurial command allows the builtin changeset
201 201 merging code to be run without doing a conversion. Its parameters and
202 202 output are similar to that of cvsps 2.1. Please see the command help for
203 203 more details.
204 204
205 205 Subversion Source
206 206 #################
207 207
208 208 Subversion source detects classical trunk/branches/tags layouts. By
209 209 default, the supplied "svn://repo/path/" source URL is converted as a
210 210 single branch. If "svn://repo/path/trunk" exists it replaces the default
211 211 branch. If "svn://repo/path/branches" exists, its subdirectories are
212 212 listed as possible branches. If "svn://repo/path/tags" exists, it is
213 213 looked for tags referencing converted branches. Default "trunk",
214 214 "branches" and "tags" values can be overridden with following options. Set
215 215 them to paths relative to the source URL, or leave them blank to disable
216 216 auto detection.
217 217
218 218 The following options can be set with "--config":
219 219
220 220 convert.svn.branches
221 221 specify the directory containing branches. The default is
222 222 "branches".
223 223 convert.svn.tags
224 224 specify the directory containing tags. The default is
225 225 "tags".
226 226 convert.svn.trunk
227 227 specify the name of the trunk branch. The default is
228 228 "trunk".
229 229 convert.localtimezone
230 230 use local time (as determined by the TZ environment
231 231 variable) for changeset date/times. The default is False
232 232 (use UTC).
233 233
234 234 Source history can be retrieved starting at a specific revision, instead
235 235 of being integrally converted. Only single branch conversions are
236 236 supported.
237 237
238 238 convert.svn.startrev
239 239 specify start Subversion revision number. The default is 0.
240 240
241 241 Git Source
242 242 ##########
243 243
244 244 The Git importer converts commits from all reachable branches (refs in
245 245 refs/heads) and remotes (refs in refs/remotes) to Mercurial. Branches are
246 246 converted to bookmarks with the same name, with the leading 'refs/heads'
247 247 stripped. Git submodules are converted to Git subrepos in Mercurial.
248 248
249 249 The following options can be set with "--config":
250 250
251 251 convert.git.similarity
252 252 specify how similar files modified in a commit must be to be
253 253 imported as renames or copies, as a percentage between "0"
254 254 (disabled) and "100" (files must be identical). For example,
255 255 "90" means that a delete/add pair will be imported as a
256 256 rename if more than 90% of the file hasn't changed. The
257 257 default is "50".
258 258 convert.git.findcopiesharder
259 259 while detecting copies, look at all files in the working
260 260 copy instead of just changed ones. This is very expensive
261 261 for large projects, and is only effective when
262 262 "convert.git.similarity" is greater than 0. The default is
263 263 False.
264 264 convert.git.renamelimit
265 265 perform rename and copy detection up to this many changed
266 266 files in a commit. Increasing this will make rename and copy
267 267 detection more accurate but will significantly slow down
268 268 computation on large projects. The option is only relevant
269 269 if "convert.git.similarity" is greater than 0. The default
270 270 is "400".
271 271 convert.git.committeractions
272 272 list of actions to take when processing author and committer
273 273 values.
274 274
275 275 Git commits have separate author (who wrote the commit) and committer
276 276 (who applied the commit) fields. Not all destinations support separate
277 277 author and committer fields (including Mercurial). This config option
278 278 controls what to do with these author and committer fields during
279 279 conversion.
280 280
281 281 A value of "messagedifferent" will append a "committer: ..." line to
282 282 the commit message if the Git committer is different from the author.
283 283 The prefix of that line can be specified using the syntax
284 284 "messagedifferent=<prefix>". e.g. "messagedifferent=git-committer:".
285 285 When a prefix is specified, a space will always be inserted between
286 286 the prefix and the value.
287 287
288 288 "messagealways" behaves like "messagedifferent" except it will always
289 289 result in a "committer: ..." line being appended to the commit
290 290 message. This value is mutually exclusive with "messagedifferent".
291 291
292 292 "dropcommitter" will remove references to the committer. Only
293 293 references to the author will remain. Actions that add references to
294 294 the committer will have no effect when this is set.
295 295
296 296 "replaceauthor" will replace the value of the author field with the
297 297 committer. Other actions that add references to the committer will
298 298 still take effect when this is set.
299 299
300 300 The default is "messagedifferent".
301 301
302 302 convert.git.extrakeys
303 303 list of extra keys from commit metadata to copy to the
304 304 destination. Some Git repositories store extra metadata in
305 305 commits. By default, this non-default metadata will be lost
306 306 during conversion. Setting this config option can retain
307 307 that metadata. Some built-in keys such as "parent" and
308 308 "branch" are not allowed to be copied.
309 309 convert.git.remoteprefix
310 310 remote refs are converted as bookmarks with
311 311 "convert.git.remoteprefix" as a prefix followed by a /. The
312 312 default is 'remote'.
313 313 convert.git.saverev
314 314 whether to store the original Git commit ID in the metadata
315 315 of the destination commit. The default is True.
316 316 convert.git.skipsubmodules
317 317 does not convert root level .gitmodules files or files with
318 318 160000 mode indicating a submodule. Default is False.
319 319
320 320 Perforce Source
321 321 ###############
322 322
323 323 The Perforce (P4) importer can be given a p4 depot path or a client
324 324 specification as source. It will convert all files in the source to a flat
325 325 Mercurial repository, ignoring labels, branches and integrations. Note
326 326 that when a depot path is given you then usually should specify a target
327 327 directory, because otherwise the target may be named "...-hg".
328 328
329 329 The following options can be set with "--config":
330 330
331 331 convert.p4.encoding
332 332 specify the encoding to use when decoding standard output of
333 333 the Perforce command line tool. The default is default
334 334 system encoding.
335 335 convert.p4.startrev
336 336 specify initial Perforce revision (a Perforce changelist
337 337 number).
338 338
339 339 Mercurial Destination
340 340 #####################
341 341
342 342 The Mercurial destination will recognize Mercurial subrepositories in the
343 343 destination directory, and update the .hgsubstate file automatically if
344 344 the destination subrepositories contain the <dest>/<sub>/.hg/shamap file.
345 345 Converting a repository with subrepositories requires converting a single
346 346 repository at a time, from the bottom up.
347 347
348 348 The following options are supported:
349 349
350 350 convert.hg.clonebranches
351 351 dispatch source branches in separate clones. The default is
352 352 False.
353 353 convert.hg.tagsbranch
354 354 branch name for tag revisions, defaults to "default".
355 355 convert.hg.usebranchnames
356 356 preserve branch names. The default is True.
357 357 convert.hg.sourcename
358 358 records the given string as a 'convert_source' extra value
359 359 on each commit made in the target repository. The default is
360 360 None.
361 361
362 362 All Destinations
363 363 ################
364 364
365 365 All destination types accept the following options:
366 366
367 367 convert.skiptags
368 368 does not convert tags from the source repo to the target
369 369 repo. The default is False.
370 370
371 371 options ([+] can be repeated):
372 372
373 373 -s --source-type TYPE source repository type
374 374 -d --dest-type TYPE destination repository type
375 375 -r --rev REV [+] import up to source revision REV
376 376 -A --authormap FILE remap usernames using this file
377 377 --filemap FILE remap file names using contents of file
378 378 --full apply filemap changes by converting all files again
379 379 --splicemap FILE splice synthesized history into place
380 380 --branchmap FILE change branch names while converting
381 381 --branchsort try to sort changesets by branches
382 382 --datesort try to sort changesets by date
383 383 --sourcesort preserve source changesets order
384 384 --closesort try to reorder closed revisions
385 385
386 386 (some details hidden, use --verbose to show complete help)
387 387 $ hg init a
388 388 $ cd a
389 389 $ echo a > a
390 390 $ hg ci -d'0 0' -Ama
391 391 adding a
392 392 $ hg cp a b
393 393 $ hg ci -d'1 0' -mb
394 394 $ hg rm a
395 395 $ hg ci -d'2 0' -mc
396 396 $ hg mv b a
397 397 $ hg ci -d'3 0' -md
398 398 $ echo a >> a
399 399 $ hg ci -d'4 0' -me
400 400 $ cd ..
401 401 $ hg convert a 2>&1 | grep -v 'subversion python bindings could not be loaded'
402 402 assuming destination a-hg
403 403 initializing destination a-hg repository
404 404 scanning source...
405 405 sorting...
406 406 converting...
407 407 4 a
408 408 3 b
409 409 2 c
410 410 1 d
411 411 0 e
412 412 $ hg --cwd a-hg pull ../a
413 413 pulling from ../a
414 414 searching for changes
415 415 no changes found
416 416
417 417 conversion to existing file should fail
418 418
419 419 $ touch bogusfile
420 420 $ hg convert a bogusfile
421 421 initializing destination bogusfile repository
422 422 abort: cannot create new bundle repository
423 423 [255]
424 424
425 425 #if unix-permissions no-root
426 426
427 427 conversion to dir without permissions should fail
428 428
429 429 $ mkdir bogusdir
430 430 $ chmod 000 bogusdir
431 431
432 432 $ hg convert a bogusdir
433 433 abort: Permission denied: 'bogusdir'
434 434 [255]
435 435
436 436 user permissions should succeed
437 437
438 438 $ chmod 700 bogusdir
439 439 $ hg convert a bogusdir
440 440 initializing destination bogusdir repository
441 441 scanning source...
442 442 sorting...
443 443 converting...
444 444 4 a
445 445 3 b
446 446 2 c
447 447 1 d
448 448 0 e
449 449
450 450 #endif
451 451
452 452 test pre and post conversion actions
453 453
454 454 $ echo 'include b' > filemap
455 455 $ hg convert --debug --filemap filemap a partialb | \
456 456 > grep 'run hg'
457 457 run hg source pre-conversion action
458 458 run hg sink pre-conversion action
459 459 run hg sink post-conversion action
460 460 run hg source post-conversion action
461 461
462 462 converting empty dir should fail "nicely
463 463
464 464 $ mkdir emptydir
465 465
466 466 override $PATH to ensure p4 not visible; use $PYTHON in case we're
467 467 running from a devel copy, not a temp installation
468 468
469 469 $ PATH="$BINDIR" $PYTHON "$BINDIR"/hg convert emptydir
470 470 assuming destination emptydir-hg
471 471 initializing destination emptydir-hg repository
472 472 emptydir does not look like a CVS checkout
473 473 $TESTTMP/emptydir does not look like a Git repository (glob)
474 474 emptydir does not look like a Subversion repository
475 475 emptydir is not a local Mercurial repository
476 476 emptydir does not look like a darcs repository
477 477 emptydir does not look like a monotone repository
478 478 emptydir does not look like a GNU Arch repository
479 479 emptydir does not look like a Bazaar repository
480 480 cannot find required "p4" tool
481 481 abort: emptydir: missing or unsupported repository
482 482 [255]
483 483
484 484 convert with imaginary source type
485 485
486 486 $ hg convert --source-type foo a a-foo
487 487 initializing destination a-foo repository
488 488 abort: foo: invalid source repository type
489 489 [255]
490 490
491 491 convert with imaginary sink type
492 492
493 493 $ hg convert --dest-type foo a a-foo
494 494 abort: foo: invalid destination repository type
495 495 [255]
496 496
497 497 testing: convert must not produce duplicate entries in fncache
498 498
499 499 $ hg convert a b
500 500 initializing destination b repository
501 501 scanning source...
502 502 sorting...
503 503 converting...
504 504 4 a
505 505 3 b
506 506 2 c
507 507 1 d
508 508 0 e
509 509
510 510 contents of fncache file:
511 511
512 512 $ cat b/.hg/store/fncache | sort
513 513 data/a.i
514 514 data/b.i
515 515
516 516 test bogus URL
517 517
518 518 $ hg convert -q bzr+ssh://foobar@selenic.com/baz baz
519 519 abort: bzr+ssh://foobar@selenic.com/baz: missing or unsupported repository
520 520 [255]
521 521
522 522 test revset converted() lookup
523 523
524 524 $ hg --config convert.hg.saverev=True convert a c
525 525 initializing destination c repository
526 526 scanning source...
527 527 sorting...
528 528 converting...
529 529 4 a
530 530 3 b
531 531 2 c
532 532 1 d
533 533 0 e
534 534 $ echo f > c/f
535 535 $ hg -R c ci -d'0 0' -Amf
536 536 adding f
537 537 created new head
538 538 $ hg -R c log -r "converted(09d945a62ce6)"
539 539 changeset: 1:98c3dd46a874
540 540 user: test
541 541 date: Thu Jan 01 00:00:01 1970 +0000
542 542 summary: b
543 543
544 544 $ hg -R c log -r "converted()"
545 545 changeset: 0:31ed57b2037c
546 546 user: test
547 547 date: Thu Jan 01 00:00:00 1970 +0000
548 548 summary: a
549 549
550 550 changeset: 1:98c3dd46a874
551 551 user: test
552 552 date: Thu Jan 01 00:00:01 1970 +0000
553 553 summary: b
554 554
555 555 changeset: 2:3b9ca06ef716
556 556 user: test
557 557 date: Thu Jan 01 00:00:02 1970 +0000
558 558 summary: c
559 559
560 560 changeset: 3:4e0debd37cf2
561 561 user: test
562 562 date: Thu Jan 01 00:00:03 1970 +0000
563 563 summary: d
564 564
565 565 changeset: 4:9de3bc9349c5
566 566 user: test
567 567 date: Thu Jan 01 00:00:04 1970 +0000
568 568 summary: e
569 569
570 570
571 571 test specifying a sourcename
572 572 $ echo g > a/g
573 573 $ hg -R a ci -d'0 0' -Amg
574 574 adding g
575 575 $ hg --config convert.hg.sourcename=mysource --config convert.hg.saverev=True convert a c
576 576 scanning source...
577 577 sorting...
578 578 converting...
579 579 0 g
580 580 $ hg -R c log -r tip --template '{extras % "{extra}\n"}'
581 581 branch=default
582 582 convert_revision=a3bc6100aa8ec03e00aaf271f1f50046fb432072
583 583 convert_source=mysource
584
585 $ cat > branchmap.txt << EOF
586 > old branch new_branch
587 > EOF
588
589 $ hg -R a branch -q 'old branch'
590 $ echo gg > a/g
591 $ hg -R a ci -m 'branch name with spaces'
592 $ hg convert --branchmap branchmap.txt a d
593 initializing destination d repository
594 scanning source...
595 sorting...
596 converting...
597 6 a
598 5 b
599 4 c
600 3 d
601 2 e
602 1 g
603 0 branch name with spaces
604
605 $ hg -R a branches
606 old branch 6:a24a66ade009
607 default 5:a3bc6100aa8e (inactive)
608 $ hg -R d branches
609 new_branch 6:64ed208b732b
610 default 5:a3bc6100aa8e (inactive)
General Comments 0
You need to be logged in to leave comments. Login now