Show More
@@ -327,6 +327,39 b' def convert(ui, src, dest=None, revmapfi' | |||||
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. |
@@ -110,6 +110,55 b' class convert_git(common.converter_sourc' | |||||
110 | raise error.Abort(_('copying of extra key is forbidden: %s') % |
|
110 | raise error.Abort(_('copying of extra key is forbidden: %s') % | |
111 | _(', ').join(sorted(banned))) |
|
111 | _(', ').join(sorted(banned))) | |
112 |
|
112 | |||
|
113 | committeractions = self.ui.configlist('convert', 'git.committeractions', | |||
|
114 | 'messagedifferent') | |||
|
115 | ||||
|
116 | messagedifferent = None | |||
|
117 | messagealways = None | |||
|
118 | for a in committeractions: | |||
|
119 | if a.startswith(('messagedifferent', 'messagealways')): | |||
|
120 | k = a | |||
|
121 | v = None | |||
|
122 | if '=' in a: | |||
|
123 | k, v = a.split('=', 1) | |||
|
124 | ||||
|
125 | if k == 'messagedifferent': | |||
|
126 | messagedifferent = v or 'committer:' | |||
|
127 | elif k == 'messagealways': | |||
|
128 | messagealways = v or 'committer:' | |||
|
129 | ||||
|
130 | if messagedifferent and messagealways: | |||
|
131 | raise error.Abort(_('committeractions cannot define both ' | |||
|
132 | 'messagedifferent and messagealways')) | |||
|
133 | ||||
|
134 | dropcommitter = 'dropcommitter' in committeractions | |||
|
135 | replaceauthor = 'replaceauthor' in committeractions | |||
|
136 | replacecommitter = 'replacecommitter' in committeractions | |||
|
137 | ||||
|
138 | if dropcommitter and (replaceauthor or replacecommitter): | |||
|
139 | raise error.Abort(_('committeractions cannot define both ' | |||
|
140 | 'dropcommitter and ' | |||
|
141 | 'replaceauthor/replacecommitter')) | |||
|
142 | ||||
|
143 | if dropcommitter and messagealways: | |||
|
144 | raise error.Abort(_('committeractions cannot define both ' | |||
|
145 | 'dropcommitter and messagealways')) | |||
|
146 | ||||
|
147 | if replaceauthor and replacecommitter: | |||
|
148 | raise error.Abort(_('committeractions cannot define both ' | |||
|
149 | 'replaceauthor and replacecommitter')) | |||
|
150 | ||||
|
151 | if not messagedifferent and not messagealways: | |||
|
152 | messagedifferent = 'committer:' | |||
|
153 | ||||
|
154 | self.committeractions = { | |||
|
155 | 'dropcommitter': dropcommitter, | |||
|
156 | 'replaceauthor': replaceauthor, | |||
|
157 | 'replacecommitter': replacecommitter, | |||
|
158 | 'messagedifferent': messagedifferent, | |||
|
159 | 'messagealways': messagealways, | |||
|
160 | } | |||
|
161 | ||||
113 | def after(self): |
|
162 | def after(self): | |
114 | for f in self.catfilepipe: |
|
163 | for f in self.catfilepipe: | |
115 | f.close() |
|
164 | f.close() | |
@@ -317,8 +366,22 b' class convert_git(common.converter_sourc' | |||||
317 | if n in self.copyextrakeys: |
|
366 | if n in self.copyextrakeys: | |
318 | extra[n] = v |
|
367 | extra[n] = v | |
319 |
|
368 | |||
320 |
if committer |
|
369 | if self.committeractions['dropcommitter']: | |
321 | message += "\ncommitter: %s\n" % committer |
|
370 | committer = None | |
|
371 | ||||
|
372 | if self.committeractions['replacecommitter']: | |||
|
373 | committer = author | |||
|
374 | elif self.committeractions['replaceauthor']: | |||
|
375 | author = committer | |||
|
376 | ||||
|
377 | if committer: | |||
|
378 | messagealways = self.committeractions['messagealways'] | |||
|
379 | messagedifferent = self.committeractions['messagedifferent'] | |||
|
380 | if messagealways: | |||
|
381 | message += '\n%s %s\n' % (messagealways, committer) | |||
|
382 | elif messagedifferent and author != committer: | |||
|
383 | message += '\n%s %s\n' % (messagedifferent, committer) | |||
|
384 | ||||
322 | tzs, tzh, tzm = tz[-5:-4] + "1", tz[-4:-2], tz[-2:] |
|
385 | tzs, tzh, tzm = tz[-5:-4] + "1", tz[-4:-2], tz[-2:] | |
323 | tz = -int(tzs) * (int(tzh) * 3600 + int(tzm)) |
|
386 | tz = -int(tzs) * (int(tzh) * 3600 + int(tzm)) | |
324 | date = tm + " " + str(tz) |
|
387 | date = tm + " " + str(tz) |
@@ -482,6 +482,229 b' convert author committer' | |||||
482 |
|
482 | |||
483 |
|
483 | |||
484 |
|
484 | |||
|
485 | Various combinations of committeractions fail | |||
|
486 | ||||
|
487 | $ hg --config convert.git.committeractions=messagedifferent,messagealways convert git-repo4 bad-committer | |||
|
488 | initializing destination bad-committer repository | |||
|
489 | abort: committeractions cannot define both messagedifferent and messagealways | |||
|
490 | [255] | |||
|
491 | ||||
|
492 | $ hg --config convert.git.committeractions=dropcommitter,replaceauthor convert git-repo4 bad-committer | |||
|
493 | initializing destination bad-committer repository | |||
|
494 | abort: committeractions cannot define both dropcommitter and replaceauthor/replacecommitter | |||
|
495 | [255] | |||
|
496 | ||||
|
497 | $ hg --config convert.git.committeractions=dropcommitter,replacecommitter convert git-repo4 bad-committer | |||
|
498 | initializing destination bad-committer repository | |||
|
499 | abort: committeractions cannot define both dropcommitter and replaceauthor/replacecommitter | |||
|
500 | [255] | |||
|
501 | ||||
|
502 | $ hg --config convert.git.committeractions=dropcommitter,messagealways convert git-repo4 bad-committer | |||
|
503 | initializing destination bad-committer repository | |||
|
504 | abort: committeractions cannot define both dropcommitter and messagealways | |||
|
505 | [255] | |||
|
506 | ||||
|
507 | $ hg --config convert.git.committeractions=replaceauthor,replacecommitter convert git-repo4 bad-committer | |||
|
508 | initializing destination bad-committer repository | |||
|
509 | abort: committeractions cannot define both replaceauthor and replacecommitter | |||
|
510 | [255] | |||
|
511 | ||||
|
512 | custom prefix on messagedifferent works | |||
|
513 | ||||
|
514 | $ hg --config convert.git.committeractions=messagedifferent=different: convert git-repo4 git-repo4-hg-messagedifferentprefix | |||
|
515 | initializing destination git-repo4-hg-messagedifferentprefix repository | |||
|
516 | scanning source... | |||
|
517 | sorting... | |||
|
518 | converting... | |||
|
519 | 1 addfoo | |||
|
520 | 0 addfoo2 | |||
|
521 | updating bookmarks | |||
|
522 | ||||
|
523 | $ hg -R git-repo4-hg-messagedifferentprefix log -v | |||
|
524 | changeset: 1:2fe0c98a109d | |||
|
525 | bookmark: master | |||
|
526 | tag: tip | |||
|
527 | user: nottest <test@example.org> | |||
|
528 | date: Mon Jan 01 00:00:21 2007 +0000 | |||
|
529 | files: foo | |||
|
530 | description: | |||
|
531 | addfoo2 | |||
|
532 | ||||
|
533 | different: test <test@example.org> | |||
|
534 | ||||
|
535 | ||||
|
536 | changeset: 0:0735477b0224 | |||
|
537 | user: test <test@example.org> | |||
|
538 | date: Mon Jan 01 00:00:20 2007 +0000 | |||
|
539 | files: foo | |||
|
540 | description: | |||
|
541 | addfoo | |||
|
542 | ||||
|
543 | ||||
|
544 | ||||
|
545 | messagealways will always add the "committer: " line even if committer identical | |||
|
546 | ||||
|
547 | $ hg --config convert.git.committeractions=messagealways convert git-repo4 git-repo4-hg-messagealways | |||
|
548 | initializing destination git-repo4-hg-messagealways repository | |||
|
549 | scanning source... | |||
|
550 | sorting... | |||
|
551 | converting... | |||
|
552 | 1 addfoo | |||
|
553 | 0 addfoo2 | |||
|
554 | updating bookmarks | |||
|
555 | ||||
|
556 | $ hg -R git-repo4-hg-messagealways log -v | |||
|
557 | changeset: 1:8db057d8cd37 | |||
|
558 | bookmark: master | |||
|
559 | tag: tip | |||
|
560 | user: nottest <test@example.org> | |||
|
561 | date: Mon Jan 01 00:00:21 2007 +0000 | |||
|
562 | files: foo | |||
|
563 | description: | |||
|
564 | addfoo2 | |||
|
565 | ||||
|
566 | committer: test <test@example.org> | |||
|
567 | ||||
|
568 | ||||
|
569 | changeset: 0:8f71fe9c98be | |||
|
570 | user: test <test@example.org> | |||
|
571 | date: Mon Jan 01 00:00:20 2007 +0000 | |||
|
572 | files: foo | |||
|
573 | description: | |||
|
574 | addfoo | |||
|
575 | ||||
|
576 | committer: test <test@example.org> | |||
|
577 | ||||
|
578 | ||||
|
579 | ||||
|
580 | custom prefix on messagealways works | |||
|
581 | ||||
|
582 | $ hg --config convert.git.committeractions=messagealways=always: convert git-repo4 git-repo4-hg-messagealwaysprefix | |||
|
583 | initializing destination git-repo4-hg-messagealwaysprefix repository | |||
|
584 | scanning source... | |||
|
585 | sorting... | |||
|
586 | converting... | |||
|
587 | 1 addfoo | |||
|
588 | 0 addfoo2 | |||
|
589 | updating bookmarks | |||
|
590 | ||||
|
591 | $ hg -R git-repo4-hg-messagealwaysprefix log -v | |||
|
592 | changeset: 1:83c17174de79 | |||
|
593 | bookmark: master | |||
|
594 | tag: tip | |||
|
595 | user: nottest <test@example.org> | |||
|
596 | date: Mon Jan 01 00:00:21 2007 +0000 | |||
|
597 | files: foo | |||
|
598 | description: | |||
|
599 | addfoo2 | |||
|
600 | ||||
|
601 | always: test <test@example.org> | |||
|
602 | ||||
|
603 | ||||
|
604 | changeset: 0:2ac9bcb3534a | |||
|
605 | user: test <test@example.org> | |||
|
606 | date: Mon Jan 01 00:00:20 2007 +0000 | |||
|
607 | files: foo | |||
|
608 | description: | |||
|
609 | addfoo | |||
|
610 | ||||
|
611 | always: test <test@example.org> | |||
|
612 | ||||
|
613 | ||||
|
614 | ||||
|
615 | replaceauthor replaces author with committer | |||
|
616 | ||||
|
617 | $ hg --config convert.git.committeractions=replaceauthor convert git-repo4 git-repo4-hg-replaceauthor | |||
|
618 | initializing destination git-repo4-hg-replaceauthor repository | |||
|
619 | scanning source... | |||
|
620 | sorting... | |||
|
621 | converting... | |||
|
622 | 1 addfoo | |||
|
623 | 0 addfoo2 | |||
|
624 | updating bookmarks | |||
|
625 | ||||
|
626 | $ hg -R git-repo4-hg-replaceauthor log -v | |||
|
627 | changeset: 1:122c1d8999ea | |||
|
628 | bookmark: master | |||
|
629 | tag: tip | |||
|
630 | user: test <test@example.org> | |||
|
631 | date: Mon Jan 01 00:00:21 2007 +0000 | |||
|
632 | files: foo | |||
|
633 | description: | |||
|
634 | addfoo2 | |||
|
635 | ||||
|
636 | ||||
|
637 | changeset: 0:0735477b0224 | |||
|
638 | user: test <test@example.org> | |||
|
639 | date: Mon Jan 01 00:00:20 2007 +0000 | |||
|
640 | files: foo | |||
|
641 | description: | |||
|
642 | addfoo | |||
|
643 | ||||
|
644 | ||||
|
645 | ||||
|
646 | replacecommitter replaces committer with author | |||
|
647 | ||||
|
648 | $ hg --config convert.git.committeractions=replacecommitter convert git-repo4 git-repo4-hg-replacecommitter | |||
|
649 | initializing destination git-repo4-hg-replacecommitter repository | |||
|
650 | scanning source... | |||
|
651 | sorting... | |||
|
652 | converting... | |||
|
653 | 1 addfoo | |||
|
654 | 0 addfoo2 | |||
|
655 | updating bookmarks | |||
|
656 | ||||
|
657 | $ hg -R git-repo4-hg-replacecommitter log -v | |||
|
658 | changeset: 1:190b2da396cc | |||
|
659 | bookmark: master | |||
|
660 | tag: tip | |||
|
661 | user: nottest <test@example.org> | |||
|
662 | date: Mon Jan 01 00:00:21 2007 +0000 | |||
|
663 | files: foo | |||
|
664 | description: | |||
|
665 | addfoo2 | |||
|
666 | ||||
|
667 | ||||
|
668 | changeset: 0:0735477b0224 | |||
|
669 | user: test <test@example.org> | |||
|
670 | date: Mon Jan 01 00:00:20 2007 +0000 | |||
|
671 | files: foo | |||
|
672 | description: | |||
|
673 | addfoo | |||
|
674 | ||||
|
675 | ||||
|
676 | ||||
|
677 | dropcommitter removes the committer | |||
|
678 | ||||
|
679 | $ hg --config convert.git.committeractions=dropcommitter convert git-repo4 git-repo4-hg-dropcommitter | |||
|
680 | initializing destination git-repo4-hg-dropcommitter repository | |||
|
681 | scanning source... | |||
|
682 | sorting... | |||
|
683 | converting... | |||
|
684 | 1 addfoo | |||
|
685 | 0 addfoo2 | |||
|
686 | updating bookmarks | |||
|
687 | ||||
|
688 | $ hg -R git-repo4-hg-dropcommitter log -v | |||
|
689 | changeset: 1:190b2da396cc | |||
|
690 | bookmark: master | |||
|
691 | tag: tip | |||
|
692 | user: nottest <test@example.org> | |||
|
693 | date: Mon Jan 01 00:00:21 2007 +0000 | |||
|
694 | files: foo | |||
|
695 | description: | |||
|
696 | addfoo2 | |||
|
697 | ||||
|
698 | ||||
|
699 | changeset: 0:0735477b0224 | |||
|
700 | user: test <test@example.org> | |||
|
701 | date: Mon Jan 01 00:00:20 2007 +0000 | |||
|
702 | files: foo | |||
|
703 | description: | |||
|
704 | addfoo | |||
|
705 | ||||
|
706 | ||||
|
707 | ||||
485 | --sourceorder should fail |
|
708 | --sourceorder should fail | |
486 |
|
709 | |||
487 | $ hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg |
|
710 | $ hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg |
@@ -268,6 +268,40 b'' | |||||
268 | computation on large projects. The option is only relevant |
|
268 | computation on large projects. The option is only relevant | |
269 | if "convert.git.similarity" is greater than 0. The default |
|
269 | if "convert.git.similarity" is greater than 0. The default | |
270 | is "400". |
|
270 | is "400". | |
|
271 | convert.git.committeractions | |||
|
272 | list of actions to take when processing author and committer | |||
|
273 | values. | |||
|
274 | ||||
|
275 | Git commits have separate author (who wrote the commit) and committer | |||
|
276 | (who applied the commit) fields. Not all destinations support separate | |||
|
277 | author and committer fields (including Mercurial). This config option | |||
|
278 | controls what to do with these author and committer fields during | |||
|
279 | conversion. | |||
|
280 | ||||
|
281 | A value of "messagedifferent" will append a "committer: ..." line to | |||
|
282 | the commit message if the Git committer is different from the author. | |||
|
283 | The prefix of that line can be specified using the syntax | |||
|
284 | "messagedifferent=<prefix>". e.g. "messagedifferent=git-committer:". | |||
|
285 | When a prefix is specified, a space will always be inserted between | |||
|
286 | the prefix and the value. | |||
|
287 | ||||
|
288 | "messagealways" behaves like "messagedifferent" except it will always | |||
|
289 | result in a "committer: ..." line being appended to the commit | |||
|
290 | message. This value is mutually exclusive with "messagedifferent". | |||
|
291 | ||||
|
292 | "dropcommitter" will remove references to the committer. Only | |||
|
293 | references to the author will remain. Actions that add references to | |||
|
294 | the committer will have no effect when this is set. | |||
|
295 | ||||
|
296 | "replaceauthor" will replace the value of the author field with the | |||
|
297 | committer. Other actions that add references to the committer will | |||
|
298 | still take effect when this is set. | |||
|
299 | ||||
|
300 | "replacecommitter" will replace the value of the committer field with | |||
|
301 | the author. | |||
|
302 | ||||
|
303 | The default is "messagedifferent". | |||
|
304 | ||||
271 | convert.git.extrakeys |
|
305 | convert.git.extrakeys | |
272 | list of extra keys from commit metadata to copy to the |
|
306 | list of extra keys from commit metadata to copy to the | |
273 | destination. Some Git repositories store extra metadata in |
|
307 | destination. Some Git repositories store extra metadata in |
General Comments 0
You need to be logged in to leave comments.
Login now