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