##// END OF EJS Templates
convert: __init__ use absolute_import
timeless -
r28414:4817c17a default
parent child Browse files
Show More
@@ -1,450 +1,458 b''
1 # convert.py Foreign SCM converter
1 # convert.py Foreign SCM converter
2 #
2 #
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 '''import revisions from foreign VCS repositories into Mercurial'''
8 '''import revisions from foreign VCS repositories into Mercurial'''
9
9
10 import convcmd
10 from __future__ import absolute_import
11 import cvsps
11
12 import subversion
12 from mercurial import (
13 from mercurial import cmdutil, templatekw
13 cmdutil,
14 templatekw,
15 )
14 from mercurial.i18n import _
16 from mercurial.i18n import _
15
17
18 from . import (
19 convcmd,
20 cvsps,
21 subversion,
22 )
23
16 cmdtable = {}
24 cmdtable = {}
17 command = cmdutil.command(cmdtable)
25 command = cmdutil.command(cmdtable)
18 # Note for extension authors: ONLY specify testedwith = 'internal' for
26 # Note for extension authors: ONLY specify testedwith = 'internal' for
19 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
27 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
20 # be specifying the version(s) of Mercurial they are tested with, or
28 # be specifying the version(s) of Mercurial they are tested with, or
21 # leave the attribute unspecified.
29 # leave the attribute unspecified.
22 testedwith = 'internal'
30 testedwith = 'internal'
23
31
24 # Commands definition was moved elsewhere to ease demandload job.
32 # Commands definition was moved elsewhere to ease demandload job.
25
33
26 @command('convert',
34 @command('convert',
27 [('', 'authors', '',
35 [('', 'authors', '',
28 _('username mapping filename (DEPRECATED) (use --authormap instead)'),
36 _('username mapping filename (DEPRECATED) (use --authormap instead)'),
29 _('FILE')),
37 _('FILE')),
30 ('s', 'source-type', '', _('source repository type'), _('TYPE')),
38 ('s', 'source-type', '', _('source repository type'), _('TYPE')),
31 ('d', 'dest-type', '', _('destination repository type'), _('TYPE')),
39 ('d', 'dest-type', '', _('destination repository type'), _('TYPE')),
32 ('r', 'rev', [], _('import up to source revision REV'), _('REV')),
40 ('r', 'rev', [], _('import up to source revision REV'), _('REV')),
33 ('A', 'authormap', '', _('remap usernames using this file'), _('FILE')),
41 ('A', 'authormap', '', _('remap usernames using this file'), _('FILE')),
34 ('', 'filemap', '', _('remap file names using contents of file'),
42 ('', 'filemap', '', _('remap file names using contents of file'),
35 _('FILE')),
43 _('FILE')),
36 ('', 'full', None,
44 ('', 'full', None,
37 _('apply filemap changes by converting all files again')),
45 _('apply filemap changes by converting all files again')),
38 ('', 'splicemap', '', _('splice synthesized history into place'),
46 ('', 'splicemap', '', _('splice synthesized history into place'),
39 _('FILE')),
47 _('FILE')),
40 ('', 'branchmap', '', _('change branch names while converting'),
48 ('', 'branchmap', '', _('change branch names while converting'),
41 _('FILE')),
49 _('FILE')),
42 ('', 'branchsort', None, _('try to sort changesets by branches')),
50 ('', 'branchsort', None, _('try to sort changesets by branches')),
43 ('', 'datesort', None, _('try to sort changesets by date')),
51 ('', 'datesort', None, _('try to sort changesets by date')),
44 ('', 'sourcesort', None, _('preserve source changesets order')),
52 ('', 'sourcesort', None, _('preserve source changesets order')),
45 ('', 'closesort', None, _('try to reorder closed revisions'))],
53 ('', 'closesort', None, _('try to reorder closed revisions'))],
46 _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]'),
54 _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]'),
47 norepo=True)
55 norepo=True)
48 def convert(ui, src, dest=None, revmapfile=None, **opts):
56 def convert(ui, src, dest=None, revmapfile=None, **opts):
49 """convert a foreign SCM repository to a Mercurial one.
57 """convert a foreign SCM repository to a Mercurial one.
50
58
51 Accepted source formats [identifiers]:
59 Accepted source formats [identifiers]:
52
60
53 - Mercurial [hg]
61 - Mercurial [hg]
54 - CVS [cvs]
62 - CVS [cvs]
55 - Darcs [darcs]
63 - Darcs [darcs]
56 - git [git]
64 - git [git]
57 - Subversion [svn]
65 - Subversion [svn]
58 - Monotone [mtn]
66 - Monotone [mtn]
59 - GNU Arch [gnuarch]
67 - GNU Arch [gnuarch]
60 - Bazaar [bzr]
68 - Bazaar [bzr]
61 - Perforce [p4]
69 - Perforce [p4]
62
70
63 Accepted destination formats [identifiers]:
71 Accepted destination formats [identifiers]:
64
72
65 - Mercurial [hg]
73 - Mercurial [hg]
66 - Subversion [svn] (history on branches is not preserved)
74 - Subversion [svn] (history on branches is not preserved)
67
75
68 If no revision is given, all revisions will be converted.
76 If no revision is given, all revisions will be converted.
69 Otherwise, convert will only import up to the named revision
77 Otherwise, convert will only import up to the named revision
70 (given in a format understood by the source).
78 (given in a format understood by the source).
71
79
72 If no destination directory name is specified, it defaults to the
80 If no destination directory name is specified, it defaults to the
73 basename of the source with ``-hg`` appended. If the destination
81 basename of the source with ``-hg`` appended. If the destination
74 repository doesn't exist, it will be created.
82 repository doesn't exist, it will be created.
75
83
76 By default, all sources except Mercurial will use --branchsort.
84 By default, all sources except Mercurial will use --branchsort.
77 Mercurial uses --sourcesort to preserve original revision numbers
85 Mercurial uses --sourcesort to preserve original revision numbers
78 order. Sort modes have the following effects:
86 order. Sort modes have the following effects:
79
87
80 --branchsort convert from parent to child revision when possible,
88 --branchsort convert from parent to child revision when possible,
81 which means branches are usually converted one after
89 which means branches are usually converted one after
82 the other. It generates more compact repositories.
90 the other. It generates more compact repositories.
83
91
84 --datesort sort revisions by date. Converted repositories have
92 --datesort sort revisions by date. Converted repositories have
85 good-looking changelogs but are often an order of
93 good-looking changelogs but are often an order of
86 magnitude larger than the same ones generated by
94 magnitude larger than the same ones generated by
87 --branchsort.
95 --branchsort.
88
96
89 --sourcesort try to preserve source revisions order, only
97 --sourcesort try to preserve source revisions order, only
90 supported by Mercurial sources.
98 supported by Mercurial sources.
91
99
92 --closesort try to move closed revisions as close as possible
100 --closesort try to move closed revisions as close as possible
93 to parent branches, only supported by Mercurial
101 to parent branches, only supported by Mercurial
94 sources.
102 sources.
95
103
96 If ``REVMAP`` isn't given, it will be put in a default location
104 If ``REVMAP`` isn't given, it will be put in a default location
97 (``<dest>/.hg/shamap`` by default). The ``REVMAP`` is a simple
105 (``<dest>/.hg/shamap`` by default). The ``REVMAP`` is a simple
98 text file that maps each source commit ID to the destination ID
106 text file that maps each source commit ID to the destination ID
99 for that revision, like so::
107 for that revision, like so::
100
108
101 <source ID> <destination ID>
109 <source ID> <destination ID>
102
110
103 If the file doesn't exist, it's automatically created. It's
111 If the file doesn't exist, it's automatically created. It's
104 updated on each commit copied, so :hg:`convert` can be interrupted
112 updated on each commit copied, so :hg:`convert` can be interrupted
105 and can be run repeatedly to copy new commits.
113 and can be run repeatedly to copy new commits.
106
114
107 The authormap is a simple text file that maps each source commit
115 The authormap is a simple text file that maps each source commit
108 author to a destination commit author. It is handy for source SCMs
116 author to a destination commit author. It is handy for source SCMs
109 that use unix logins to identify authors (e.g.: CVS). One line per
117 that use unix logins to identify authors (e.g.: CVS). One line per
110 author mapping and the line format is::
118 author mapping and the line format is::
111
119
112 source author = destination author
120 source author = destination author
113
121
114 Empty lines and lines starting with a ``#`` are ignored.
122 Empty lines and lines starting with a ``#`` are ignored.
115
123
116 The filemap is a file that allows filtering and remapping of files
124 The filemap is a file that allows filtering and remapping of files
117 and directories. Each line can contain one of the following
125 and directories. Each line can contain one of the following
118 directives::
126 directives::
119
127
120 include path/to/file-or-dir
128 include path/to/file-or-dir
121
129
122 exclude path/to/file-or-dir
130 exclude path/to/file-or-dir
123
131
124 rename path/to/source path/to/destination
132 rename path/to/source path/to/destination
125
133
126 Comment lines start with ``#``. A specified path matches if it
134 Comment lines start with ``#``. A specified path matches if it
127 equals the full relative name of a file or one of its parent
135 equals the full relative name of a file or one of its parent
128 directories. The ``include`` or ``exclude`` directive with the
136 directories. The ``include`` or ``exclude`` directive with the
129 longest matching path applies, so line order does not matter.
137 longest matching path applies, so line order does not matter.
130
138
131 The ``include`` directive causes a file, or all files under a
139 The ``include`` directive causes a file, or all files under a
132 directory, to be included in the destination repository. The default
140 directory, to be included in the destination repository. The default
133 if there are no ``include`` statements is to include everything.
141 if there are no ``include`` statements is to include everything.
134 If there are any ``include`` statements, nothing else is included.
142 If there are any ``include`` statements, nothing else is included.
135 The ``exclude`` directive causes files or directories to
143 The ``exclude`` directive causes files or directories to
136 be omitted. The ``rename`` directive renames a file or directory if
144 be omitted. The ``rename`` directive renames a file or directory if
137 it is converted. To rename from a subdirectory into the root of
145 it is converted. To rename from a subdirectory into the root of
138 the repository, use ``.`` as the path to rename to.
146 the repository, use ``.`` as the path to rename to.
139
147
140 ``--full`` will make sure the converted changesets contain exactly
148 ``--full`` will make sure the converted changesets contain exactly
141 the right files with the right content. It will make a full
149 the right files with the right content. It will make a full
142 conversion of all files, not just the ones that have
150 conversion of all files, not just the ones that have
143 changed. Files that already are correct will not be changed. This
151 changed. Files that already are correct will not be changed. This
144 can be used to apply filemap changes when converting
152 can be used to apply filemap changes when converting
145 incrementally. This is currently only supported for Mercurial and
153 incrementally. This is currently only supported for Mercurial and
146 Subversion.
154 Subversion.
147
155
148 The splicemap is a file that allows insertion of synthetic
156 The splicemap is a file that allows insertion of synthetic
149 history, letting you specify the parents of a revision. This is
157 history, letting you specify the parents of a revision. This is
150 useful if you want to e.g. give a Subversion merge two parents, or
158 useful if you want to e.g. give a Subversion merge two parents, or
151 graft two disconnected series of history together. Each entry
159 graft two disconnected series of history together. Each entry
152 contains a key, followed by a space, followed by one or two
160 contains a key, followed by a space, followed by one or two
153 comma-separated values::
161 comma-separated values::
154
162
155 key parent1, parent2
163 key parent1, parent2
156
164
157 The key is the revision ID in the source
165 The key is the revision ID in the source
158 revision control system whose parents should be modified (same
166 revision control system whose parents should be modified (same
159 format as a key in .hg/shamap). The values are the revision IDs
167 format as a key in .hg/shamap). The values are the revision IDs
160 (in either the source or destination revision control system) that
168 (in either the source or destination revision control system) that
161 should be used as the new parents for that node. For example, if
169 should be used as the new parents for that node. For example, if
162 you have merged "release-1.0" into "trunk", then you should
170 you have merged "release-1.0" into "trunk", then you should
163 specify the revision on "trunk" as the first parent and the one on
171 specify the revision on "trunk" as the first parent and the one on
164 the "release-1.0" branch as the second.
172 the "release-1.0" branch as the second.
165
173
166 The branchmap is a file that allows you to rename a branch when it is
174 The branchmap is a file that allows you to rename a branch when it is
167 being brought in from whatever external repository. When used in
175 being brought in from whatever external repository. When used in
168 conjunction with a splicemap, it allows for a powerful combination
176 conjunction with a splicemap, it allows for a powerful combination
169 to help fix even the most badly mismanaged repositories and turn them
177 to help fix even the most badly mismanaged repositories and turn them
170 into nicely structured Mercurial repositories. The branchmap contains
178 into nicely structured Mercurial repositories. The branchmap contains
171 lines of the form::
179 lines of the form::
172
180
173 original_branch_name new_branch_name
181 original_branch_name new_branch_name
174
182
175 where "original_branch_name" is the name of the branch in the
183 where "original_branch_name" is the name of the branch in the
176 source repository, and "new_branch_name" is the name of the branch
184 source repository, and "new_branch_name" is the name of the branch
177 is the destination repository. No whitespace is allowed in the
185 is the destination repository. No whitespace is allowed in the
178 branch names. This can be used to (for instance) move code in one
186 branch names. This can be used to (for instance) move code in one
179 repository from "default" to a named branch.
187 repository from "default" to a named branch.
180
188
181 Mercurial Source
189 Mercurial Source
182 ################
190 ################
183
191
184 The Mercurial source recognizes the following configuration
192 The Mercurial source recognizes the following configuration
185 options, which you can set on the command line with ``--config``:
193 options, which you can set on the command line with ``--config``:
186
194
187 :convert.hg.ignoreerrors: ignore integrity errors when reading.
195 :convert.hg.ignoreerrors: ignore integrity errors when reading.
188 Use it to fix Mercurial repositories with missing revlogs, by
196 Use it to fix Mercurial repositories with missing revlogs, by
189 converting from and to Mercurial. Default is False.
197 converting from and to Mercurial. Default is False.
190
198
191 :convert.hg.saverev: store original revision ID in changeset
199 :convert.hg.saverev: store original revision ID in changeset
192 (forces target IDs to change). It takes a boolean argument and
200 (forces target IDs to change). It takes a boolean argument and
193 defaults to False.
201 defaults to False.
194
202
195 :convert.hg.startrev: specify the initial Mercurial revision.
203 :convert.hg.startrev: specify the initial Mercurial revision.
196 The default is 0.
204 The default is 0.
197
205
198 :convert.hg.revs: revset specifying the source revisions to convert.
206 :convert.hg.revs: revset specifying the source revisions to convert.
199
207
200 CVS Source
208 CVS Source
201 ##########
209 ##########
202
210
203 CVS source will use a sandbox (i.e. a checked-out copy) from CVS
211 CVS source will use a sandbox (i.e. a checked-out copy) from CVS
204 to indicate the starting point of what will be converted. Direct
212 to indicate the starting point of what will be converted. Direct
205 access to the repository files is not needed, unless of course the
213 access to the repository files is not needed, unless of course the
206 repository is ``:local:``. The conversion uses the top level
214 repository is ``:local:``. The conversion uses the top level
207 directory in the sandbox to find the CVS repository, and then uses
215 directory in the sandbox to find the CVS repository, and then uses
208 CVS rlog commands to find files to convert. This means that unless
216 CVS rlog commands to find files to convert. This means that unless
209 a filemap is given, all files under the starting directory will be
217 a filemap is given, all files under the starting directory will be
210 converted, and that any directory reorganization in the CVS
218 converted, and that any directory reorganization in the CVS
211 sandbox is ignored.
219 sandbox is ignored.
212
220
213 The following options can be used with ``--config``:
221 The following options can be used with ``--config``:
214
222
215 :convert.cvsps.cache: Set to False to disable remote log caching,
223 :convert.cvsps.cache: Set to False to disable remote log caching,
216 for testing and debugging purposes. Default is True.
224 for testing and debugging purposes. Default is True.
217
225
218 :convert.cvsps.fuzz: Specify the maximum time (in seconds) that is
226 :convert.cvsps.fuzz: Specify the maximum time (in seconds) that is
219 allowed between commits with identical user and log message in
227 allowed between commits with identical user and log message in
220 a single changeset. When very large files were checked in as
228 a single changeset. When very large files were checked in as
221 part of a changeset then the default may not be long enough.
229 part of a changeset then the default may not be long enough.
222 The default is 60.
230 The default is 60.
223
231
224 :convert.cvsps.mergeto: Specify a regular expression to which
232 :convert.cvsps.mergeto: Specify a regular expression to which
225 commit log messages are matched. If a match occurs, then the
233 commit log messages are matched. If a match occurs, then the
226 conversion process will insert a dummy revision merging the
234 conversion process will insert a dummy revision merging the
227 branch on which this log message occurs to the branch
235 branch on which this log message occurs to the branch
228 indicated in the regex. Default is ``{{mergetobranch
236 indicated in the regex. Default is ``{{mergetobranch
229 ([-\\w]+)}}``
237 ([-\\w]+)}}``
230
238
231 :convert.cvsps.mergefrom: Specify a regular expression to which
239 :convert.cvsps.mergefrom: Specify a regular expression to which
232 commit log messages are matched. If a match occurs, then the
240 commit log messages are matched. If a match occurs, then the
233 conversion process will add the most recent revision on the
241 conversion process will add the most recent revision on the
234 branch indicated in the regex as the second parent of the
242 branch indicated in the regex as the second parent of the
235 changeset. Default is ``{{mergefrombranch ([-\\w]+)}}``
243 changeset. Default is ``{{mergefrombranch ([-\\w]+)}}``
236
244
237 :convert.localtimezone: use local time (as determined by the TZ
245 :convert.localtimezone: use local time (as determined by the TZ
238 environment variable) for changeset date/times. The default
246 environment variable) for changeset date/times. The default
239 is False (use UTC).
247 is False (use UTC).
240
248
241 :hooks.cvslog: Specify a Python function to be called at the end of
249 :hooks.cvslog: Specify a Python function to be called at the end of
242 gathering the CVS log. The function is passed a list with the
250 gathering the CVS log. The function is passed a list with the
243 log entries, and can modify the entries in-place, or add or
251 log entries, and can modify the entries in-place, or add or
244 delete them.
252 delete them.
245
253
246 :hooks.cvschangesets: Specify a Python function to be called after
254 :hooks.cvschangesets: Specify a Python function to be called after
247 the changesets are calculated from the CVS log. The
255 the changesets are calculated from the CVS log. The
248 function is passed a list with the changeset entries, and can
256 function is passed a list with the changeset entries, and can
249 modify the changesets in-place, or add or delete them.
257 modify the changesets in-place, or add or delete them.
250
258
251 An additional "debugcvsps" Mercurial command allows the builtin
259 An additional "debugcvsps" Mercurial command allows the builtin
252 changeset merging code to be run without doing a conversion. Its
260 changeset merging code to be run without doing a conversion. Its
253 parameters and output are similar to that of cvsps 2.1. Please see
261 parameters and output are similar to that of cvsps 2.1. Please see
254 the command help for more details.
262 the command help for more details.
255
263
256 Subversion Source
264 Subversion Source
257 #################
265 #################
258
266
259 Subversion source detects classical trunk/branches/tags layouts.
267 Subversion source detects classical trunk/branches/tags layouts.
260 By default, the supplied ``svn://repo/path/`` source URL is
268 By default, the supplied ``svn://repo/path/`` source URL is
261 converted as a single branch. If ``svn://repo/path/trunk`` exists
269 converted as a single branch. If ``svn://repo/path/trunk`` exists
262 it replaces the default branch. If ``svn://repo/path/branches``
270 it replaces the default branch. If ``svn://repo/path/branches``
263 exists, its subdirectories are listed as possible branches. If
271 exists, its subdirectories are listed as possible branches. If
264 ``svn://repo/path/tags`` exists, it is looked for tags referencing
272 ``svn://repo/path/tags`` exists, it is looked for tags referencing
265 converted branches. Default ``trunk``, ``branches`` and ``tags``
273 converted branches. Default ``trunk``, ``branches`` and ``tags``
266 values can be overridden with following options. Set them to paths
274 values can be overridden with following options. Set them to paths
267 relative to the source URL, or leave them blank to disable auto
275 relative to the source URL, or leave them blank to disable auto
268 detection.
276 detection.
269
277
270 The following options can be set with ``--config``:
278 The following options can be set with ``--config``:
271
279
272 :convert.svn.branches: specify the directory containing branches.
280 :convert.svn.branches: specify the directory containing branches.
273 The default is ``branches``.
281 The default is ``branches``.
274
282
275 :convert.svn.tags: specify the directory containing tags. The
283 :convert.svn.tags: specify the directory containing tags. The
276 default is ``tags``.
284 default is ``tags``.
277
285
278 :convert.svn.trunk: specify the name of the trunk branch. The
286 :convert.svn.trunk: specify the name of the trunk branch. The
279 default is ``trunk``.
287 default is ``trunk``.
280
288
281 :convert.localtimezone: use local time (as determined by the TZ
289 :convert.localtimezone: use local time (as determined by the TZ
282 environment variable) for changeset date/times. The default
290 environment variable) for changeset date/times. The default
283 is False (use UTC).
291 is False (use UTC).
284
292
285 Source history can be retrieved starting at a specific revision,
293 Source history can be retrieved starting at a specific revision,
286 instead of being integrally converted. Only single branch
294 instead of being integrally converted. Only single branch
287 conversions are supported.
295 conversions are supported.
288
296
289 :convert.svn.startrev: specify start Subversion revision number.
297 :convert.svn.startrev: specify start Subversion revision number.
290 The default is 0.
298 The default is 0.
291
299
292 Git Source
300 Git Source
293 ##########
301 ##########
294
302
295 The Git importer converts commits from all reachable branches (refs
303 The Git importer converts commits from all reachable branches (refs
296 in refs/heads) and remotes (refs in refs/remotes) to Mercurial.
304 in refs/heads) and remotes (refs in refs/remotes) to Mercurial.
297 Branches are converted to bookmarks with the same name, with the
305 Branches are converted to bookmarks with the same name, with the
298 leading 'refs/heads' stripped. Git submodules are converted to Git
306 leading 'refs/heads' stripped. Git submodules are converted to Git
299 subrepos in Mercurial.
307 subrepos in Mercurial.
300
308
301 The following options can be set with ``--config``:
309 The following options can be set with ``--config``:
302
310
303 :convert.git.similarity: specify how similar files modified in a
311 :convert.git.similarity: specify how similar files modified in a
304 commit must be to be imported as renames or copies, as a
312 commit must be to be imported as renames or copies, as a
305 percentage between ``0`` (disabled) and ``100`` (files must be
313 percentage between ``0`` (disabled) and ``100`` (files must be
306 identical). For example, ``90`` means that a delete/add pair will
314 identical). For example, ``90`` means that a delete/add pair will
307 be imported as a rename if more than 90% of the file hasn't
315 be imported as a rename if more than 90% of the file hasn't
308 changed. The default is ``50``.
316 changed. The default is ``50``.
309
317
310 :convert.git.findcopiesharder: while detecting copies, look at all
318 :convert.git.findcopiesharder: while detecting copies, look at all
311 files in the working copy instead of just changed ones. This
319 files in the working copy instead of just changed ones. This
312 is very expensive for large projects, and is only effective when
320 is very expensive for large projects, and is only effective when
313 ``convert.git.similarity`` is greater than 0. The default is False.
321 ``convert.git.similarity`` is greater than 0. The default is False.
314
322
315 :convert.git.remoteprefix: remote refs are converted as bookmarks with
323 :convert.git.remoteprefix: remote refs are converted as bookmarks with
316 ``convert.git.remoteprefix`` as a prefix followed by a /. The default
324 ``convert.git.remoteprefix`` as a prefix followed by a /. The default
317 is 'remote'.
325 is 'remote'.
318
326
319 :convert.git.skipsubmodules: does not convert root level .gitmodules files
327 :convert.git.skipsubmodules: does not convert root level .gitmodules files
320 or files with 160000 mode indicating a submodule. Default is False.
328 or files with 160000 mode indicating a submodule. Default is False.
321
329
322 Perforce Source
330 Perforce Source
323 ###############
331 ###############
324
332
325 The Perforce (P4) importer can be given a p4 depot path or a
333 The Perforce (P4) importer can be given a p4 depot path or a
326 client specification as source. It will convert all files in the
334 client specification as source. It will convert all files in the
327 source to a flat Mercurial repository, ignoring labels, branches
335 source to a flat Mercurial repository, ignoring labels, branches
328 and integrations. Note that when a depot path is given you then
336 and integrations. Note that when a depot path is given you then
329 usually should specify a target directory, because otherwise the
337 usually should specify a target directory, because otherwise the
330 target may be named ``...-hg``.
338 target may be named ``...-hg``.
331
339
332 The following options can be set with ``--config``:
340 The following options can be set with ``--config``:
333
341
334 :convert.p4.encoding: specify the encoding to use when decoding standard
342 :convert.p4.encoding: specify the encoding to use when decoding standard
335 output of the Perforce command line tool. The default is default system
343 output of the Perforce command line tool. The default is default system
336 encoding.
344 encoding.
337
345
338 :convert.p4.startrev: specify initial Perforce revision (a
346 :convert.p4.startrev: specify initial Perforce revision (a
339 Perforce changelist number).
347 Perforce changelist number).
340
348
341 Mercurial Destination
349 Mercurial Destination
342 #####################
350 #####################
343
351
344 The Mercurial destination will recognize Mercurial subrepositories in the
352 The Mercurial destination will recognize Mercurial subrepositories in the
345 destination directory, and update the .hgsubstate file automatically if the
353 destination directory, and update the .hgsubstate file automatically if the
346 destination subrepositories contain the <dest>/<sub>/.hg/shamap file.
354 destination subrepositories contain the <dest>/<sub>/.hg/shamap file.
347 Converting a repository with subrepositories requires converting a single
355 Converting a repository with subrepositories requires converting a single
348 repository at a time, from the bottom up.
356 repository at a time, from the bottom up.
349
357
350 .. container:: verbose
358 .. container:: verbose
351
359
352 An example showing how to convert a repository with subrepositories::
360 An example showing how to convert a repository with subrepositories::
353
361
354 # so convert knows the type when it sees a non empty destination
362 # so convert knows the type when it sees a non empty destination
355 $ hg init converted
363 $ hg init converted
356
364
357 $ hg convert orig/sub1 converted/sub1
365 $ hg convert orig/sub1 converted/sub1
358 $ hg convert orig/sub2 converted/sub2
366 $ hg convert orig/sub2 converted/sub2
359 $ hg convert orig converted
367 $ hg convert orig converted
360
368
361 The following options are supported:
369 The following options are supported:
362
370
363 :convert.hg.clonebranches: dispatch source branches in separate
371 :convert.hg.clonebranches: dispatch source branches in separate
364 clones. The default is False.
372 clones. The default is False.
365
373
366 :convert.hg.tagsbranch: branch name for tag revisions, defaults to
374 :convert.hg.tagsbranch: branch name for tag revisions, defaults to
367 ``default``.
375 ``default``.
368
376
369 :convert.hg.usebranchnames: preserve branch names. The default is
377 :convert.hg.usebranchnames: preserve branch names. The default is
370 True.
378 True.
371
379
372 :convert.hg.sourcename: records the given string as a 'convert_source' extra
380 :convert.hg.sourcename: records the given string as a 'convert_source' extra
373 value on each commit made in the target repository. The default is None.
381 value on each commit made in the target repository. The default is None.
374
382
375 All Destinations
383 All Destinations
376 ################
384 ################
377
385
378 All destination types accept the following options:
386 All destination types accept the following options:
379
387
380 :convert.skiptags: does not convert tags from the source repo to the target
388 :convert.skiptags: does not convert tags from the source repo to the target
381 repo. The default is False.
389 repo. The default is False.
382 """
390 """
383 return convcmd.convert(ui, src, dest, revmapfile, **opts)
391 return convcmd.convert(ui, src, dest, revmapfile, **opts)
384
392
385 @command('debugsvnlog', [], 'hg debugsvnlog', norepo=True)
393 @command('debugsvnlog', [], 'hg debugsvnlog', norepo=True)
386 def debugsvnlog(ui, **opts):
394 def debugsvnlog(ui, **opts):
387 return subversion.debugsvnlog(ui, **opts)
395 return subversion.debugsvnlog(ui, **opts)
388
396
389 @command('debugcvsps',
397 @command('debugcvsps',
390 [
398 [
391 # Main options shared with cvsps-2.1
399 # Main options shared with cvsps-2.1
392 ('b', 'branches', [], _('only return changes on specified branches')),
400 ('b', 'branches', [], _('only return changes on specified branches')),
393 ('p', 'prefix', '', _('prefix to remove from file names')),
401 ('p', 'prefix', '', _('prefix to remove from file names')),
394 ('r', 'revisions', [],
402 ('r', 'revisions', [],
395 _('only return changes after or between specified tags')),
403 _('only return changes after or between specified tags')),
396 ('u', 'update-cache', None, _("update cvs log cache")),
404 ('u', 'update-cache', None, _("update cvs log cache")),
397 ('x', 'new-cache', None, _("create new cvs log cache")),
405 ('x', 'new-cache', None, _("create new cvs log cache")),
398 ('z', 'fuzz', 60, _('set commit time fuzz in seconds')),
406 ('z', 'fuzz', 60, _('set commit time fuzz in seconds')),
399 ('', 'root', '', _('specify cvsroot')),
407 ('', 'root', '', _('specify cvsroot')),
400 # Options specific to builtin cvsps
408 # Options specific to builtin cvsps
401 ('', 'parents', '', _('show parent changesets')),
409 ('', 'parents', '', _('show parent changesets')),
402 ('', 'ancestors', '', _('show current changeset in ancestor branches')),
410 ('', 'ancestors', '', _('show current changeset in ancestor branches')),
403 # Options that are ignored for compatibility with cvsps-2.1
411 # Options that are ignored for compatibility with cvsps-2.1
404 ('A', 'cvs-direct', None, _('ignored for compatibility')),
412 ('A', 'cvs-direct', None, _('ignored for compatibility')),
405 ],
413 ],
406 _('hg debugcvsps [OPTION]... [PATH]...'),
414 _('hg debugcvsps [OPTION]... [PATH]...'),
407 norepo=True)
415 norepo=True)
408 def debugcvsps(ui, *args, **opts):
416 def debugcvsps(ui, *args, **opts):
409 '''create changeset information from CVS
417 '''create changeset information from CVS
410
418
411 This command is intended as a debugging tool for the CVS to
419 This command is intended as a debugging tool for the CVS to
412 Mercurial converter, and can be used as a direct replacement for
420 Mercurial converter, and can be used as a direct replacement for
413 cvsps.
421 cvsps.
414
422
415 Hg debugcvsps reads the CVS rlog for current directory (or any
423 Hg debugcvsps reads the CVS rlog for current directory (or any
416 named directory) in the CVS repository, and converts the log to a
424 named directory) in the CVS repository, and converts the log to a
417 series of changesets based on matching commit log entries and
425 series of changesets based on matching commit log entries and
418 dates.'''
426 dates.'''
419 return cvsps.debugcvsps(ui, *args, **opts)
427 return cvsps.debugcvsps(ui, *args, **opts)
420
428
421 def kwconverted(ctx, name):
429 def kwconverted(ctx, name):
422 rev = ctx.extra().get('convert_revision', '')
430 rev = ctx.extra().get('convert_revision', '')
423 if rev.startswith('svn:'):
431 if rev.startswith('svn:'):
424 if name == 'svnrev':
432 if name == 'svnrev':
425 return str(subversion.revsplit(rev)[2])
433 return str(subversion.revsplit(rev)[2])
426 elif name == 'svnpath':
434 elif name == 'svnpath':
427 return subversion.revsplit(rev)[1]
435 return subversion.revsplit(rev)[1]
428 elif name == 'svnuuid':
436 elif name == 'svnuuid':
429 return subversion.revsplit(rev)[0]
437 return subversion.revsplit(rev)[0]
430 return rev
438 return rev
431
439
432 def kwsvnrev(repo, ctx, **args):
440 def kwsvnrev(repo, ctx, **args):
433 """:svnrev: String. Converted subversion revision number."""
441 """:svnrev: String. Converted subversion revision number."""
434 return kwconverted(ctx, 'svnrev')
442 return kwconverted(ctx, 'svnrev')
435
443
436 def kwsvnpath(repo, ctx, **args):
444 def kwsvnpath(repo, ctx, **args):
437 """:svnpath: String. Converted subversion revision project path."""
445 """:svnpath: String. Converted subversion revision project path."""
438 return kwconverted(ctx, 'svnpath')
446 return kwconverted(ctx, 'svnpath')
439
447
440 def kwsvnuuid(repo, ctx, **args):
448 def kwsvnuuid(repo, ctx, **args):
441 """:svnuuid: String. Converted subversion revision repository identifier."""
449 """:svnuuid: String. Converted subversion revision repository identifier."""
442 return kwconverted(ctx, 'svnuuid')
450 return kwconverted(ctx, 'svnuuid')
443
451
444 def extsetup(ui):
452 def extsetup(ui):
445 templatekw.keywords['svnrev'] = kwsvnrev
453 templatekw.keywords['svnrev'] = kwsvnrev
446 templatekw.keywords['svnpath'] = kwsvnpath
454 templatekw.keywords['svnpath'] = kwsvnpath
447 templatekw.keywords['svnuuid'] = kwsvnuuid
455 templatekw.keywords['svnuuid'] = kwsvnuuid
448
456
449 # tell hggettext to extract docstrings from these functions:
457 # tell hggettext to extract docstrings from these functions:
450 i18nfunctions = [kwsvnrev, kwsvnpath, kwsvnuuid]
458 i18nfunctions = [kwsvnrev, kwsvnpath, kwsvnuuid]
@@ -1,133 +1,132 b''
1 #require test-repo
1 #require test-repo
2
2
3 $ cd "$TESTDIR"/..
3 $ cd "$TESTDIR"/..
4
4
5 $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py
5 $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py
6 contrib/check-code.py not using absolute_import
6 contrib/check-code.py not using absolute_import
7 contrib/check-code.py requires print_function
7 contrib/check-code.py requires print_function
8 contrib/debugshell.py not using absolute_import
8 contrib/debugshell.py not using absolute_import
9 contrib/import-checker.py not using absolute_import
9 contrib/import-checker.py not using absolute_import
10 contrib/import-checker.py requires print_function
10 contrib/import-checker.py requires print_function
11 contrib/memory.py not using absolute_import
11 contrib/memory.py not using absolute_import
12 contrib/perf.py not using absolute_import
12 contrib/perf.py not using absolute_import
13 contrib/python-hook-examples.py not using absolute_import
13 contrib/python-hook-examples.py not using absolute_import
14 contrib/revsetbenchmarks.py not using absolute_import
14 contrib/revsetbenchmarks.py not using absolute_import
15 contrib/revsetbenchmarks.py requires print_function
15 contrib/revsetbenchmarks.py requires print_function
16 contrib/showstack.py not using absolute_import
16 contrib/showstack.py not using absolute_import
17 contrib/synthrepo.py not using absolute_import
17 contrib/synthrepo.py not using absolute_import
18 contrib/win32/hgwebdir_wsgi.py not using absolute_import
18 contrib/win32/hgwebdir_wsgi.py not using absolute_import
19 doc/check-seclevel.py not using absolute_import
19 doc/check-seclevel.py not using absolute_import
20 doc/gendoc.py not using absolute_import
20 doc/gendoc.py not using absolute_import
21 doc/hgmanpage.py not using absolute_import
21 doc/hgmanpage.py not using absolute_import
22 hgext/__init__.py not using absolute_import
22 hgext/__init__.py not using absolute_import
23 hgext/color.py not using absolute_import
23 hgext/color.py not using absolute_import
24 hgext/convert/__init__.py not using absolute_import
25 hgext/eol.py not using absolute_import
24 hgext/eol.py not using absolute_import
26 hgext/extdiff.py not using absolute_import
25 hgext/extdiff.py not using absolute_import
27 hgext/factotum.py not using absolute_import
26 hgext/factotum.py not using absolute_import
28 hgext/fetch.py not using absolute_import
27 hgext/fetch.py not using absolute_import
29 hgext/gpg.py not using absolute_import
28 hgext/gpg.py not using absolute_import
30 hgext/graphlog.py not using absolute_import
29 hgext/graphlog.py not using absolute_import
31 hgext/hgcia.py not using absolute_import
30 hgext/hgcia.py not using absolute_import
32 hgext/hgk.py not using absolute_import
31 hgext/hgk.py not using absolute_import
33 hgext/highlight/__init__.py not using absolute_import
32 hgext/highlight/__init__.py not using absolute_import
34 hgext/highlight/highlight.py not using absolute_import
33 hgext/highlight/highlight.py not using absolute_import
35 hgext/histedit.py not using absolute_import
34 hgext/histedit.py not using absolute_import
36 hgext/largefiles/__init__.py not using absolute_import
35 hgext/largefiles/__init__.py not using absolute_import
37 hgext/largefiles/basestore.py not using absolute_import
36 hgext/largefiles/basestore.py not using absolute_import
38 hgext/largefiles/lfcommands.py not using absolute_import
37 hgext/largefiles/lfcommands.py not using absolute_import
39 hgext/largefiles/lfutil.py not using absolute_import
38 hgext/largefiles/lfutil.py not using absolute_import
40 hgext/largefiles/localstore.py not using absolute_import
39 hgext/largefiles/localstore.py not using absolute_import
41 hgext/largefiles/overrides.py not using absolute_import
40 hgext/largefiles/overrides.py not using absolute_import
42 hgext/largefiles/proto.py not using absolute_import
41 hgext/largefiles/proto.py not using absolute_import
43 hgext/largefiles/remotestore.py not using absolute_import
42 hgext/largefiles/remotestore.py not using absolute_import
44 hgext/largefiles/reposetup.py not using absolute_import
43 hgext/largefiles/reposetup.py not using absolute_import
45 hgext/largefiles/uisetup.py not using absolute_import
44 hgext/largefiles/uisetup.py not using absolute_import
46 hgext/largefiles/wirestore.py not using absolute_import
45 hgext/largefiles/wirestore.py not using absolute_import
47 hgext/mq.py not using absolute_import
46 hgext/mq.py not using absolute_import
48 hgext/notify.py not using absolute_import
47 hgext/notify.py not using absolute_import
49 hgext/patchbomb.py not using absolute_import
48 hgext/patchbomb.py not using absolute_import
50 hgext/rebase.py not using absolute_import
49 hgext/rebase.py not using absolute_import
51 hgext/share.py not using absolute_import
50 hgext/share.py not using absolute_import
52 hgext/transplant.py not using absolute_import
51 hgext/transplant.py not using absolute_import
53 hgext/win32mbcs.py not using absolute_import
52 hgext/win32mbcs.py not using absolute_import
54 hgext/win32text.py not using absolute_import
53 hgext/win32text.py not using absolute_import
55 i18n/check-translation.py not using absolute_import
54 i18n/check-translation.py not using absolute_import
56 i18n/polib.py not using absolute_import
55 i18n/polib.py not using absolute_import
57 setup.py not using absolute_import
56 setup.py not using absolute_import
58 tests/filterpyflakes.py requires print_function
57 tests/filterpyflakes.py requires print_function
59 tests/generate-working-copy-states.py requires print_function
58 tests/generate-working-copy-states.py requires print_function
60 tests/get-with-headers.py requires print_function
59 tests/get-with-headers.py requires print_function
61 tests/heredoctest.py requires print_function
60 tests/heredoctest.py requires print_function
62 tests/hypothesishelpers.py not using absolute_import
61 tests/hypothesishelpers.py not using absolute_import
63 tests/hypothesishelpers.py requires print_function
62 tests/hypothesishelpers.py requires print_function
64 tests/killdaemons.py not using absolute_import
63 tests/killdaemons.py not using absolute_import
65 tests/md5sum.py not using absolute_import
64 tests/md5sum.py not using absolute_import
66 tests/mockblackbox.py not using absolute_import
65 tests/mockblackbox.py not using absolute_import
67 tests/printenv.py not using absolute_import
66 tests/printenv.py not using absolute_import
68 tests/readlink.py not using absolute_import
67 tests/readlink.py not using absolute_import
69 tests/readlink.py requires print_function
68 tests/readlink.py requires print_function
70 tests/revlog-formatv0.py not using absolute_import
69 tests/revlog-formatv0.py not using absolute_import
71 tests/run-tests.py not using absolute_import
70 tests/run-tests.py not using absolute_import
72 tests/seq.py not using absolute_import
71 tests/seq.py not using absolute_import
73 tests/seq.py requires print_function
72 tests/seq.py requires print_function
74 tests/silenttestrunner.py not using absolute_import
73 tests/silenttestrunner.py not using absolute_import
75 tests/silenttestrunner.py requires print_function
74 tests/silenttestrunner.py requires print_function
76 tests/sitecustomize.py not using absolute_import
75 tests/sitecustomize.py not using absolute_import
77 tests/svn-safe-append.py not using absolute_import
76 tests/svn-safe-append.py not using absolute_import
78 tests/svnxml.py not using absolute_import
77 tests/svnxml.py not using absolute_import
79 tests/test-ancestor.py requires print_function
78 tests/test-ancestor.py requires print_function
80 tests/test-atomictempfile.py not using absolute_import
79 tests/test-atomictempfile.py not using absolute_import
81 tests/test-batching.py not using absolute_import
80 tests/test-batching.py not using absolute_import
82 tests/test-batching.py requires print_function
81 tests/test-batching.py requires print_function
83 tests/test-bdiff.py not using absolute_import
82 tests/test-bdiff.py not using absolute_import
84 tests/test-bdiff.py requires print_function
83 tests/test-bdiff.py requires print_function
85 tests/test-context.py not using absolute_import
84 tests/test-context.py not using absolute_import
86 tests/test-context.py requires print_function
85 tests/test-context.py requires print_function
87 tests/test-demandimport.py not using absolute_import
86 tests/test-demandimport.py not using absolute_import
88 tests/test-demandimport.py requires print_function
87 tests/test-demandimport.py requires print_function
89 tests/test-doctest.py not using absolute_import
88 tests/test-doctest.py not using absolute_import
90 tests/test-duplicateoptions.py not using absolute_import
89 tests/test-duplicateoptions.py not using absolute_import
91 tests/test-duplicateoptions.py requires print_function
90 tests/test-duplicateoptions.py requires print_function
92 tests/test-filecache.py not using absolute_import
91 tests/test-filecache.py not using absolute_import
93 tests/test-filecache.py requires print_function
92 tests/test-filecache.py requires print_function
94 tests/test-filelog.py not using absolute_import
93 tests/test-filelog.py not using absolute_import
95 tests/test-filelog.py requires print_function
94 tests/test-filelog.py requires print_function
96 tests/test-hg-parseurl.py not using absolute_import
95 tests/test-hg-parseurl.py not using absolute_import
97 tests/test-hg-parseurl.py requires print_function
96 tests/test-hg-parseurl.py requires print_function
98 tests/test-hgweb-auth.py not using absolute_import
97 tests/test-hgweb-auth.py not using absolute_import
99 tests/test-hgweb-auth.py requires print_function
98 tests/test-hgweb-auth.py requires print_function
100 tests/test-hgwebdir-paths.py not using absolute_import
99 tests/test-hgwebdir-paths.py not using absolute_import
101 tests/test-hybridencode.py not using absolute_import
100 tests/test-hybridencode.py not using absolute_import
102 tests/test-hybridencode.py requires print_function
101 tests/test-hybridencode.py requires print_function
103 tests/test-lrucachedict.py not using absolute_import
102 tests/test-lrucachedict.py not using absolute_import
104 tests/test-lrucachedict.py requires print_function
103 tests/test-lrucachedict.py requires print_function
105 tests/test-manifest.py not using absolute_import
104 tests/test-manifest.py not using absolute_import
106 tests/test-minirst.py not using absolute_import
105 tests/test-minirst.py not using absolute_import
107 tests/test-minirst.py requires print_function
106 tests/test-minirst.py requires print_function
108 tests/test-parseindex2.py not using absolute_import
107 tests/test-parseindex2.py not using absolute_import
109 tests/test-parseindex2.py requires print_function
108 tests/test-parseindex2.py requires print_function
110 tests/test-pathencode.py not using absolute_import
109 tests/test-pathencode.py not using absolute_import
111 tests/test-pathencode.py requires print_function
110 tests/test-pathencode.py requires print_function
112 tests/test-propertycache.py not using absolute_import
111 tests/test-propertycache.py not using absolute_import
113 tests/test-propertycache.py requires print_function
112 tests/test-propertycache.py requires print_function
114 tests/test-revlog-ancestry.py not using absolute_import
113 tests/test-revlog-ancestry.py not using absolute_import
115 tests/test-revlog-ancestry.py requires print_function
114 tests/test-revlog-ancestry.py requires print_function
116 tests/test-run-tests.py not using absolute_import
115 tests/test-run-tests.py not using absolute_import
117 tests/test-simplemerge.py not using absolute_import
116 tests/test-simplemerge.py not using absolute_import
118 tests/test-status-inprocess.py not using absolute_import
117 tests/test-status-inprocess.py not using absolute_import
119 tests/test-status-inprocess.py requires print_function
118 tests/test-status-inprocess.py requires print_function
120 tests/test-symlink-os-yes-fs-no.py not using absolute_import
119 tests/test-symlink-os-yes-fs-no.py not using absolute_import
121 tests/test-trusted.py not using absolute_import
120 tests/test-trusted.py not using absolute_import
122 tests/test-trusted.py requires print_function
121 tests/test-trusted.py requires print_function
123 tests/test-ui-color.py not using absolute_import
122 tests/test-ui-color.py not using absolute_import
124 tests/test-ui-color.py requires print_function
123 tests/test-ui-color.py requires print_function
125 tests/test-ui-config.py not using absolute_import
124 tests/test-ui-config.py not using absolute_import
126 tests/test-ui-config.py requires print_function
125 tests/test-ui-config.py requires print_function
127 tests/test-ui-verbosity.py not using absolute_import
126 tests/test-ui-verbosity.py not using absolute_import
128 tests/test-ui-verbosity.py requires print_function
127 tests/test-ui-verbosity.py requires print_function
129 tests/test-url.py not using absolute_import
128 tests/test-url.py not using absolute_import
130 tests/test-url.py requires print_function
129 tests/test-url.py requires print_function
131 tests/test-walkrepo.py requires print_function
130 tests/test-walkrepo.py requires print_function
132 tests/test-wireproto.py requires print_function
131 tests/test-wireproto.py requires print_function
133 tests/tinyproxy.py requires print_function
132 tests/tinyproxy.py requires print_function
General Comments 0
You need to be logged in to leave comments. Login now