eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py

changeset 7771
787a6b3f8c9f
parent 7679
5816200f021b
child 7775
4a1db75550bd
equal deleted inserted replaced
7770:49f3377aebf1 7771:787a6b3f8c9f
11 import re 11 import re
12 import collections 12 import collections
13 13
14 from PyQt5.QtCore import pyqtSlot, Qt, QDate, QRegExp, QSize, QPoint, QFileInfo 14 from PyQt5.QtCore import pyqtSlot, Qt, QDate, QRegExp, QSize, QPoint, QFileInfo
15 from PyQt5.QtGui import ( 15 from PyQt5.QtGui import (
16 QCursor, QColor, QPixmap, QPainter, QPen, QBrush, QIcon, QTextCursor, 16 QColor, QPixmap, QPainter, QPen, QBrush, QIcon, QTextCursor, QPalette
17 QPalette
18 ) 17 )
19 from PyQt5.QtWidgets import ( 18 from PyQt5.QtWidgets import (
20 QWidget, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QApplication, 19 QWidget, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QApplication,
21 QLineEdit, QMenu, QInputDialog 20 QLineEdit, QMenu, QInputDialog
22 ) 21 )
23 22
24 from E5Gui.E5Application import e5App 23 from E5Gui.E5Application import e5App
25 from E5Gui import E5MessageBox, E5FileDialog 24 from E5Gui import E5MessageBox, E5FileDialog
25 from E5Gui.E5OverrideCursor import E5OverrideCursor
26 26
27 from .Ui_HgLogBrowserDialog import Ui_HgLogBrowserDialog 27 from .Ui_HgLogBrowserDialog import Ui_HgLogBrowserDialog
28 28
29 from .HgDiffHighlighter import HgDiffHighlighter 29 from .HgDiffHighlighter import HgDiffHighlighter
30 from .HgDiffGenerator import HgDiffGenerator 30 from .HgDiffGenerator import HgDiffGenerator
966 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 966 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
967 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 967 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
968 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 968 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
969 QApplication.processEvents() 969 QApplication.processEvents()
970 970
971 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) 971 with E5OverrideCursor():
972 QApplication.processEvents() 972 self.buf = []
973 973 self.cancelled = False
974 self.buf = [] 974 self.errors.clear()
975 self.cancelled = False 975 self.intercept = False
976 self.errors.clear() 976
977 self.intercept = False 977 if noEntries == 0:
978 978 noEntries = self.limitSpinBox.value()
979 if noEntries == 0: 979
980 noEntries = self.limitSpinBox.value() 980 preargs = []
981 981 args = self.vcs.initCommand(self.commandMode)
982 preargs = [] 982 args.append('--verbose')
983 args = self.vcs.initCommand(self.commandMode) 983 if self.commandMode not in ("incoming", "outgoing"):
984 args.append('--verbose') 984 args.append('--limit')
985 if self.commandMode not in ("incoming", "outgoing"): 985 args.append(str(noEntries))
986 args.append('--limit') 986 if self.commandMode in ("incoming", "outgoing"):
987 args.append(str(noEntries)) 987 args.append("--newest-first")
988 if self.commandMode in ("incoming", "outgoing"): 988 if self.vcs.hasSubrepositories():
989 args.append("--newest-first") 989 args.append("--subrepos")
990 if self.vcs.hasSubrepositories(): 990 if startRev is not None:
991 args.append("--subrepos") 991 args.append('--rev')
992 if startRev is not None: 992 args.append('{0}:0'.format(startRev))
993 args.append('--rev')
994 args.append('{0}:0'.format(startRev))
995 if (
996 not self.projectMode and
997 not self.fname == "." and
998 not self.stopCheckBox.isChecked()
999 ):
1000 args.append('--follow')
1001 if self.commandMode == "log":
1002 args.append('--copies')
1003 args.append('--template')
1004 args.append(os.path.join(os.path.dirname(__file__),
1005 "templates",
1006 "logBrowserBookmarkPhase.tmpl"))
1007 if self.commandMode == "incoming":
1008 if self.__bundle:
1009 args.append(self.__bundle)
1010 elif not self.vcs.hasSubrepositories():
1011 project = e5App().getObject("Project")
1012 self.vcs.bundleFile = os.path.join(
1013 project.getProjectManagementDir(), "hg-bundle.hg")
1014 if os.path.exists(self.vcs.bundleFile):
1015 os.remove(self.vcs.bundleFile)
1016 preargs = args[:]
1017 preargs.append("--quiet")
1018 preargs.append('--bundle')
1019 preargs.append(self.vcs.bundleFile)
1020 args.append(self.vcs.bundleFile)
1021 if not self.projectMode:
1022 args.append(self.__filename)
1023
1024 if preargs:
1025 out, err = self.__hgClient.runcommand(preargs)
1026 else:
1027 err = ""
1028 if err:
1029 if ( 993 if (
994 not self.projectMode and
995 not self.fname == "." and
996 not self.stopCheckBox.isChecked()
997 ):
998 args.append('--follow')
999 if self.commandMode == "log":
1000 args.append('--copies')
1001 args.append('--template')
1002 args.append(os.path.join(os.path.dirname(__file__),
1003 "templates",
1004 "logBrowserBookmarkPhase.tmpl"))
1005 if self.commandMode == "incoming":
1006 if self.__bundle:
1007 args.append(self.__bundle)
1008 elif not self.vcs.hasSubrepositories():
1009 project = e5App().getObject("Project")
1010 self.vcs.bundleFile = os.path.join(
1011 project.getProjectManagementDir(), "hg-bundle.hg")
1012 if os.path.exists(self.vcs.bundleFile):
1013 os.remove(self.vcs.bundleFile)
1014 preargs = args[:]
1015 preargs.append("--quiet")
1016 preargs.append('--bundle')
1017 preargs.append(self.vcs.bundleFile)
1018 args.append(self.vcs.bundleFile)
1019 if not self.projectMode:
1020 args.append(self.__filename)
1021
1022 if preargs:
1023 out, err = self.__hgClient.runcommand(preargs)
1024 else:
1025 err = ""
1026 if err:
1027 if (
1028 self.commandMode == "incoming" and
1029 self.initialCommandMode == "full_log"
1030 ):
1031 # ignore the error
1032 self.commandMode = "log"
1033 else:
1034 self.__showError(err)
1035 elif (
1036 self.commandMode != "incoming" or
1037 (self.vcs.bundleFile and
1038 os.path.exists(self.vcs.bundleFile)) or
1039 self.__bundle
1040 ):
1041 out, err = self.__hgClient.runcommand(args)
1042 self.buf = out.splitlines(True)
1043 if err:
1044 self.__showError(err)
1045 self.__processBuffer()
1046 elif (
1030 self.commandMode == "incoming" and 1047 self.commandMode == "incoming" and
1031 self.initialCommandMode == "full_log" 1048 self.initialCommandMode == "full_log"
1032 ): 1049 ):
1033 # ignore the error 1050 # no incoming changesets, just switch to log mode
1034 self.commandMode = "log" 1051 self.commandMode = "log"
1035 else:
1036 self.__showError(err)
1037 elif (
1038 self.commandMode != "incoming" or
1039 (self.vcs.bundleFile and
1040 os.path.exists(self.vcs.bundleFile)) or
1041 self.__bundle
1042 ):
1043 out, err = self.__hgClient.runcommand(args)
1044 self.buf = out.splitlines(True)
1045 if err:
1046 self.__showError(err)
1047 self.__processBuffer()
1048 elif (
1049 self.commandMode == "incoming" and
1050 self.initialCommandMode == "full_log"
1051 ):
1052 # no incoming changesets, just switch to log mode
1053 self.commandMode = "log"
1054 self.__finish() 1052 self.__finish()
1055 1053
1056 def start(self, fn, bundle=None, isFile=False, noEntries=0): 1054 def start(self, fn, bundle=None, isFile=False, noEntries=0):
1057 """ 1055 """
1058 Public slot to start the hg log command. 1056 Public slot to start the hg log command.
1107 def __finish(self): 1105 def __finish(self):
1108 """ 1106 """
1109 Private slot called when the process finished or the user pressed 1107 Private slot called when the process finished or the user pressed
1110 the button. 1108 the button.
1111 """ 1109 """
1112 QApplication.restoreOverrideCursor()
1113
1114 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 1110 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
1115 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 1111 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
1116 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 1112 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
1117 1113
1118 self.refreshButton.setEnabled(True) 1114 self.refreshButton.setEnabled(True)

eric ide

mercurial