Show More
@@ -618,6 +618,9 def _makebackup(repo, ui, wctx, fcd, pre | |||||
618 | (if any), the backup is used to undo certain premerges, confirm whether a |
|
618 | (if any), the backup is used to undo certain premerges, confirm whether a | |
619 | merge changed anything, and determine what line endings the new file should |
|
619 | merge changed anything, and determine what line endings the new file should | |
620 | have. |
|
620 | have. | |
|
621 | ||||
|
622 | Backups only need to be written once (right before the premerge) since their | |||
|
623 | content doesn't change afterwards. | |||
621 | """ |
|
624 | """ | |
622 | if fcd.isabsent(): |
|
625 | if fcd.isabsent(): | |
623 | return None |
|
626 | return None | |
@@ -628,7 +631,6 def _makebackup(repo, ui, wctx, fcd, pre | |||||
628 | back = scmutil.origpath(ui, repo, a) |
|
631 | back = scmutil.origpath(ui, repo, a) | |
629 | inworkingdir = (back.startswith(repo.wvfs.base) and not |
|
632 | inworkingdir = (back.startswith(repo.wvfs.base) and not | |
630 | back.startswith(repo.vfs.base)) |
|
633 | back.startswith(repo.vfs.base)) | |
631 |
|
||||
632 | if isinstance(fcd, context.overlayworkingfilectx) and inworkingdir: |
|
634 | if isinstance(fcd, context.overlayworkingfilectx) and inworkingdir: | |
633 | # If the backup file is to be in the working directory, and we're |
|
635 | # If the backup file is to be in the working directory, and we're | |
634 | # merging in-memory, we must redirect the backup to the memory context |
|
636 | # merging in-memory, we must redirect the backup to the memory context | |
@@ -637,12 +639,17 def _makebackup(repo, ui, wctx, fcd, pre | |||||
637 | wctx[relpath].write(fcd.data(), fcd.flags()) |
|
639 | wctx[relpath].write(fcd.data(), fcd.flags()) | |
638 | return wctx[relpath] |
|
640 | return wctx[relpath] | |
639 | else: |
|
641 | else: | |
640 | # Otherwise, write to wherever the user specified the backups should go. |
|
642 | if premerge: | |
641 | # |
|
643 | # Otherwise, write to wherever path the user specified the backups | |
|
644 | # should go. We still need to switch based on whether the source is | |||
|
645 | # in-memory so we can use the fast path of ``util.copy`` if both are | |||
|
646 | # on disk. | |||
|
647 | if isinstance(fcd, context.overlayworkingfilectx): | |||
|
648 | util.writefile(back, fcd.data()) | |||
|
649 | else: | |||
|
650 | util.copyfile(a, back) | |||
642 | # A arbitraryfilectx is returned, so we can run the same functions on |
|
651 | # A arbitraryfilectx is returned, so we can run the same functions on | |
643 | # the backup context regardless of where it lives. |
|
652 | # the backup context regardless of where it lives. | |
644 | if premerge: |
|
|||
645 | util.copyfile(a, back) |
|
|||
646 | return context.arbitraryfilectx(back, repo=repo) |
|
653 | return context.arbitraryfilectx(back, repo=repo) | |
647 |
|
654 | |||
648 | def _maketempfiles(repo, fco, fca): |
|
655 | def _maketempfiles(repo, fco, fca): |
General Comments 0
You need to be logged in to leave comments.
Login now