Show More
@@ -742,20 +742,26 b' def _xmerge(repo, mynode, local, other, ' | |||||
742 | return False, 1, None |
|
742 | return False, 1, None | |
743 | localpath = _workingpath(repo, fcd) |
|
743 | localpath = _workingpath(repo, fcd) | |
744 | args = _toolstr(repo.ui, tool, b"args") |
|
744 | args = _toolstr(repo.ui, tool, b"args") | |
745 | localoutputpath = None |
|
745 | ||
|
746 | files = [ | |||
|
747 | (b"base", fca.path(), fca.decodeddata()), | |||
|
748 | (b"other", fco.path(), fco.decodeddata()), | |||
|
749 | ] | |||
|
750 | outpath = b"" | |||
746 | if b"$output" in args: |
|
751 | if b"$output" in args: | |
|
752 | # read input from backup, write to original | |||
|
753 | outpath = localpath | |||
747 | localoutputpath = backup.path() |
|
754 | localoutputpath = backup.path() | |
748 | # Remove the .orig to make syntax-highlighting more likely. |
|
755 | # Remove the .orig to make syntax-highlighting more likely. | |
749 | if localoutputpath.endswith(b'.orig'): |
|
756 | if localoutputpath.endswith(b'.orig'): | |
750 | localoutputpath, ext = os.path.splitext(localoutputpath) |
|
757 | localoutputpath, ext = os.path.splitext(localoutputpath) | |
|
758 | localdata = util.readfile(localpath) | |||
|
759 | files.append((b"local", localoutputpath, localdata)) | |||
751 |
|
760 | |||
752 | with _maketempfiles( |
|
761 | with _maketempfiles(files) as temppaths: | |
753 | fco, |
|
762 | basepath, otherpath = temppaths[:2] | |
754 | fca, |
|
763 | if len(temppaths) == 3: | |
755 | localoutputpath, |
|
764 | localpath = temppaths[2] | |
756 | ) as temppaths: |
|
|||
757 | basepath, otherpath, localoutputpath = temppaths |
|
|||
758 | outpath = b"" |
|
|||
759 |
|
765 | |||
760 | def format_label(input): |
|
766 | def format_label(input): | |
761 | if input.label_detail: |
|
767 | if input.label_detail: | |
@@ -777,10 +783,6 b' def _xmerge(repo, mynode, local, other, ' | |||||
777 | } |
|
783 | } | |
778 | ui = repo.ui |
|
784 | ui = repo.ui | |
779 |
|
785 | |||
780 | if b"$output" in args: |
|
|||
781 | # read input from backup, write to original |
|
|||
782 | outpath = localpath |
|
|||
783 | localpath = localoutputpath |
|
|||
784 | replace = { |
|
786 | replace = { | |
785 | b'local': localpath, |
|
787 | b'local': localpath, | |
786 | b'base': basepath, |
|
788 | b'base': basepath, | |
@@ -915,10 +917,9 b' def _makebackup(repo, ui, fcd):' | |||||
915 |
|
917 | |||
916 |
|
918 | |||
917 | @contextlib.contextmanager |
|
919 | @contextlib.contextmanager | |
918 |
def _maketempfiles(f |
|
920 | def _maketempfiles(files): | |
919 | """Writes out `fco` and `fca` as temporary files, and (if localpath is not |
|
921 | """Creates a temporary file for each (prefix, path, data) tuple in `files`, | |
920 | None) copies `localpath` to another temporary file, so an external merge |
|
922 | so an external merge tool may use them. | |
921 | tool may use them. |
|
|||
922 | """ |
|
923 | """ | |
923 | tmproot = pycompat.mkdtemp(prefix=b'hgmerge-') |
|
924 | tmproot = pycompat.mkdtemp(prefix=b'hgmerge-') | |
924 |
|
925 | |||
@@ -931,18 +932,11 b' def _maketempfiles(fco, fca, localpath):' | |||||
931 | util.writefile(name, data) |
|
932 | util.writefile(name, data) | |
932 | return name |
|
933 | return name | |
933 |
|
934 | |||
934 | def tempfromcontext(prefix, ctx): |
|
935 | temp_files = [] | |
935 | return maketempfrompath(prefix, ctx.path(), ctx.decodeddata()) |
|
936 | for prefix, path, data in files: | |
936 |
|
937 | temp_files.append(maketempfrompath(prefix, path, data)) | ||
937 | b = tempfromcontext(b"base", fca) |
|
|||
938 | c = tempfromcontext(b"other", fco) |
|
|||
939 | d = localpath |
|
|||
940 | if localpath is not None: |
|
|||
941 | data = util.readfile(localpath) |
|
|||
942 | d = maketempfrompath(b"local", localpath, data) |
|
|||
943 |
|
||||
944 | try: |
|
938 | try: | |
945 |
yield |
|
939 | yield temp_files | |
946 | finally: |
|
940 | finally: | |
947 | shutil.rmtree(tmproot) |
|
941 | shutil.rmtree(tmproot) | |
948 |
|
942 |
General Comments 0
You need to be logged in to leave comments.
Login now