Show More
@@ -877,7 +877,7 b' def partextras(labels):' | |||
|
877 | 877 | } |
|
878 | 878 | |
|
879 | 879 | |
|
880 |
def _makebackup(repo, ui, |
|
|
880 | def _makebackup(repo, ui, fcd): | |
|
881 | 881 | """Makes and returns a filectx-like object for ``fcd``'s backup file. |
|
882 | 882 | |
|
883 | 883 | In addition to preserving the user's pre-existing modifications to `fcd` |
@@ -894,30 +894,17 b' def _makebackup(repo, ui, wctx, fcd):' | |||
|
894 | 894 | # merge -> filemerge). (I suspect the fileset import is the weakest link) |
|
895 | 895 | from . import context |
|
896 | 896 | |
|
897 | backup = scmutil.backuppath(ui, repo, fcd.path()) | |
|
898 | inworkingdir = backup.startswith(repo.wvfs.base) and not backup.startswith( | |
|
899 | repo.vfs.base | |
|
900 | ) | |
|
901 | if isinstance(fcd, context.overlayworkingfilectx) and inworkingdir: | |
|
902 | # If the backup file is to be in the working directory, and we're | |
|
903 | # merging in-memory, we must redirect the backup to the memory context | |
|
904 | # so we don't disturb the working directory. | |
|
905 | relpath = backup[len(repo.wvfs.base) + 1 :] | |
|
906 | wctx[relpath].write(fcd.data(), fcd.flags()) | |
|
907 | return wctx[relpath] | |
|
897 | if isinstance(fcd, context.overlayworkingfilectx): | |
|
898 | # If we're merging in-memory, we're free to put the backup anywhere. | |
|
899 | fd, backup = pycompat.mkstemp(b'hg-merge-backup') | |
|
900 | with os.fdopen(fd, 'wb') as f: | |
|
901 | f.write(fcd.data()) | |
|
908 | 902 | else: |
|
909 | # Otherwise, write to wherever path the user specified the backups | |
|
910 | # should go. We still need to switch based on whether the source is | |
|
911 | # in-memory so we can use the fast path of ``util.copy`` if both are | |
|
912 | # on disk. | |
|
913 | if isinstance(fcd, context.overlayworkingfilectx): | |
|
914 | util.writefile(backup, fcd.data()) | |
|
915 | else: | |
|
916 | a = _workingpath(repo, fcd) | |
|
917 | util.copyfile(a, backup) | |
|
918 | # A arbitraryfilectx is returned, so we can run the same functions on | |
|
919 | # the backup context regardless of where it lives. | |
|
920 | return context.arbitraryfilectx(backup, repo=repo) | |
|
903 | backup = scmutil.backuppath(ui, repo, fcd.path()) | |
|
904 | a = _workingpath(repo, fcd) | |
|
905 | util.copyfile(a, backup) | |
|
906 | ||
|
907 | return context.arbitraryfilectx(backup, repo=repo) | |
|
921 | 908 | |
|
922 | 909 | |
|
923 | 910 | @contextlib.contextmanager |
@@ -1065,7 +1052,7 b' def filemerge(repo, wctx, mynode, orig, ' | |||
|
1065 | 1052 | ui.warn(onfailure % fduipath) |
|
1066 | 1053 | return 1, False |
|
1067 | 1054 | |
|
1068 |
backup = _makebackup(repo, ui, |
|
|
1055 | backup = _makebackup(repo, ui, fcd) | |
|
1069 | 1056 | r = 1 |
|
1070 | 1057 | try: |
|
1071 | 1058 | internalmarkerstyle = ui.config(b'ui', b'mergemarkers') |
General Comments 0
You need to be logged in to leave comments.
Login now