##// END OF EJS Templates
convert: fix description of 'convert --rev'
Mads Kiilerich -
r19864:1ce3f56b default
parent child Browse files
Show More
@@ -1,383 +1,383 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 Mercurial Source
145 145 ################
146 146
147 147 The Mercurial source recognizes the following configuration
148 148 options, which you can set on the command line with ``--config``:
149 149
150 150 :convert.hg.ignoreerrors: ignore integrity errors when reading.
151 151 Use it to fix Mercurial repositories with missing revlogs, by
152 152 converting from and to Mercurial. Default is False.
153 153
154 154 :convert.hg.saverev: store original revision ID in changeset
155 155 (forces target IDs to change). It takes a boolean argument and
156 156 defaults to False.
157 157
158 158 :convert.hg.startrev: convert start revision and its descendants.
159 159 It takes a hg revision identifier and defaults to 0.
160 160
161 161 CVS Source
162 162 ##########
163 163
164 164 CVS source will use a sandbox (i.e. a checked-out copy) from CVS
165 165 to indicate the starting point of what will be converted. Direct
166 166 access to the repository files is not needed, unless of course the
167 167 repository is ``:local:``. The conversion uses the top level
168 168 directory in the sandbox to find the CVS repository, and then uses
169 169 CVS rlog commands to find files to convert. This means that unless
170 170 a filemap is given, all files under the starting directory will be
171 171 converted, and that any directory reorganization in the CVS
172 172 sandbox is ignored.
173 173
174 174 The following options can be used with ``--config``:
175 175
176 176 :convert.cvsps.cache: Set to False to disable remote log caching,
177 177 for testing and debugging purposes. Default is True.
178 178
179 179 :convert.cvsps.fuzz: Specify the maximum time (in seconds) that is
180 180 allowed between commits with identical user and log message in
181 181 a single changeset. When very large files were checked in as
182 182 part of a changeset then the default may not be long enough.
183 183 The default is 60.
184 184
185 185 :convert.cvsps.mergeto: Specify a regular expression to which
186 186 commit log messages are matched. If a match occurs, then the
187 187 conversion process will insert a dummy revision merging the
188 188 branch on which this log message occurs to the branch
189 189 indicated in the regex. Default is ``{{mergetobranch
190 190 ([-\\w]+)}}``
191 191
192 192 :convert.cvsps.mergefrom: Specify a regular expression to which
193 193 commit log messages are matched. If a match occurs, then the
194 194 conversion process will add the most recent revision on the
195 195 branch indicated in the regex as the second parent of the
196 196 changeset. Default is ``{{mergefrombranch ([-\\w]+)}}``
197 197
198 198 :convert.localtimezone: use local time (as determined by the TZ
199 199 environment variable) for changeset date/times. The default
200 200 is False (use UTC).
201 201
202 202 :hooks.cvslog: Specify a Python function to be called at the end of
203 203 gathering the CVS log. The function is passed a list with the
204 204 log entries, and can modify the entries in-place, or add or
205 205 delete them.
206 206
207 207 :hooks.cvschangesets: Specify a Python function to be called after
208 208 the changesets are calculated from the CVS log. The
209 209 function is passed a list with the changeset entries, and can
210 210 modify the changesets in-place, or add or delete them.
211 211
212 212 An additional "debugcvsps" Mercurial command allows the builtin
213 213 changeset merging code to be run without doing a conversion. Its
214 214 parameters and output are similar to that of cvsps 2.1. Please see
215 215 the command help for more details.
216 216
217 217 Subversion Source
218 218 #################
219 219
220 220 Subversion source detects classical trunk/branches/tags layouts.
221 221 By default, the supplied ``svn://repo/path/`` source URL is
222 222 converted as a single branch. If ``svn://repo/path/trunk`` exists
223 223 it replaces the default branch. If ``svn://repo/path/branches``
224 224 exists, its subdirectories are listed as possible branches. If
225 225 ``svn://repo/path/tags`` exists, it is looked for tags referencing
226 226 converted branches. Default ``trunk``, ``branches`` and ``tags``
227 227 values can be overridden with following options. Set them to paths
228 228 relative to the source URL, or leave them blank to disable auto
229 229 detection.
230 230
231 231 The following options can be set with ``--config``:
232 232
233 233 :convert.svn.branches: specify the directory containing branches.
234 234 The default is ``branches``.
235 235
236 236 :convert.svn.tags: specify the directory containing tags. The
237 237 default is ``tags``.
238 238
239 239 :convert.svn.trunk: specify the name of the trunk branch. The
240 240 default is ``trunk``.
241 241
242 242 :convert.localtimezone: use local time (as determined by the TZ
243 243 environment variable) for changeset date/times. The default
244 244 is False (use UTC).
245 245
246 246 Source history can be retrieved starting at a specific revision,
247 247 instead of being integrally converted. Only single branch
248 248 conversions are supported.
249 249
250 250 :convert.svn.startrev: specify start Subversion revision number.
251 251 The default is 0.
252 252
253 253 Perforce Source
254 254 ###############
255 255
256 256 The Perforce (P4) importer can be given a p4 depot path or a
257 257 client specification as source. It will convert all files in the
258 258 source to a flat Mercurial repository, ignoring labels, branches
259 259 and integrations. Note that when a depot path is given you then
260 260 usually should specify a target directory, because otherwise the
261 261 target may be named ``...-hg``.
262 262
263 263 It is possible to limit the amount of source history to be
264 264 converted by specifying an initial Perforce revision:
265 265
266 266 :convert.p4.startrev: specify initial Perforce revision (a
267 267 Perforce changelist number).
268 268
269 269 Mercurial Destination
270 270 #####################
271 271
272 272 The following options are supported:
273 273
274 274 :convert.hg.clonebranches: dispatch source branches in separate
275 275 clones. The default is False.
276 276
277 277 :convert.hg.tagsbranch: branch name for tag revisions, defaults to
278 278 ``default``.
279 279
280 280 :convert.hg.usebranchnames: preserve branch names. The default is
281 281 True.
282 282 """
283 283 return convcmd.convert(ui, src, dest, revmapfile, **opts)
284 284
285 285 def debugsvnlog(ui, **opts):
286 286 return subversion.debugsvnlog(ui, **opts)
287 287
288 288 def debugcvsps(ui, *args, **opts):
289 289 '''create changeset information from CVS
290 290
291 291 This command is intended as a debugging tool for the CVS to
292 292 Mercurial converter, and can be used as a direct replacement for
293 293 cvsps.
294 294
295 295 Hg debugcvsps reads the CVS rlog for current directory (or any
296 296 named directory) in the CVS repository, and converts the log to a
297 297 series of changesets based on matching commit log entries and
298 298 dates.'''
299 299 return cvsps.debugcvsps(ui, *args, **opts)
300 300
301 301 commands.norepo += " convert debugsvnlog debugcvsps"
302 302
303 303 cmdtable = {
304 304 "convert":
305 305 (convert,
306 306 [('', 'authors', '',
307 307 _('username mapping filename (DEPRECATED, use --authormap instead)'),
308 308 _('FILE')),
309 309 ('s', 'source-type', '',
310 310 _('source repository type'), _('TYPE')),
311 311 ('d', 'dest-type', '',
312 312 _('destination repository type'), _('TYPE')),
313 313 ('r', 'rev', '',
314 _('import up to target revision REV'), _('REV')),
314 _('import up to source revision REV'), _('REV')),
315 315 ('A', 'authormap', '',
316 316 _('remap usernames using this file'), _('FILE')),
317 317 ('', 'filemap', '',
318 318 _('remap file names using contents of file'), _('FILE')),
319 319 ('', 'splicemap', '',
320 320 _('splice synthesized history into place'), _('FILE')),
321 321 ('', 'branchmap', '',
322 322 _('change branch names while converting'), _('FILE')),
323 323 ('', 'branchsort', None, _('try to sort changesets by branches')),
324 324 ('', 'datesort', None, _('try to sort changesets by date')),
325 325 ('', 'sourcesort', None, _('preserve source changesets order')),
326 326 ('', 'closesort', None, _('try to reorder closed revisions'))],
327 327 _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]')),
328 328 "debugsvnlog":
329 329 (debugsvnlog,
330 330 [],
331 331 'hg debugsvnlog'),
332 332 "debugcvsps":
333 333 (debugcvsps,
334 334 [
335 335 # Main options shared with cvsps-2.1
336 336 ('b', 'branches', [], _('only return changes on specified branches')),
337 337 ('p', 'prefix', '', _('prefix to remove from file names')),
338 338 ('r', 'revisions', [],
339 339 _('only return changes after or between specified tags')),
340 340 ('u', 'update-cache', None, _("update cvs log cache")),
341 341 ('x', 'new-cache', None, _("create new cvs log cache")),
342 342 ('z', 'fuzz', 60, _('set commit time fuzz in seconds')),
343 343 ('', 'root', '', _('specify cvsroot')),
344 344 # Options specific to builtin cvsps
345 345 ('', 'parents', '', _('show parent changesets')),
346 346 ('', 'ancestors', '',
347 347 _('show current changeset in ancestor branches')),
348 348 # Options that are ignored for compatibility with cvsps-2.1
349 349 ('A', 'cvs-direct', None, _('ignored for compatibility')),
350 350 ],
351 351 _('hg debugcvsps [OPTION]... [PATH]...')),
352 352 }
353 353
354 354 def kwconverted(ctx, name):
355 355 rev = ctx.extra().get('convert_revision', '')
356 356 if rev.startswith('svn:'):
357 357 if name == 'svnrev':
358 358 return str(subversion.revsplit(rev)[2])
359 359 elif name == 'svnpath':
360 360 return subversion.revsplit(rev)[1]
361 361 elif name == 'svnuuid':
362 362 return subversion.revsplit(rev)[0]
363 363 return rev
364 364
365 365 def kwsvnrev(repo, ctx, **args):
366 366 """:svnrev: String. Converted subversion revision number."""
367 367 return kwconverted(ctx, 'svnrev')
368 368
369 369 def kwsvnpath(repo, ctx, **args):
370 370 """:svnpath: String. Converted subversion revision project path."""
371 371 return kwconverted(ctx, 'svnpath')
372 372
373 373 def kwsvnuuid(repo, ctx, **args):
374 374 """:svnuuid: String. Converted subversion revision repository identifier."""
375 375 return kwconverted(ctx, 'svnuuid')
376 376
377 377 def extsetup(ui):
378 378 templatekw.keywords['svnrev'] = kwsvnrev
379 379 templatekw.keywords['svnpath'] = kwsvnpath
380 380 templatekw.keywords['svnuuid'] = kwsvnuuid
381 381
382 382 # tell hggettext to extract docstrings from these functions:
383 383 i18nfunctions = [kwsvnrev, kwsvnpath, kwsvnuuid]
@@ -1,458 +1,458 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 Mercurial Source
125 125 ################
126 126
127 127 The Mercurial source recognizes the following configuration options, which
128 128 you can set on the command line with "--config":
129 129
130 130 convert.hg.ignoreerrors
131 131 ignore integrity errors when reading. Use it to fix
132 132 Mercurial repositories with missing revlogs, by converting
133 133 from and to Mercurial. Default is False.
134 134 convert.hg.saverev
135 135 store original revision ID in changeset (forces target IDs
136 136 to change). It takes a boolean argument and defaults to
137 137 False.
138 138 convert.hg.startrev
139 139 convert start revision and its descendants. It takes a hg
140 140 revision identifier and defaults to 0.
141 141
142 142 CVS Source
143 143 ##########
144 144
145 145 CVS source will use a sandbox (i.e. a checked-out copy) from CVS to
146 146 indicate the starting point of what will be converted. Direct access to
147 147 the repository files is not needed, unless of course the repository is
148 148 ":local:". The conversion uses the top level directory in the sandbox to
149 149 find the CVS repository, and then uses CVS rlog commands to find files to
150 150 convert. This means that unless a filemap is given, all files under the
151 151 starting directory will be converted, and that any directory
152 152 reorganization in the CVS sandbox is ignored.
153 153
154 154 The following options can be used with "--config":
155 155
156 156 convert.cvsps.cache
157 157 Set to False to disable remote log caching, for testing and
158 158 debugging purposes. Default is True.
159 159 convert.cvsps.fuzz
160 160 Specify the maximum time (in seconds) that is allowed
161 161 between commits with identical user and log message in a
162 162 single changeset. When very large files were checked in as
163 163 part of a changeset then the default may not be long enough.
164 164 The default is 60.
165 165 convert.cvsps.mergeto
166 166 Specify a regular expression to which commit log messages
167 167 are matched. If a match occurs, then the conversion process
168 168 will insert a dummy revision merging the branch on which
169 169 this log message occurs to the branch indicated in the
170 170 regex. Default is "{{mergetobranch ([-\w]+)}}"
171 171 convert.cvsps.mergefrom
172 172 Specify a regular expression to which commit log messages
173 173 are matched. If a match occurs, then the conversion process
174 174 will add the most recent revision on the branch indicated in
175 175 the regex as the second parent of the changeset. Default is
176 176 "{{mergefrombranch ([-\w]+)}}"
177 177 convert.localtimezone
178 178 use local time (as determined by the TZ environment
179 179 variable) for changeset date/times. The default is False
180 180 (use UTC).
181 181 hooks.cvslog Specify a Python function to be called at the end of
182 182 gathering the CVS log. The function is passed a list with
183 183 the log entries, and can modify the entries in-place, or add
184 184 or delete them.
185 185 hooks.cvschangesets
186 186 Specify a Python function to be called after the changesets
187 187 are calculated from the CVS log. The function is passed a
188 188 list with the changeset entries, and can modify the
189 189 changesets in-place, or add or delete them.
190 190
191 191 An additional "debugcvsps" Mercurial command allows the builtin changeset
192 192 merging code to be run without doing a conversion. Its parameters and
193 193 output are similar to that of cvsps 2.1. Please see the command help for
194 194 more details.
195 195
196 196 Subversion Source
197 197 #################
198 198
199 199 Subversion source detects classical trunk/branches/tags layouts. By
200 200 default, the supplied "svn://repo/path/" source URL is converted as a
201 201 single branch. If "svn://repo/path/trunk" exists it replaces the default
202 202 branch. If "svn://repo/path/branches" exists, its subdirectories are
203 203 listed as possible branches. If "svn://repo/path/tags" exists, it is
204 204 looked for tags referencing converted branches. Default "trunk",
205 205 "branches" and "tags" values can be overridden with following options. Set
206 206 them to paths relative to the source URL, or leave them blank to disable
207 207 auto detection.
208 208
209 209 The following options can be set with "--config":
210 210
211 211 convert.svn.branches
212 212 specify the directory containing branches. The default is
213 213 "branches".
214 214 convert.svn.tags
215 215 specify the directory containing tags. The default is
216 216 "tags".
217 217 convert.svn.trunk
218 218 specify the name of the trunk branch. The default is
219 219 "trunk".
220 220 convert.localtimezone
221 221 use local time (as determined by the TZ environment
222 222 variable) for changeset date/times. The default is False
223 223 (use UTC).
224 224
225 225 Source history can be retrieved starting at a specific revision, instead
226 226 of being integrally converted. Only single branch conversions are
227 227 supported.
228 228
229 229 convert.svn.startrev
230 230 specify start Subversion revision number. The default is 0.
231 231
232 232 Perforce Source
233 233 ###############
234 234
235 235 The Perforce (P4) importer can be given a p4 depot path or a client
236 236 specification as source. It will convert all files in the source to a flat
237 237 Mercurial repository, ignoring labels, branches and integrations. Note
238 238 that when a depot path is given you then usually should specify a target
239 239 directory, because otherwise the target may be named "...-hg".
240 240
241 241 It is possible to limit the amount of source history to be converted by
242 242 specifying an initial Perforce revision:
243 243
244 244 convert.p4.startrev
245 245 specify initial Perforce revision (a Perforce changelist
246 246 number).
247 247
248 248 Mercurial Destination
249 249 #####################
250 250
251 251 The following options are supported:
252 252
253 253 convert.hg.clonebranches
254 254 dispatch source branches in separate clones. The default is
255 255 False.
256 256 convert.hg.tagsbranch
257 257 branch name for tag revisions, defaults to "default".
258 258 convert.hg.usebranchnames
259 259 preserve branch names. The default is True.
260 260
261 261 options:
262 262
263 263 -s --source-type TYPE source repository type
264 264 -d --dest-type TYPE destination repository type
265 -r --rev REV import up to target revision REV
265 -r --rev REV import up to source revision REV
266 266 -A --authormap FILE remap usernames using this file
267 267 --filemap FILE remap file names using contents of file
268 268 --splicemap FILE splice synthesized history into place
269 269 --branchmap FILE change branch names while converting
270 270 --branchsort try to sort changesets by branches
271 271 --datesort try to sort changesets by date
272 272 --sourcesort preserve source changesets order
273 273 --closesort try to reorder closed revisions
274 274
275 275 use "hg -v help convert" to show the global options
276 276 $ hg init a
277 277 $ cd a
278 278 $ echo a > a
279 279 $ hg ci -d'0 0' -Ama
280 280 adding a
281 281 $ hg cp a b
282 282 $ hg ci -d'1 0' -mb
283 283 $ hg rm a
284 284 $ hg ci -d'2 0' -mc
285 285 $ hg mv b a
286 286 $ hg ci -d'3 0' -md
287 287 $ echo a >> a
288 288 $ hg ci -d'4 0' -me
289 289 $ cd ..
290 290 $ hg convert a 2>&1 | grep -v 'subversion python bindings could not be loaded'
291 291 assuming destination a-hg
292 292 initializing destination a-hg repository
293 293 scanning source...
294 294 sorting...
295 295 converting...
296 296 4 a
297 297 3 b
298 298 2 c
299 299 1 d
300 300 0 e
301 301 $ hg --cwd a-hg pull ../a
302 302 pulling from ../a
303 303 searching for changes
304 304 no changes found
305 305
306 306 conversion to existing file should fail
307 307
308 308 $ touch bogusfile
309 309 $ hg convert a bogusfile
310 310 initializing destination bogusfile repository
311 311 abort: cannot create new bundle repository
312 312 [255]
313 313
314 314 #if unix-permissions
315 315
316 316 conversion to dir without permissions should fail
317 317
318 318 $ mkdir bogusdir
319 319 $ chmod 000 bogusdir
320 320
321 321 $ hg convert a bogusdir
322 322 abort: Permission denied: 'bogusdir'
323 323 [255]
324 324
325 325 user permissions should succeed
326 326
327 327 $ chmod 700 bogusdir
328 328 $ hg convert a bogusdir
329 329 initializing destination bogusdir repository
330 330 scanning source...
331 331 sorting...
332 332 converting...
333 333 4 a
334 334 3 b
335 335 2 c
336 336 1 d
337 337 0 e
338 338
339 339 #endif
340 340
341 341 test pre and post conversion actions
342 342
343 343 $ echo 'include b' > filemap
344 344 $ hg convert --debug --filemap filemap a partialb | \
345 345 > grep 'run hg'
346 346 run hg source pre-conversion action
347 347 run hg sink pre-conversion action
348 348 run hg sink post-conversion action
349 349 run hg source post-conversion action
350 350
351 351 converting empty dir should fail "nicely
352 352
353 353 $ mkdir emptydir
354 354
355 355 override $PATH to ensure p4 not visible; use $PYTHON in case we're
356 356 running from a devel copy, not a temp installation
357 357
358 358 $ PATH="$BINDIR" $PYTHON "$BINDIR"/hg convert emptydir
359 359 assuming destination emptydir-hg
360 360 initializing destination emptydir-hg repository
361 361 emptydir does not look like a CVS checkout
362 362 emptydir does not look like a Git repository
363 363 emptydir does not look like a Subversion repository
364 364 emptydir is not a local Mercurial repository
365 365 emptydir does not look like a darcs repository
366 366 emptydir does not look like a monotone repository
367 367 emptydir does not look like a GNU Arch repository
368 368 emptydir does not look like a Bazaar repository
369 369 cannot find required "p4" tool
370 370 abort: emptydir: missing or unsupported repository
371 371 [255]
372 372
373 373 convert with imaginary source type
374 374
375 375 $ hg convert --source-type foo a a-foo
376 376 initializing destination a-foo repository
377 377 abort: foo: invalid source repository type
378 378 [255]
379 379
380 380 convert with imaginary sink type
381 381
382 382 $ hg convert --dest-type foo a a-foo
383 383 abort: foo: invalid destination repository type
384 384 [255]
385 385
386 386 testing: convert must not produce duplicate entries in fncache
387 387
388 388 $ hg convert a b
389 389 initializing destination b repository
390 390 scanning source...
391 391 sorting...
392 392 converting...
393 393 4 a
394 394 3 b
395 395 2 c
396 396 1 d
397 397 0 e
398 398
399 399 contents of fncache file:
400 400
401 401 $ cat b/.hg/store/fncache | sort
402 402 data/a.i
403 403 data/b.i
404 404
405 405 test bogus URL
406 406
407 407 $ hg convert -q bzr+ssh://foobar@selenic.com/baz baz
408 408 abort: bzr+ssh://foobar@selenic.com/baz: missing or unsupported repository
409 409 [255]
410 410
411 411 test revset converted() lookup
412 412
413 413 $ hg --config convert.hg.saverev=True convert a c
414 414 initializing destination c repository
415 415 scanning source...
416 416 sorting...
417 417 converting...
418 418 4 a
419 419 3 b
420 420 2 c
421 421 1 d
422 422 0 e
423 423 $ echo f > c/f
424 424 $ hg -R c ci -d'0 0' -Amf
425 425 adding f
426 426 created new head
427 427 $ hg -R c log -r "converted(09d945a62ce6)"
428 428 changeset: 1:98c3dd46a874
429 429 user: test
430 430 date: Thu Jan 01 00:00:01 1970 +0000
431 431 summary: b
432 432
433 433 $ hg -R c log -r "converted()"
434 434 changeset: 0:31ed57b2037c
435 435 user: test
436 436 date: Thu Jan 01 00:00:00 1970 +0000
437 437 summary: a
438 438
439 439 changeset: 1:98c3dd46a874
440 440 user: test
441 441 date: Thu Jan 01 00:00:01 1970 +0000
442 442 summary: b
443 443
444 444 changeset: 2:3b9ca06ef716
445 445 user: test
446 446 date: Thu Jan 01 00:00:02 1970 +0000
447 447 summary: c
448 448
449 449 changeset: 3:4e0debd37cf2
450 450 user: test
451 451 date: Thu Jan 01 00:00:03 1970 +0000
452 452 summary: d
453 453
454 454 changeset: 4:9de3bc9349c5
455 455 user: test
456 456 date: Thu Jan 01 00:00:04 1970 +0000
457 457 summary: e
458 458
General Comments 0
You need to be logged in to leave comments. Login now