comparison hgext/convert/__init__.py @ 30813:2cbbd4622ab0

convert: config option to control Git committer actions When converting a Git repository to Mercurial at Mozilla, I encountered a scenario where I didn't want `hg convert` to automatically add the "committer: <committer>" line to commit messages. While I can hack around this by rewriting the Git commit before it is fed into `hg convert`, I figured it would be a useful knob to control. This patch introduces a config option that allows lots of control over the committer value. I initially implemented this as a single boolean flag to control whether to save the committer message. But then there was feedback that it would be useful to save the committer in extra data. While this patch doesn't implement support for saving in extra data, it does add a mechanism for extending which actions to take on the committer field. We should be able to easily add actions to save in extra data. Some of the implemented features weren't asked for. But I figured they could be useful. If nothing else they demonstrate the extensibility of this mechanism.
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 13 Jan 2017 23:21:10 -0800
parents ced0d686ecb3
children c5bf2e8ec18c
comparison
equal deleted inserted replaced
30812:98bfce9bd5e5 30813:2cbbd4622ab0
325 and copy detection more accurate but will significantly slow down 325 and copy detection more accurate but will significantly slow down
326 computation on large projects. The option is only relevant if 326 computation on large projects. The option is only relevant if
327 ``convert.git.similarity`` is greater than 0. The default is 327 ``convert.git.similarity`` is greater than 0. The default is
328 ``400``. 328 ``400``.
329 329
330 :convert.git.committeractions: list of actions to take when processing
331 author and committer values.
332
333 Git commits have separate author (who wrote the commit) and committer
334 (who applied the commit) fields. Not all destinations support separate
335 author and committer fields (including Mercurial). This config option
336 controls what to do with these author and committer fields during
337 conversion.
338
339 A value of ``messagedifferent`` will append a ``committer: ...``
340 line to the commit message if the Git committer is different from the
341 author. The prefix of that line can be specified using the syntax
342 ``messagedifferent=<prefix>``. e.g. ``messagedifferent=git-committer:``.
343 When a prefix is specified, a space will always be inserted between the
344 prefix and the value.
345
346 ``messagealways`` behaves like ``messagedifferent`` except it will
347 always result in a ``committer: ...`` line being appended to the commit
348 message. This value is mutually exclusive with ``messagedifferent``.
349
350 ``dropcommitter`` will remove references to the committer. Only
351 references to the author will remain. Actions that add references
352 to the committer will have no effect when this is set.
353
354 ``replaceauthor`` will replace the value of the author field with
355 the committer. Other actions that add references to the committer
356 will still take effect when this is set.
357
358 ``replacecommitter`` will replace the value of the committer field
359 with the author.
360
361 The default is ``messagedifferent``.
362
330 :convert.git.extrakeys: list of extra keys from commit metadata to copy to 363 :convert.git.extrakeys: list of extra keys from commit metadata to copy to
331 the destination. Some Git repositories store extra metadata in commits. 364 the destination. Some Git repositories store extra metadata in commits.
332 By default, this non-default metadata will be lost during conversion. 365 By default, this non-default metadata will be lost during conversion.
333 Setting this config option can retain that metadata. Some built-in 366 Setting this config option can retain that metadata. Some built-in
334 keys such as ``parent`` and ``branch`` are not allowed to be copied. 367 keys such as ``parent`` and ``branch`` are not allowed to be copied.