--- a/eric7/Plugins/VcsPlugins/vcsMercurial/HgDiffDialog.py Wed Jun 15 09:44:07 2022 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsMercurial/HgDiffDialog.py Thu Jun 16 18:28:59 2022 +0200 @@ -7,7 +7,9 @@ Module implementing a dialog to show the output of the hg diff command process. """ -from PyQt6.QtCore import pyqtSlot, QFileInfo, Qt +import pathlib + +from PyQt6.QtCore import pyqtSlot, Qt from PyQt6.QtGui import QTextCursor from PyQt6.QtWidgets import QWidget, QDialogButtonBox @@ -18,7 +20,6 @@ from .HgDiffHighlighter import HgDiffHighlighter from .HgDiffGenerator import HgDiffGenerator -import Utilities import Preferences @@ -230,25 +231,24 @@ if not fname: return # user aborted - ext = QFileInfo(fname).suffix() - if not ext: + fpath = pathlib.Path(fname) + if not fpath.suffix: ex = selectedFilter.split("(*")[1].split(")")[0] if ex: - fname += ex - if QFileInfo(fname).exists(): + fpath = fpath.with_suffix(ex) + if fpath.exists(): res = EricMessageBox.yesNo( self, self.tr("Save Diff"), self.tr("<p>The patch file <b>{0}</b> already exists." - " Overwrite it?</p>").format(fname), + " Overwrite it?</p>").format(str(fpath)), icon=EricMessageBox.Warning) if not res: return - fname = Utilities.toNativeSeparators(fname) eol = ericApp().getObject("Project").getEolString() try: - with open(fname, "w", encoding="utf-8", newline="") as f: + with fpath.open("w", encoding="utf-8", newline="") as f: f.write(eol.join(self.contents.toPlainText().splitlines())) except OSError as why: EricMessageBox.critical( @@ -256,7 +256,7 @@ self.tr( '<p>The patch file <b>{0}</b> could not be saved.' '<br>Reason: {1}</p>') - .format(fname, str(why))) + .format(str(fpath), str(why))) @pyqtSlot() def on_refreshButton_clicked(self):