--- a/eric7/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Wed Jun 15 09:44:07 2022 +0200 +++ b/eric7/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Thu Jun 16 18:28:59 2022 +0200 @@ -11,8 +11,9 @@ import re import collections import contextlib +import pathlib -from PyQt6.QtCore import pyqtSlot, Qt, QDate, QSize, QPoint, QFileInfo +from PyQt6.QtCore import pyqtSlot, Qt, QDate, QSize, QPoint from PyQt6.QtGui import ( QColor, QPixmap, QPainter, QPen, QBrush, QIcon, QTextCursor, QPalette ) @@ -2685,25 +2686,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.diffEdit.toPlainText().splitlines())) except OSError as why: EricMessageBox.critical( @@ -2711,7 +2711,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(str) def on_sbsSelectLabel_linkActivated(self, link):