[meld: 1/2] VcView: add missing cases from temp file extension commit
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld: 1/2] VcView: add missing cases from temp file extension commit
- Date: Mon, 21 Sep 2020 07:00:56 +0000 (UTC)
commit 55699d97e32fc7f286b3514b6b2a74ee7fd8ff6f
Author: Alan Suran <alan1apds gmail com>
Date: Fri Sep 18 01:09:52 2020 -0400
VcView: add missing cases from temp file extension commit
Missing cases from "tempextension" commit
VcView: use extension with temp files so syntax highlight correct (#459)
- file in git repo with conflict status didn't preserve the
extension for the base file, so may get incorrect language
- null vc
meld/vc/_null.py | 5 ++++-
meld/vc/git.py | 9 ++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/meld/vc/_null.py b/meld/vc/_null.py
index 88e821b2..58b80c1b 100644
--- a/meld/vc/_null.py
+++ b/meld/vc/_null.py
@@ -22,6 +22,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import os
import shutil
import tempfile
@@ -41,7 +42,9 @@ class Vc(_vc.Vc):
pass
def get_path_for_repo_file(self, path, commit=None):
- with tempfile.NamedTemporaryFile(prefix='meld-tmp', delete=False) as f:
+ suffix = os.path.splitext(path)[1]
+ with tempfile.NamedTemporaryFile(
+ prefix='meld-tmp', suffix=suffix, delete=False) as f:
with open(path, 'rb') as vc_file:
shutil.copyfileobj(vc_file, f)
return f.name
diff --git a/meld/vc/git.py b/meld/vc/git.py
index 5e45aaf2..473e8590 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -179,7 +179,7 @@ class Vc(_vc.Vc):
command = [self.CMD, 'add']
runner(command, files, refresh=True, working_dir=self.root)
- def remerge_with_ancestor(self, local, base, remote):
+ def remerge_with_ancestor(self, local, base, remote, suffix=''):
"""Reconstruct a mixed merge-plus-base file
This method re-merges a given file to get diff3-style conflicts
@@ -194,7 +194,8 @@ class Vc(_vc.Vc):
_vc.base_from_diff3(proc.stdout.read()))
prefix = 'meld-tmp-%s-' % _vc.CONFLICT_MERGED
- with tempfile.NamedTemporaryFile(prefix=prefix, delete=False) as f:
+ with tempfile.NamedTemporaryFile(
+ prefix=prefix, suffix=suffix, delete=False) as f:
shutil.copyfileobj(vc_file, f)
return f.name, True
@@ -213,7 +214,9 @@ class Vc(_vc.Vc):
raise _vc.InvalidVCPath(self, path,
"Couldn't access conflict parents")
- filename, is_temp = self.remerge_with_ancestor(local, base, remote)
+ suffix = os.path.splitext(path)[1]
+ filename, is_temp = self.remerge_with_ancestor(
+ local, base, remote, suffix=suffix)
for temp_file in (local, base, remote):
if os.name == "nt":
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]