19 from PyQt6.QtWidgets import ( |
19 from PyQt6.QtWidgets import ( |
20 QWidget, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QApplication, |
20 QWidget, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QApplication, |
21 QLineEdit, QMenu, QInputDialog |
21 QLineEdit, QMenu, QInputDialog |
22 ) |
22 ) |
23 |
23 |
24 from E5Gui.E5Application import e5App |
24 from E5Gui.EricApplication import ericApp |
25 from E5Gui import E5MessageBox, E5FileDialog |
25 from E5Gui import EricMessageBox, EricFileDialog |
26 from E5Gui.E5OverrideCursor import E5OverrideCursor |
26 from E5Gui.EricOverrideCursor import EricOverrideCursor |
27 |
27 |
28 from .Ui_HgLogBrowserDialog import Ui_HgLogBrowserDialog |
28 from .Ui_HgLogBrowserDialog import Ui_HgLogBrowserDialog |
29 |
29 |
30 from .HgDiffHighlighter import HgDiffHighlighter |
30 from .HgDiffHighlighter import HgDiffHighlighter |
31 from .HgDiffGenerator import HgDiffGenerator |
31 from .HgDiffGenerator import HgDiffGenerator |
228 |
228 |
229 self.__logTreeNormalFont = self.logTree.font() |
229 self.__logTreeNormalFont = self.logTree.font() |
230 self.__logTreeNormalFont.setBold(False) |
230 self.__logTreeNormalFont.setBold(False) |
231 self.__logTreeBoldFont = self.logTree.font() |
231 self.__logTreeBoldFont = self.logTree.font() |
232 self.__logTreeBoldFont.setBold(True) |
232 self.__logTreeBoldFont.setBold(True) |
233 self.__logTreeHasDarkBackground = e5App().usesDarkPalette() |
233 self.__logTreeHasDarkBackground = ericApp().usesDarkPalette() |
234 |
234 |
235 self.detailsEdit.anchorClicked.connect(self.__revisionClicked) |
235 self.detailsEdit.anchorClicked.connect(self.__revisionClicked) |
236 |
236 |
237 self.__initActionsMenu() |
237 self.__initActionsMenu() |
238 |
238 |
982 QDialogButtonBox.StandardButton.Cancel).setEnabled(True) |
982 QDialogButtonBox.StandardButton.Cancel).setEnabled(True) |
983 self.buttonBox.button( |
983 self.buttonBox.button( |
984 QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
984 QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
985 QApplication.processEvents() |
985 QApplication.processEvents() |
986 |
986 |
987 with E5OverrideCursor(): |
987 with EricOverrideCursor(): |
988 self.buf = [] |
988 self.buf = [] |
989 self.cancelled = False |
989 self.cancelled = False |
990 self.errors.clear() |
990 self.errors.clear() |
991 self.intercept = False |
991 self.intercept = False |
992 |
992 |
1019 "logBrowserBookmarkPhase.tmpl")) |
1019 "logBrowserBookmarkPhase.tmpl")) |
1020 if self.commandMode == "incoming": |
1020 if self.commandMode == "incoming": |
1021 if self.__bundle: |
1021 if self.__bundle: |
1022 args.append(self.__bundle) |
1022 args.append(self.__bundle) |
1023 elif not self.vcs.hasSubrepositories(): |
1023 elif not self.vcs.hasSubrepositories(): |
1024 project = e5App().getObject("Project") |
1024 project = ericApp().getObject("Project") |
1025 self.vcs.bundleFile = os.path.join( |
1025 self.vcs.bundleFile = os.path.join( |
1026 project.getProjectManagementDir(), "hg-bundle.hg") |
1026 project.getProjectManagementDir(), "hg-bundle.hg") |
1027 if os.path.exists(self.vcs.bundleFile): |
1027 if os.path.exists(self.vcs.bundleFile): |
1028 os.remove(self.vcs.bundleFile) |
1028 os.remove(self.vcs.bundleFile) |
1029 preargs = args[:] |
1029 preargs = args[:] |
2006 itm.text(self.RevisionColumn).strip().split(":", 1)[0]) |
2006 itm.text(self.RevisionColumn).strip().split(":", 1)[0]) |
2007 |
2007 |
2008 if revs: |
2008 if revs: |
2009 shouldReopen = self.vcs.hgGraft(revs) |
2009 shouldReopen = self.vcs.hgGraft(revs) |
2010 if shouldReopen: |
2010 if shouldReopen: |
2011 res = E5MessageBox.yesNo( |
2011 res = EricMessageBox.yesNo( |
2012 None, |
2012 None, |
2013 self.tr("Copy Changesets"), |
2013 self.tr("Copy Changesets"), |
2014 self.tr( |
2014 self.tr( |
2015 """The project should be reread. Do this now?"""), |
2015 """The project should be reread. Do this now?"""), |
2016 yesDefault=True) |
2016 yesDefault=True) |
2017 if res: |
2017 if res: |
2018 e5App().getObject("Project").reopenProject() |
2018 ericApp().getObject("Project").reopenProject() |
2019 return |
2019 return |
2020 |
2020 |
2021 self.on_refreshButton_clicked() |
2021 self.on_refreshButton_clicked() |
2022 |
2022 |
2023 @pyqtSlot() |
2023 @pyqtSlot() |
2174 refresh = True |
2174 refresh = True |
2175 if self.initialCommandMode == "incoming": |
2175 if self.initialCommandMode == "incoming": |
2176 addNext = True |
2176 addNext = True |
2177 |
2177 |
2178 if shouldReopen: |
2178 if shouldReopen: |
2179 res = E5MessageBox.yesNo( |
2179 res = EricMessageBox.yesNo( |
2180 None, |
2180 None, |
2181 self.tr("Pull Changes"), |
2181 self.tr("Pull Changes"), |
2182 self.tr( |
2182 self.tr( |
2183 """The project should be reread. Do this now?"""), |
2183 """The project should be reread. Do this now?"""), |
2184 yesDefault=True) |
2184 yesDefault=True) |
2185 if res: |
2185 if res: |
2186 e5App().getObject("Project").reopenProject() |
2186 ericApp().getObject("Project").reopenProject() |
2187 return |
2187 return |
2188 |
2188 |
2189 if refresh: |
2189 if refresh: |
2190 self.on_refreshButton_clicked(addNext=addNext) |
2190 self.on_refreshButton_clicked(addNext=addNext) |
2191 |
2191 |
2220 if not itm.data(0, self.__incomingRole): |
2220 if not itm.data(0, self.__incomingRole): |
2221 rev = itm.text(self.RevisionColumn).strip().split(":", 1)[1] |
2221 rev = itm.text(self.RevisionColumn).strip().split(":", 1)[1] |
2222 shouldReopen = self.vcs.getExtensionObject("strip").hgStrip( |
2222 shouldReopen = self.vcs.getExtensionObject("strip").hgStrip( |
2223 rev=rev) |
2223 rev=rev) |
2224 if shouldReopen: |
2224 if shouldReopen: |
2225 res = E5MessageBox.yesNo( |
2225 res = EricMessageBox.yesNo( |
2226 None, |
2226 None, |
2227 self.tr("Strip Changesets"), |
2227 self.tr("Strip Changesets"), |
2228 self.tr( |
2228 self.tr( |
2229 """The project should be reread. Do this now?"""), |
2229 """The project should be reread. Do this now?"""), |
2230 yesDefault=True) |
2230 yesDefault=True) |
2231 if res: |
2231 if res: |
2232 e5App().getObject("Project").reopenProject() |
2232 ericApp().getObject("Project").reopenProject() |
2233 return |
2233 return |
2234 |
2234 |
2235 self.on_refreshButton_clicked() |
2235 self.on_refreshButton_clicked() |
2236 |
2236 |
2237 @pyqtSlot() |
2237 @pyqtSlot() |
2308 Private slot to apply the currently previewed bundle file. |
2308 Private slot to apply the currently previewed bundle file. |
2309 """ |
2309 """ |
2310 if self.initialCommandMode == "incoming" and bool(self.__bundle): |
2310 if self.initialCommandMode == "incoming" and bool(self.__bundle): |
2311 shouldReopen = self.vcs.hgUnbundle(files=[self.__bundle]) |
2311 shouldReopen = self.vcs.hgUnbundle(files=[self.__bundle]) |
2312 if shouldReopen: |
2312 if shouldReopen: |
2313 res = E5MessageBox.yesNo( |
2313 res = EricMessageBox.yesNo( |
2314 None, |
2314 None, |
2315 self.tr("Apply Changegroup"), |
2315 self.tr("Apply Changegroup"), |
2316 self.tr("""The project should be reread. Do this now?"""), |
2316 self.tr("""The project should be reread. Do this now?"""), |
2317 yesDefault=True) |
2317 yesDefault=True) |
2318 if res: |
2318 if res: |
2319 e5App().getObject("Project").reopenProject() |
2319 ericApp().getObject("Project").reopenProject() |
2320 return |
2320 return |
2321 |
2321 |
2322 self.vcs.vcsLogBrowser() |
2322 self.vcs.vcsLogBrowser() |
2323 self.close() |
2323 self.close() |
2324 |
2324 |
2449 txt = topItem.text(fieldIndex) |
2449 txt = topItem.text(fieldIndex) |
2450 if searchRx.search(txt) is not None: |
2450 if searchRx.search(txt) is not None: |
2451 self.logTree.setCurrentItem(self.logTree.topLevelItem(index)) |
2451 self.logTree.setCurrentItem(self.logTree.topLevelItem(index)) |
2452 break |
2452 break |
2453 else: |
2453 else: |
2454 E5MessageBox.information( |
2454 EricMessageBox.information( |
2455 self, |
2455 self, |
2456 self.tr("Find Commit"), |
2456 self.tr("Find Commit"), |
2457 self.tr("""'{0}' was not found.""").format(self.rxEdit.text())) |
2457 self.tr("""'{0}' was not found.""").format(self.rxEdit.text())) |
2458 |
2458 |
2459 def __revisionClicked(self, url): |
2459 def __revisionClicked(self, url): |
2651 if fname != '.': |
2651 if fname != '.': |
2652 fname = "{0}.diff".format(self.__filename) |
2652 fname = "{0}.diff".format(self.__filename) |
2653 else: |
2653 else: |
2654 fname = dname |
2654 fname = dname |
2655 |
2655 |
2656 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
2656 fname, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( |
2657 self, |
2657 self, |
2658 self.tr("Save Diff"), |
2658 self.tr("Save Diff"), |
2659 fname, |
2659 fname, |
2660 self.tr("Patch Files (*.diff)"), |
2660 self.tr("Patch Files (*.diff)"), |
2661 None, |
2661 None, |
2662 E5FileDialog.DontConfirmOverwrite) |
2662 EricFileDialog.DontConfirmOverwrite) |
2663 |
2663 |
2664 if not fname: |
2664 if not fname: |
2665 return # user aborted |
2665 return # user aborted |
2666 |
2666 |
2667 ext = QFileInfo(fname).suffix() |
2667 ext = QFileInfo(fname).suffix() |
2668 if not ext: |
2668 if not ext: |
2669 ex = selectedFilter.split("(*")[1].split(")")[0] |
2669 ex = selectedFilter.split("(*")[1].split(")")[0] |
2670 if ex: |
2670 if ex: |
2671 fname += ex |
2671 fname += ex |
2672 if QFileInfo(fname).exists(): |
2672 if QFileInfo(fname).exists(): |
2673 res = E5MessageBox.yesNo( |
2673 res = EricMessageBox.yesNo( |
2674 self, |
2674 self, |
2675 self.tr("Save Diff"), |
2675 self.tr("Save Diff"), |
2676 self.tr("<p>The patch file <b>{0}</b> already exists." |
2676 self.tr("<p>The patch file <b>{0}</b> already exists." |
2677 " Overwrite it?</p>").format(fname), |
2677 " Overwrite it?</p>").format(fname), |
2678 icon=E5MessageBox.Warning) |
2678 icon=EricMessageBox.Warning) |
2679 if not res: |
2679 if not res: |
2680 return |
2680 return |
2681 fname = Utilities.toNativeSeparators(fname) |
2681 fname = Utilities.toNativeSeparators(fname) |
2682 |
2682 |
2683 eol = e5App().getObject("Project").getEolString() |
2683 eol = ericApp().getObject("Project").getEolString() |
2684 try: |
2684 try: |
2685 with open(fname, "w", encoding="utf-8", newline="") as f: |
2685 with open(fname, "w", encoding="utf-8", newline="") as f: |
2686 f.write(eol.join(self.diffEdit.toPlainText().splitlines())) |
2686 f.write(eol.join(self.diffEdit.toPlainText().splitlines())) |
2687 except OSError as why: |
2687 except OSError as why: |
2688 E5MessageBox.critical( |
2688 EricMessageBox.critical( |
2689 self, self.tr('Save Diff'), |
2689 self, self.tr('Save Diff'), |
2690 self.tr( |
2690 self.tr( |
2691 '<p>The patch file <b>{0}</b> could not be saved.' |
2691 '<p>The patch file <b>{0}</b> could not be saved.' |
2692 '<br>Reason: {1}</p>') |
2692 '<br>Reason: {1}</p>') |
2693 .format(fname, str(why))) |
2693 .format(fname, str(why))) |