Show More
@@ -602,37 +602,7 def histedit(ui, repo, *parent, **opts): | |||||
602 |
|
602 | |||
603 | if not keep: |
|
603 | if not keep: | |
604 | if replacemap: |
|
604 | if replacemap: | |
605 | ui.note(_('histedit: Should update metadata for the following ' |
|
605 | movebookmarks(ui, repo, replacemap, tmpnodes, created) | |
606 | 'changes:\n')) |
|
|||
607 |
|
||||
608 | def copybms(old, new): |
|
|||
609 | if old in tmpnodes or old in created: |
|
|||
610 | # can't have any metadata we'd want to update |
|
|||
611 | return |
|
|||
612 | while new in replacemap: |
|
|||
613 | new = replacemap[new] |
|
|||
614 | ui.note(_('histedit: %s to %s\n') % (node.short(old), |
|
|||
615 | node.short(new))) |
|
|||
616 | octx = repo[old] |
|
|||
617 | marks = octx.bookmarks() |
|
|||
618 | if marks: |
|
|||
619 | ui.note(_('histedit: moving bookmarks %s\n') % |
|
|||
620 | ', '.join(marks)) |
|
|||
621 | for mark in marks: |
|
|||
622 | repo._bookmarks[mark] = new |
|
|||
623 | bookmarks.write(repo) |
|
|||
624 |
|
||||
625 | # We assume that bookmarks on the tip should remain |
|
|||
626 | # tipmost, but bookmarks on non-tip changesets should go |
|
|||
627 | # to their most reasonable successor. As a result, find |
|
|||
628 | # the old tip and new tip and copy those bookmarks first, |
|
|||
629 | # then do the rest of the bookmark copies. |
|
|||
630 | oldtip = sorted(replacemap.keys(), key=repo.changelog.rev)[-1] |
|
|||
631 | newtip = sorted(replacemap.values(), key=repo.changelog.rev)[-1] |
|
|||
632 | copybms(oldtip, newtip) |
|
|||
633 |
|
||||
634 | for old, new in sorted(replacemap.iteritems()): |
|
|||
635 | copybms(old, new) |
|
|||
636 |
|
|
606 | # TODO update mq state | |
637 |
|
607 | |||
638 | ui.debug('should strip replaced nodes %s\n' % |
|
608 | ui.debug('should strip replaced nodes %s\n' % | |
@@ -743,3 +713,37 def verifyrules(rules, repo, ctxs): | |||||
743 | raise util.Abort(_('unknown action "%s"') % action) |
|
713 | raise util.Abort(_('unknown action "%s"') % action) | |
744 | parsed.append([action, ha]) |
|
714 | parsed.append([action, ha]) | |
745 | return parsed |
|
715 | return parsed | |
|
716 | ||||
|
717 | def movebookmarks(ui, repo, replacemap, tmpnodes, created): | |||
|
718 | """Move bookmark from old to newly created node""" | |||
|
719 | ui.note(_('histedit: Should update metadata for the following ' | |||
|
720 | 'changes:\n')) | |||
|
721 | ||||
|
722 | def copybms(old, new): | |||
|
723 | if old in tmpnodes or old in created: | |||
|
724 | # can't have any metadata we'd want to update | |||
|
725 | return | |||
|
726 | while new in replacemap: | |||
|
727 | new = replacemap[new] | |||
|
728 | ui.note(_('histedit: %s to %s\n') % (node.short(old), | |||
|
729 | node.short(new))) | |||
|
730 | octx = repo[old] | |||
|
731 | marks = octx.bookmarks() | |||
|
732 | if marks: | |||
|
733 | ui.note(_('histedit: moving bookmarks %s\n') % | |||
|
734 | ', '.join(marks)) | |||
|
735 | for mark in marks: | |||
|
736 | repo._bookmarks[mark] = new | |||
|
737 | bookmarks.write(repo) | |||
|
738 | ||||
|
739 | # We assume that bookmarks on the tip should remain | |||
|
740 | # tipmost, but bookmarks on non-tip changesets should go | |||
|
741 | # to their most reasonable successor. As a result, find | |||
|
742 | # the old tip and new tip and copy those bookmarks first, | |||
|
743 | # then do the rest of the bookmark copies. | |||
|
744 | oldtip = sorted(replacemap.keys(), key=repo.changelog.rev)[-1] | |||
|
745 | newtip = sorted(replacemap.values(), key=repo.changelog.rev)[-1] | |||
|
746 | copybms(oldtip, newtip) | |||
|
747 | ||||
|
748 | for old, new in sorted(replacemap.iteritems()): | |||
|
749 | copybms(old, new) |
General Comments 0
You need to be logged in to leave comments.
Login now