# HG changeset patch # User Martin von Zweigbergk # Date 1644905090 28800 # Node ID b53f2f5a18deb84c20fb6e3335279ff525d74d5f # Parent 9d0d0a388c397c14849cfc6c0a99e40c39e3d9a3 filemerge: move removal of `.orig` extension on temp file close to context The place where the `.orig` extension is removed in `_maketempfiles()` doesn't make it clear that it's the backup path, which is why we have a comment in the code explaining it. Let's instead move it out of the function and close to where we get it from `backup.path()`, so that becomes clear. Differential Revision: https://phab.mercurial-scm.org/D12190 diff -r 9d0d0a388c39 -r b53f2f5a18de mercurial/filemerge.py --- a/mercurial/filemerge.py Mon Feb 14 21:52:18 2022 -0800 +++ b/mercurial/filemerge.py Mon Feb 14 22:04:50 2022 -0800 @@ -746,6 +746,9 @@ localoutputpath = None if b"$output" in args: localoutputpath = backup.path() + # Remove the .orig to make syntax-highlighting more likely. + if localoutputpath.endswith(b'.orig'): + localoutputpath, ext = os.path.splitext(localoutputpath) with _maketempfiles( fco, @@ -940,10 +943,6 @@ c = tempfromcontext(b"other", fco) d = localpath if localpath is not None: - # We start off with this being the backup filename, so remove the .orig - # to make syntax-highlighting more likely. - if d.endswith(b'.orig'): - d, _ = os.path.splitext(d) f, d = maketempfrompath(b"local", d) with open(localpath, b'rb') as src: f.write(src.read())