##// END OF EJS Templates
convert: add tagmap option...
Sean Farley -
r20379:b75a0450 default
parent child Browse files
Show More
@@ -1,388 +1,394 b''
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, templatekw
14 14 from mercurial.i18n import _
15 15
16 16 testedwith = 'internal'
17 17
18 18 # Commands definition was moved elsewhere to ease demandload job.
19 19
20 20 def convert(ui, src, dest=None, revmapfile=None, **opts):
21 21 """convert a foreign SCM repository to a Mercurial one.
22 22
23 23 Accepted source formats [identifiers]:
24 24
25 25 - Mercurial [hg]
26 26 - CVS [cvs]
27 27 - Darcs [darcs]
28 28 - git [git]
29 29 - Subversion [svn]
30 30 - Monotone [mtn]
31 31 - GNU Arch [gnuarch]
32 32 - Bazaar [bzr]
33 33 - Perforce [p4]
34 34
35 35 Accepted destination formats [identifiers]:
36 36
37 37 - Mercurial [hg]
38 38 - Subversion [svn] (history on branches is not preserved)
39 39
40 40 If no revision is given, all revisions will be converted.
41 41 Otherwise, convert will only import up to the named revision
42 42 (given in a format understood by the source).
43 43
44 44 If no destination directory name is specified, it defaults to the
45 45 basename of the source with ``-hg`` appended. If the destination
46 46 repository doesn't exist, it will be created.
47 47
48 48 By default, all sources except Mercurial will use --branchsort.
49 49 Mercurial uses --sourcesort to preserve original revision numbers
50 50 order. Sort modes have the following effects:
51 51
52 52 --branchsort convert from parent to child revision when possible,
53 53 which means branches are usually converted one after
54 54 the other. It generates more compact repositories.
55 55
56 56 --datesort sort revisions by date. Converted repositories have
57 57 good-looking changelogs but are often an order of
58 58 magnitude larger than the same ones generated by
59 59 --branchsort.
60 60
61 61 --sourcesort try to preserve source revisions order, only
62 62 supported by Mercurial sources.
63 63
64 64 --closesort try to move closed revisions as close as possible
65 65 to parent branches, only supported by Mercurial
66 66 sources.
67 67
68 68 If ``REVMAP`` isn't given, it will be put in a default location
69 69 (``<dest>/.hg/shamap`` by default). The ``REVMAP`` is a simple
70 70 text file that maps each source commit ID to the destination ID
71 71 for that revision, like so::
72 72
73 73 <source ID> <destination ID>
74 74
75 75 If the file doesn't exist, it's automatically created. It's
76 76 updated on each commit copied, so :hg:`convert` can be interrupted
77 77 and can be run repeatedly to copy new commits.
78 78
79 79 The authormap is a simple text file that maps each source commit
80 80 author to a destination commit author. It is handy for source SCMs
81 81 that use unix logins to identify authors (e.g.: CVS). One line per
82 82 author mapping and the line format is::
83 83
84 84 source author = destination author
85 85
86 86 Empty lines and lines starting with a ``#`` are ignored.
87 87
88 88 The filemap is a file that allows filtering and remapping of files
89 89 and directories. Each line can contain one of the following
90 90 directives::
91 91
92 92 include path/to/file-or-dir
93 93
94 94 exclude path/to/file-or-dir
95 95
96 96 rename path/to/source path/to/destination
97 97
98 98 Comment lines start with ``#``. A specified path matches if it
99 99 equals the full relative name of a file or one of its parent
100 100 directories. The ``include`` or ``exclude`` directive with the
101 101 longest matching path applies, so line order does not matter.
102 102
103 103 The ``include`` directive causes a file, or all files under a
104 104 directory, to be included in the destination repository, and the
105 105 exclusion of all other files and directories not explicitly
106 106 included. The ``exclude`` directive causes files or directories to
107 107 be omitted. The ``rename`` directive renames a file or directory if
108 108 it is converted. To rename from a subdirectory into the root of
109 109 the repository, use ``.`` as the path to rename to.
110 110
111 111 The splicemap is a file that allows insertion of synthetic
112 112 history, letting you specify the parents of a revision. This is
113 113 useful if you want to e.g. give a Subversion merge two parents, or
114 114 graft two disconnected series of history together. Each entry
115 115 contains a key, followed by a space, followed by one or two
116 116 comma-separated values::
117 117
118 118 key parent1, parent2
119 119
120 120 The key is the revision ID in the source
121 121 revision control system whose parents should be modified (same
122 122 format as a key in .hg/shamap). The values are the revision IDs
123 123 (in either the source or destination revision control system) that
124 124 should be used as the new parents for that node. For example, if
125 125 you have merged "release-1.0" into "trunk", then you should
126 126 specify the revision on "trunk" as the first parent and the one on
127 127 the "release-1.0" branch as the second.
128 128
129 129 The branchmap is a file that allows you to rename a branch when it is
130 130 being brought in from whatever external repository. When used in
131 131 conjunction with a splicemap, it allows for a powerful combination
132 132 to help fix even the most badly mismanaged repositories and turn them
133 133 into nicely structured Mercurial repositories. The branchmap contains
134 134 lines of the form::
135 135
136 136 original_branch_name new_branch_name
137 137
138 138 where "original_branch_name" is the name of the branch in the
139 139 source repository, and "new_branch_name" is the name of the branch
140 140 is the destination repository. No whitespace is allowed in the
141 141 branch names. This can be used to (for instance) move code in one
142 142 repository from "default" to a named branch.
143 143
144 144 The closemap is a file that allows closing of a branch. This is useful if
145 145 you want to close a branch. Each entry contains a revision or hash
146 146 separated by white space.
147 147
148 The tagpmap is a file that exactly analogous to the branchmap. This will
149 rename tags on the fly and prevent the 'update tags' commit usually found
150 at the end of a convert process.
151
148 152 Mercurial Source
149 153 ################
150 154
151 155 The Mercurial source recognizes the following configuration
152 156 options, which you can set on the command line with ``--config``:
153 157
154 158 :convert.hg.ignoreerrors: ignore integrity errors when reading.
155 159 Use it to fix Mercurial repositories with missing revlogs, by
156 160 converting from and to Mercurial. Default is False.
157 161
158 162 :convert.hg.saverev: store original revision ID in changeset
159 163 (forces target IDs to change). It takes a boolean argument and
160 164 defaults to False.
161 165
162 166 :convert.hg.revs: revset specifying the source revisions to convert.
163 167
164 168 CVS Source
165 169 ##########
166 170
167 171 CVS source will use a sandbox (i.e. a checked-out copy) from CVS
168 172 to indicate the starting point of what will be converted. Direct
169 173 access to the repository files is not needed, unless of course the
170 174 repository is ``:local:``. The conversion uses the top level
171 175 directory in the sandbox to find the CVS repository, and then uses
172 176 CVS rlog commands to find files to convert. This means that unless
173 177 a filemap is given, all files under the starting directory will be
174 178 converted, and that any directory reorganization in the CVS
175 179 sandbox is ignored.
176 180
177 181 The following options can be used with ``--config``:
178 182
179 183 :convert.cvsps.cache: Set to False to disable remote log caching,
180 184 for testing and debugging purposes. Default is True.
181 185
182 186 :convert.cvsps.fuzz: Specify the maximum time (in seconds) that is
183 187 allowed between commits with identical user and log message in
184 188 a single changeset. When very large files were checked in as
185 189 part of a changeset then the default may not be long enough.
186 190 The default is 60.
187 191
188 192 :convert.cvsps.mergeto: Specify a regular expression to which
189 193 commit log messages are matched. If a match occurs, then the
190 194 conversion process will insert a dummy revision merging the
191 195 branch on which this log message occurs to the branch
192 196 indicated in the regex. Default is ``{{mergetobranch
193 197 ([-\\w]+)}}``
194 198
195 199 :convert.cvsps.mergefrom: Specify a regular expression to which
196 200 commit log messages are matched. If a match occurs, then the
197 201 conversion process will add the most recent revision on the
198 202 branch indicated in the regex as the second parent of the
199 203 changeset. Default is ``{{mergefrombranch ([-\\w]+)}}``
200 204
201 205 :convert.localtimezone: use local time (as determined by the TZ
202 206 environment variable) for changeset date/times. The default
203 207 is False (use UTC).
204 208
205 209 :hooks.cvslog: Specify a Python function to be called at the end of
206 210 gathering the CVS log. The function is passed a list with the
207 211 log entries, and can modify the entries in-place, or add or
208 212 delete them.
209 213
210 214 :hooks.cvschangesets: Specify a Python function to be called after
211 215 the changesets are calculated from the CVS log. The
212 216 function is passed a list with the changeset entries, and can
213 217 modify the changesets in-place, or add or delete them.
214 218
215 219 An additional "debugcvsps" Mercurial command allows the builtin
216 220 changeset merging code to be run without doing a conversion. Its
217 221 parameters and output are similar to that of cvsps 2.1. Please see
218 222 the command help for more details.
219 223
220 224 Subversion Source
221 225 #################
222 226
223 227 Subversion source detects classical trunk/branches/tags layouts.
224 228 By default, the supplied ``svn://repo/path/`` source URL is
225 229 converted as a single branch. If ``svn://repo/path/trunk`` exists
226 230 it replaces the default branch. If ``svn://repo/path/branches``
227 231 exists, its subdirectories are listed as possible branches. If
228 232 ``svn://repo/path/tags`` exists, it is looked for tags referencing
229 233 converted branches. Default ``trunk``, ``branches`` and ``tags``
230 234 values can be overridden with following options. Set them to paths
231 235 relative to the source URL, or leave them blank to disable auto
232 236 detection.
233 237
234 238 The following options can be set with ``--config``:
235 239
236 240 :convert.svn.branches: specify the directory containing branches.
237 241 The default is ``branches``.
238 242
239 243 :convert.svn.tags: specify the directory containing tags. The
240 244 default is ``tags``.
241 245
242 246 :convert.svn.trunk: specify the name of the trunk branch. The
243 247 default is ``trunk``.
244 248
245 249 :convert.localtimezone: use local time (as determined by the TZ
246 250 environment variable) for changeset date/times. The default
247 251 is False (use UTC).
248 252
249 253 Source history can be retrieved starting at a specific revision,
250 254 instead of being integrally converted. Only single branch
251 255 conversions are supported.
252 256
253 257 :convert.svn.startrev: specify start Subversion revision number.
254 258 The default is 0.
255 259
256 260 Perforce Source
257 261 ###############
258 262
259 263 The Perforce (P4) importer can be given a p4 depot path or a
260 264 client specification as source. It will convert all files in the
261 265 source to a flat Mercurial repository, ignoring labels, branches
262 266 and integrations. Note that when a depot path is given you then
263 267 usually should specify a target directory, because otherwise the
264 268 target may be named ``...-hg``.
265 269
266 270 It is possible to limit the amount of source history to be
267 271 converted by specifying an initial Perforce revision:
268 272
269 273 :convert.p4.startrev: specify initial Perforce revision (a
270 274 Perforce changelist number).
271 275
272 276 Mercurial Destination
273 277 #####################
274 278
275 279 The following options are supported:
276 280
277 281 :convert.hg.clonebranches: dispatch source branches in separate
278 282 clones. The default is False.
279 283
280 284 :convert.hg.tagsbranch: branch name for tag revisions, defaults to
281 285 ``default``.
282 286
283 287 :convert.hg.usebranchnames: preserve branch names. The default is
284 288 True.
285 289 """
286 290 return convcmd.convert(ui, src, dest, revmapfile, **opts)
287 291
288 292 def debugsvnlog(ui, **opts):
289 293 return subversion.debugsvnlog(ui, **opts)
290 294
291 295 def debugcvsps(ui, *args, **opts):
292 296 '''create changeset information from CVS
293 297
294 298 This command is intended as a debugging tool for the CVS to
295 299 Mercurial converter, and can be used as a direct replacement for
296 300 cvsps.
297 301
298 302 Hg debugcvsps reads the CVS rlog for current directory (or any
299 303 named directory) in the CVS repository, and converts the log to a
300 304 series of changesets based on matching commit log entries and
301 305 dates.'''
302 306 return cvsps.debugcvsps(ui, *args, **opts)
303 307
304 308 commands.norepo += " convert debugsvnlog debugcvsps"
305 309
306 310 cmdtable = {
307 311 "convert":
308 312 (convert,
309 313 [('', 'authors', '',
310 314 _('username mapping filename (DEPRECATED, use --authormap instead)'),
311 315 _('FILE')),
312 316 ('s', 'source-type', '',
313 317 _('source repository type'), _('TYPE')),
314 318 ('d', 'dest-type', '',
315 319 _('destination repository type'), _('TYPE')),
316 320 ('r', 'rev', '',
317 321 _('import up to source revision REV'), _('REV')),
318 322 ('A', 'authormap', '',
319 323 _('remap usernames using this file'), _('FILE')),
320 324 ('', 'filemap', '',
321 325 _('remap file names using contents of file'), _('FILE')),
322 326 ('', 'splicemap', '',
323 327 _('splice synthesized history into place'), _('FILE')),
324 328 ('', 'branchmap', '',
325 329 _('change branch names while converting'), _('FILE')),
326 330 ('', 'closemap', '',
327 331 _('closes given revs'), _('FILE')),
332 ('', 'tagmap', '',
333 _('change tag names while converting'), _('FILE')),
328 334 ('', 'branchsort', None, _('try to sort changesets by branches')),
329 335 ('', 'datesort', None, _('try to sort changesets by date')),
330 336 ('', 'sourcesort', None, _('preserve source changesets order')),
331 337 ('', 'closesort', None, _('try to reorder closed revisions'))],
332 338 _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]')),
333 339 "debugsvnlog":
334 340 (debugsvnlog,
335 341 [],
336 342 'hg debugsvnlog'),
337 343 "debugcvsps":
338 344 (debugcvsps,
339 345 [
340 346 # Main options shared with cvsps-2.1
341 347 ('b', 'branches', [], _('only return changes on specified branches')),
342 348 ('p', 'prefix', '', _('prefix to remove from file names')),
343 349 ('r', 'revisions', [],
344 350 _('only return changes after or between specified tags')),
345 351 ('u', 'update-cache', None, _("update cvs log cache")),
346 352 ('x', 'new-cache', None, _("create new cvs log cache")),
347 353 ('z', 'fuzz', 60, _('set commit time fuzz in seconds')),
348 354 ('', 'root', '', _('specify cvsroot')),
349 355 # Options specific to builtin cvsps
350 356 ('', 'parents', '', _('show parent changesets')),
351 357 ('', 'ancestors', '',
352 358 _('show current changeset in ancestor branches')),
353 359 # Options that are ignored for compatibility with cvsps-2.1
354 360 ('A', 'cvs-direct', None, _('ignored for compatibility')),
355 361 ],
356 362 _('hg debugcvsps [OPTION]... [PATH]...')),
357 363 }
358 364
359 365 def kwconverted(ctx, name):
360 366 rev = ctx.extra().get('convert_revision', '')
361 367 if rev.startswith('svn:'):
362 368 if name == 'svnrev':
363 369 return str(subversion.revsplit(rev)[2])
364 370 elif name == 'svnpath':
365 371 return subversion.revsplit(rev)[1]
366 372 elif name == 'svnuuid':
367 373 return subversion.revsplit(rev)[0]
368 374 return rev
369 375
370 376 def kwsvnrev(repo, ctx, **args):
371 377 """:svnrev: String. Converted subversion revision number."""
372 378 return kwconverted(ctx, 'svnrev')
373 379
374 380 def kwsvnpath(repo, ctx, **args):
375 381 """:svnpath: String. Converted subversion revision project path."""
376 382 return kwconverted(ctx, 'svnpath')
377 383
378 384 def kwsvnuuid(repo, ctx, **args):
379 385 """:svnuuid: String. Converted subversion revision repository identifier."""
380 386 return kwconverted(ctx, 'svnuuid')
381 387
382 388 def extsetup(ui):
383 389 templatekw.keywords['svnrev'] = kwsvnrev
384 390 templatekw.keywords['svnpath'] = kwsvnpath
385 391 templatekw.keywords['svnuuid'] = kwsvnuuid
386 392
387 393 # tell hggettext to extract docstrings from these functions:
388 394 i18nfunctions = [kwsvnrev, kwsvnpath, kwsvnuuid]
@@ -1,462 +1,467 b''
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, and the exclusion of all other
88 88 files and directories not explicitly included. The "exclude" directive
89 89 causes files or directories to be omitted. The "rename" directive renames
90 90 a file or directory if it is converted. To rename from a subdirectory into
91 91 the root of the repository, use "." as the path to rename to.
92 92
93 93 The splicemap is a file that allows insertion of synthetic history,
94 94 letting you specify the parents of a revision. This is useful if you want
95 95 to e.g. give a Subversion merge two parents, or graft two disconnected
96 96 series of history together. Each entry contains a key, followed by a
97 97 space, followed by one or two comma-separated values:
98 98
99 99 key parent1, parent2
100 100
101 101 The key is the revision ID in the source revision control system whose
102 102 parents should be modified (same format as a key in .hg/shamap). The
103 103 values are the revision IDs (in either the source or destination revision
104 104 control system) that should be used as the new parents for that node. For
105 105 example, if you have merged "release-1.0" into "trunk", then you should
106 106 specify the revision on "trunk" as the first parent and the one on the
107 107 "release-1.0" branch as the second.
108 108
109 109 The branchmap is a file that allows you to rename a branch when it is
110 110 being brought in from whatever external repository. When used in
111 111 conjunction with a splicemap, it allows for a powerful combination to help
112 112 fix even the most badly mismanaged repositories and turn them into nicely
113 113 structured Mercurial repositories. The branchmap contains lines of the
114 114 form:
115 115
116 116 original_branch_name new_branch_name
117 117
118 118 where "original_branch_name" is the name of the branch in the source
119 119 repository, and "new_branch_name" is the name of the branch is the
120 120 destination repository. No whitespace is allowed in the branch names. This
121 121 can be used to (for instance) move code in one repository from "default"
122 122 to a named branch.
123 123
124 124 The closemap is a file that allows closing of a branch. This is useful if
125 125 you want to close a branch. Each entry contains a revision or hash
126 126 separated by white space.
127 127
128 The tagpmap is a file that exactly analogous to the branchmap. This will
129 rename tags on the fly and prevent the 'update tags' commit usually found
130 at the end of a convert process.
131
128 132 Mercurial Source
129 133 ################
130 134
131 135 The Mercurial source recognizes the following configuration options, which
132 136 you can set on the command line with "--config":
133 137
134 138 convert.hg.ignoreerrors
135 139 ignore integrity errors when reading. Use it to fix
136 140 Mercurial repositories with missing revlogs, by converting
137 141 from and to Mercurial. Default is False.
138 142 convert.hg.saverev
139 143 store original revision ID in changeset (forces target IDs
140 144 to change). It takes a boolean argument and defaults to
141 145 False.
142 146 convert.hg.revs
143 147 revset specifying the source revisions to convert.
144 148
145 149 CVS Source
146 150 ##########
147 151
148 152 CVS source will use a sandbox (i.e. a checked-out copy) from CVS to
149 153 indicate the starting point of what will be converted. Direct access to
150 154 the repository files is not needed, unless of course the repository is
151 155 ":local:". The conversion uses the top level directory in the sandbox to
152 156 find the CVS repository, and then uses CVS rlog commands to find files to
153 157 convert. This means that unless a filemap is given, all files under the
154 158 starting directory will be converted, and that any directory
155 159 reorganization in the CVS sandbox is ignored.
156 160
157 161 The following options can be used with "--config":
158 162
159 163 convert.cvsps.cache
160 164 Set to False to disable remote log caching, for testing and
161 165 debugging purposes. Default is True.
162 166 convert.cvsps.fuzz
163 167 Specify the maximum time (in seconds) that is allowed
164 168 between commits with identical user and log message in a
165 169 single changeset. When very large files were checked in as
166 170 part of a changeset then the default may not be long enough.
167 171 The default is 60.
168 172 convert.cvsps.mergeto
169 173 Specify a regular expression to which commit log messages
170 174 are matched. If a match occurs, then the conversion process
171 175 will insert a dummy revision merging the branch on which
172 176 this log message occurs to the branch indicated in the
173 177 regex. Default is "{{mergetobranch ([-\w]+)}}"
174 178 convert.cvsps.mergefrom
175 179 Specify a regular expression to which commit log messages
176 180 are matched. If a match occurs, then the conversion process
177 181 will add the most recent revision on the branch indicated in
178 182 the regex as the second parent of the changeset. Default is
179 183 "{{mergefrombranch ([-\w]+)}}"
180 184 convert.localtimezone
181 185 use local time (as determined by the TZ environment
182 186 variable) for changeset date/times. The default is False
183 187 (use UTC).
184 188 hooks.cvslog Specify a Python function to be called at the end of
185 189 gathering the CVS log. The function is passed a list with
186 190 the log entries, and can modify the entries in-place, or add
187 191 or delete them.
188 192 hooks.cvschangesets
189 193 Specify a Python function to be called after the changesets
190 194 are calculated from the CVS log. The function is passed a
191 195 list with the changeset entries, and can modify the
192 196 changesets in-place, or add or delete them.
193 197
194 198 An additional "debugcvsps" Mercurial command allows the builtin changeset
195 199 merging code to be run without doing a conversion. Its parameters and
196 200 output are similar to that of cvsps 2.1. Please see the command help for
197 201 more details.
198 202
199 203 Subversion Source
200 204 #################
201 205
202 206 Subversion source detects classical trunk/branches/tags layouts. By
203 207 default, the supplied "svn://repo/path/" source URL is converted as a
204 208 single branch. If "svn://repo/path/trunk" exists it replaces the default
205 209 branch. If "svn://repo/path/branches" exists, its subdirectories are
206 210 listed as possible branches. If "svn://repo/path/tags" exists, it is
207 211 looked for tags referencing converted branches. Default "trunk",
208 212 "branches" and "tags" values can be overridden with following options. Set
209 213 them to paths relative to the source URL, or leave them blank to disable
210 214 auto detection.
211 215
212 216 The following options can be set with "--config":
213 217
214 218 convert.svn.branches
215 219 specify the directory containing branches. The default is
216 220 "branches".
217 221 convert.svn.tags
218 222 specify the directory containing tags. The default is
219 223 "tags".
220 224 convert.svn.trunk
221 225 specify the name of the trunk branch. The default is
222 226 "trunk".
223 227 convert.localtimezone
224 228 use local time (as determined by the TZ environment
225 229 variable) for changeset date/times. The default is False
226 230 (use UTC).
227 231
228 232 Source history can be retrieved starting at a specific revision, instead
229 233 of being integrally converted. Only single branch conversions are
230 234 supported.
231 235
232 236 convert.svn.startrev
233 237 specify start Subversion revision number. The default is 0.
234 238
235 239 Perforce Source
236 240 ###############
237 241
238 242 The Perforce (P4) importer can be given a p4 depot path or a client
239 243 specification as source. It will convert all files in the source to a flat
240 244 Mercurial repository, ignoring labels, branches and integrations. Note
241 245 that when a depot path is given you then usually should specify a target
242 246 directory, because otherwise the target may be named "...-hg".
243 247
244 248 It is possible to limit the amount of source history to be converted by
245 249 specifying an initial Perforce revision:
246 250
247 251 convert.p4.startrev
248 252 specify initial Perforce revision (a Perforce changelist
249 253 number).
250 254
251 255 Mercurial Destination
252 256 #####################
253 257
254 258 The following options are supported:
255 259
256 260 convert.hg.clonebranches
257 261 dispatch source branches in separate clones. The default is
258 262 False.
259 263 convert.hg.tagsbranch
260 264 branch name for tag revisions, defaults to "default".
261 265 convert.hg.usebranchnames
262 266 preserve branch names. The default is True.
263 267
264 268 options:
265 269
266 270 -s --source-type TYPE source repository type
267 271 -d --dest-type TYPE destination repository type
268 272 -r --rev REV import up to source revision REV
269 273 -A --authormap FILE remap usernames using this file
270 274 --filemap FILE remap file names using contents of file
271 275 --splicemap FILE splice synthesized history into place
272 276 --branchmap FILE change branch names while converting
273 277 --closemap FILE closes given revs
278 --tagmap FILE change tag names while converting
274 279 --branchsort try to sort changesets by branches
275 280 --datesort try to sort changesets by date
276 281 --sourcesort preserve source changesets order
277 282 --closesort try to reorder closed revisions
278 283
279 284 use "hg -v help convert" to show the global options
280 285 $ hg init a
281 286 $ cd a
282 287 $ echo a > a
283 288 $ hg ci -d'0 0' -Ama
284 289 adding a
285 290 $ hg cp a b
286 291 $ hg ci -d'1 0' -mb
287 292 $ hg rm a
288 293 $ hg ci -d'2 0' -mc
289 294 $ hg mv b a
290 295 $ hg ci -d'3 0' -md
291 296 $ echo a >> a
292 297 $ hg ci -d'4 0' -me
293 298 $ cd ..
294 299 $ hg convert a 2>&1 | grep -v 'subversion python bindings could not be loaded'
295 300 assuming destination a-hg
296 301 initializing destination a-hg repository
297 302 scanning source...
298 303 sorting...
299 304 converting...
300 305 4 a
301 306 3 b
302 307 2 c
303 308 1 d
304 309 0 e
305 310 $ hg --cwd a-hg pull ../a
306 311 pulling from ../a
307 312 searching for changes
308 313 no changes found
309 314
310 315 conversion to existing file should fail
311 316
312 317 $ touch bogusfile
313 318 $ hg convert a bogusfile
314 319 initializing destination bogusfile repository
315 320 abort: cannot create new bundle repository
316 321 [255]
317 322
318 323 #if unix-permissions no-root
319 324
320 325 conversion to dir without permissions should fail
321 326
322 327 $ mkdir bogusdir
323 328 $ chmod 000 bogusdir
324 329
325 330 $ hg convert a bogusdir
326 331 abort: Permission denied: 'bogusdir'
327 332 [255]
328 333
329 334 user permissions should succeed
330 335
331 336 $ chmod 700 bogusdir
332 337 $ hg convert a bogusdir
333 338 initializing destination bogusdir repository
334 339 scanning source...
335 340 sorting...
336 341 converting...
337 342 4 a
338 343 3 b
339 344 2 c
340 345 1 d
341 346 0 e
342 347
343 348 #endif
344 349
345 350 test pre and post conversion actions
346 351
347 352 $ echo 'include b' > filemap
348 353 $ hg convert --debug --filemap filemap a partialb | \
349 354 > grep 'run hg'
350 355 run hg source pre-conversion action
351 356 run hg sink pre-conversion action
352 357 run hg sink post-conversion action
353 358 run hg source post-conversion action
354 359
355 360 converting empty dir should fail "nicely
356 361
357 362 $ mkdir emptydir
358 363
359 364 override $PATH to ensure p4 not visible; use $PYTHON in case we're
360 365 running from a devel copy, not a temp installation
361 366
362 367 $ PATH="$BINDIR" $PYTHON "$BINDIR"/hg convert emptydir
363 368 assuming destination emptydir-hg
364 369 initializing destination emptydir-hg repository
365 370 emptydir does not look like a CVS checkout
366 371 emptydir does not look like a Git repository
367 372 emptydir does not look like a Subversion repository
368 373 emptydir is not a local Mercurial repository
369 374 emptydir does not look like a darcs repository
370 375 emptydir does not look like a monotone repository
371 376 emptydir does not look like a GNU Arch repository
372 377 emptydir does not look like a Bazaar repository
373 378 cannot find required "p4" tool
374 379 abort: emptydir: missing or unsupported repository
375 380 [255]
376 381
377 382 convert with imaginary source type
378 383
379 384 $ hg convert --source-type foo a a-foo
380 385 initializing destination a-foo repository
381 386 abort: foo: invalid source repository type
382 387 [255]
383 388
384 389 convert with imaginary sink type
385 390
386 391 $ hg convert --dest-type foo a a-foo
387 392 abort: foo: invalid destination repository type
388 393 [255]
389 394
390 395 testing: convert must not produce duplicate entries in fncache
391 396
392 397 $ hg convert a b
393 398 initializing destination b repository
394 399 scanning source...
395 400 sorting...
396 401 converting...
397 402 4 a
398 403 3 b
399 404 2 c
400 405 1 d
401 406 0 e
402 407
403 408 contents of fncache file:
404 409
405 410 $ cat b/.hg/store/fncache | sort
406 411 data/a.i
407 412 data/b.i
408 413
409 414 test bogus URL
410 415
411 416 $ hg convert -q bzr+ssh://foobar@selenic.com/baz baz
412 417 abort: bzr+ssh://foobar@selenic.com/baz: missing or unsupported repository
413 418 [255]
414 419
415 420 test revset converted() lookup
416 421
417 422 $ hg --config convert.hg.saverev=True convert a c
418 423 initializing destination c repository
419 424 scanning source...
420 425 sorting...
421 426 converting...
422 427 4 a
423 428 3 b
424 429 2 c
425 430 1 d
426 431 0 e
427 432 $ echo f > c/f
428 433 $ hg -R c ci -d'0 0' -Amf
429 434 adding f
430 435 created new head
431 436 $ hg -R c log -r "converted(09d945a62ce6)"
432 437 changeset: 1:98c3dd46a874
433 438 user: test
434 439 date: Thu Jan 01 00:00:01 1970 +0000
435 440 summary: b
436 441
437 442 $ hg -R c log -r "converted()"
438 443 changeset: 0:31ed57b2037c
439 444 user: test
440 445 date: Thu Jan 01 00:00:00 1970 +0000
441 446 summary: a
442 447
443 448 changeset: 1:98c3dd46a874
444 449 user: test
445 450 date: Thu Jan 01 00:00:01 1970 +0000
446 451 summary: b
447 452
448 453 changeset: 2:3b9ca06ef716
449 454 user: test
450 455 date: Thu Jan 01 00:00:02 1970 +0000
451 456 summary: c
452 457
453 458 changeset: 3:4e0debd37cf2
454 459 user: test
455 460 date: Thu Jan 01 00:00:03 1970 +0000
456 461 summary: d
457 462
458 463 changeset: 4:9de3bc9349c5
459 464 user: test
460 465 date: Thu Jan 01 00:00:04 1970 +0000
461 466 summary: e
462 467
General Comments 0
You need to be logged in to leave comments. Login now