Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py

changeset 3185
d4fa462547bc
parent 3160
209a07d7e401
child 3190
a9a94491c4fd
equal deleted inserted replaced
3182:a4ce50816cba 3185:d4fa462547bc
11 11
12 from PyQt4.QtCore import pyqtSlot, Qt, QDate, QProcess, QTimer, QRegExp, \ 12 from PyQt4.QtCore import pyqtSlot, Qt, QDate, QProcess, QTimer, QRegExp, \
13 QSize, QPoint 13 QSize, QPoint
14 from PyQt4.QtGui import QDialog, QDialogButtonBox, QHeaderView, \ 14 from PyQt4.QtGui import QDialog, QDialogButtonBox, QHeaderView, \
15 QTreeWidgetItem, QApplication, QCursor, QLineEdit, QColor, \ 15 QTreeWidgetItem, QApplication, QCursor, QLineEdit, QColor, \
16 QPixmap, QPainter, QPen, QBrush, QIcon 16 QPixmap, QPainter, QPen, QBrush, QIcon, QMenu
17 17
18 from E5Gui.E5Application import e5App 18 from E5Gui.E5Application import e5App
19 from E5Gui import E5MessageBox 19 from E5Gui import E5MessageBox
20 20
21 from .Ui_HgLogBrowserDialog import Ui_HgLogBrowserDialog 21 from .Ui_HgLogBrowserDialog import Ui_HgLogBrowserDialog
22 22
23 import Preferences 23 import Preferences
24 import UI.PixmapCache
24 25
25 COLORNAMES = ["blue", "darkgreen", "red", "green", "darkblue", "purple", 26 COLORNAMES = ["blue", "darkgreen", "red", "green", "darkblue", "purple",
26 "cyan", "olive", "magenta", "darkred", "darkmagenta", 27 "cyan", "olive", "magenta", "darkred", "darkmagenta",
27 "darkcyan", "gray", "yellow"] 28 "darkcyan", "gray", "yellow"]
28 COLORS = [str(QColor(x).name()) for x in COLORNAMES] 29 COLORS = [str(QColor(x).name()) for x in COLORNAMES]
132 if self.vcs.version >= (1, 8): 133 if self.vcs.version >= (1, 8):
133 self.logTree.headerItem().setText( 134 self.logTree.headerItem().setText(
134 self.logTree.columnCount(), self.trUtf8("Bookmarks")) 135 self.logTree.columnCount(), self.trUtf8("Bookmarks"))
135 if self.vcs.version < (2, 1): 136 if self.vcs.version < (2, 1):
136 self.logTree.setColumnHidden(self.PhaseColumn, True) 137 self.logTree.setColumnHidden(self.PhaseColumn, True)
137 self.phaseLine.hide() 138
138 self.phaseButton.hide() 139 self.__actionsMenu = QMenu()
139 if self.vcs.version < (2, 0): 140 if self.vcs.version >= (2, 0):
140 self.graftButton.setEnabled(False) 141 self.__graftAct = self.__actionsMenu.addAction(
141 self.graftButton.hide() 142 self.trUtf8("Copy Changesets"), self.__graftActTriggered)
142 if self.phaseButton.isHidden() and \ 143 self.__graftAct.setToolTip(self.trUtf8(
143 self.graftButton.isHidden(): 144 "Copy the selected changesets to the current branch"))
144 self.phaseLine.hide() 145 else:
146 self.__graftAct = None
147 if self.vcs.version >= (2, 1):
148 self.__phaseAct = self.__actionsMenu.addAction(
149 self.trUtf8("Change Phase"), self.__phaseActTriggered)
150 self.__phaseAct.setToolTip(self.trUtf8(
151 "Change the phase of the selected revisions"))
152 self.__phaseAct.setWhatsThis(self.trUtf8(
153 """<b>Change Phase</b>\n<p>This changes the phase of the"""
154 """ selected revisions. The selected revisions have to have"""
155 """ the same current phase.</p>"""))
156 else:
157 self.__phaseAct = None
158 self.__tagAct = self.__actionsMenu.addAction(
159 self.trUtf8("Tag"), self.__tagActTriggered)
160 self.__tagAct.setToolTip(self.trUtf8("Tag the selected revision"))
161 self.actionsButton.setIcon(
162 UI.PixmapCache.getIcon("actionsToolButton.png"))
163 self.actionsButton.setMenu(self.__actionsMenu)
145 164
146 def __initData(self): 165 def __initData(self):
147 """ 166 """
148 Private method to (re-)initialize some data. 167 Private method to (re-)initialize some data.
149 """ 168 """
918 937
919 self.__filterLogsEnabled = True 938 self.__filterLogsEnabled = True
920 self.__filterLogs() 939 self.__filterLogs()
921 940
922 self.__updateDiffButtons() 941 self.__updateDiffButtons()
923 self.__updatePhaseButton() 942 self.__updatePhaseAction()
924 self.__updateGraftButton() 943 self.__updateGraftAction()
925 944
926 def __readStdout(self): 945 def __readStdout(self):
927 """ 946 """
928 Private slot to handle the readyReadStandardOutput signal. 947 Private slot to handle the readyReadStandardOutput signal.
929 948
1019 self.diffP1Button.setEnabled(False) 1038 self.diffP1Button.setEnabled(False)
1020 self.diffP2Button.setEnabled(False) 1039 self.diffP2Button.setEnabled(False)
1021 1040
1022 self.diffRevisionsButton.setEnabled(False) 1041 self.diffRevisionsButton.setEnabled(False)
1023 1042
1024 def __updatePhaseButton(self): 1043 def __updatePhaseAction(self):
1025 """ 1044 """
1026 Private slot to update the status of the phase button. 1045 Private slot to update the status of the phase button.
1027 """ 1046 """
1028 if self.initialCommandMode == "log": 1047 if self.initialCommandMode == "log":
1029 # step 1: count entries with changeable phases 1048 # step 1: count entries with changeable phases
1041 1060
1042 # step 2: set the status of the phase button 1061 # step 2: set the status of the phase button
1043 if public == 0 and \ 1062 if public == 0 and \
1044 ((secret > 0 and draft == 0) or 1063 ((secret > 0 and draft == 0) or
1045 (secret == 0 and draft > 0)): 1064 (secret == 0 and draft > 0)):
1046 self.phaseButton.setEnabled(True) 1065 self.__phaseAct.setEnabled(True)
1047 else: 1066 else:
1048 self.phaseButton.setEnabled(False) 1067 self.__phaseAct.setEnabled(False)
1049 else: 1068 else:
1050 self.phaseButton.setEnabled(False) 1069 self.__phaseAct.setEnabled(False)
1051 1070
1052 def __updateGraftButton(self): 1071 def __updateGraftAction(self):
1053 """ 1072 """
1054 Private slot to update the status of the graft button. 1073 Private slot to update the status of the graft button.
1055 """ 1074 """
1056 if self.graftButton.isVisible(): 1075 if self.__graftAct is not None:
1057 if self.initialCommandMode == "log": 1076 if self.initialCommandMode == "log":
1058 # step 1: count selected entries not belonging to the 1077 # step 1: count selected entries not belonging to the
1059 # current branch 1078 # current branch
1060 otherBranches = 0 1079 otherBranches = 0
1061 for itm in self.logTree.selectedItems(): 1080 for itm in self.logTree.selectedItems():
1062 branch = itm.text(self.BranchColumn) 1081 branch = itm.text(self.BranchColumn)
1063 if branch != self.__projectBranch: 1082 if branch != self.__projectBranch:
1064 otherBranches += 1 1083 otherBranches += 1
1065 1084
1066 # step 2: set the status of the graft button 1085 # step 2: set the status of the graft action
1067 self.graftButton.setEnabled(otherBranches > 0) 1086 self.__graftAct.setEnabled(otherBranches > 0)
1068 else: 1087 else:
1069 self.graftButton.setEnabled(False) 1088 self.__graftAct.setEnabled(False)
1070 1089
1071 def __updateGui(self, itm): 1090 def __updateGui(self, itm):
1072 """ 1091 """
1073 Private slot to update GUI elements except the diff and phase buttons. 1092 Private slot to update GUI elements except the diff and phase buttons.
1074 1093
1098 @param current reference to the new current item (QTreeWidgetItem) 1117 @param current reference to the new current item (QTreeWidgetItem)
1099 @param previous reference to the old current item (QTreeWidgetItem) 1118 @param previous reference to the old current item (QTreeWidgetItem)
1100 """ 1119 """
1101 self.__updateGui(current) 1120 self.__updateGui(current)
1102 self.__updateDiffButtons() 1121 self.__updateDiffButtons()
1103 self.__updatePhaseButton() 1122 self.__updatePhaseAction()
1104 self.__updateGraftButton() 1123 self.__updateGraftAction()
1105 1124
1106 @pyqtSlot() 1125 @pyqtSlot()
1107 def on_logTree_itemSelectionChanged(self): 1126 def on_logTree_itemSelectionChanged(self):
1108 """ 1127 """
1109 Private slot called, when the selection has changed. 1128 Private slot called, when the selection has changed.
1110 """ 1129 """
1111 if len(self.logTree.selectedItems()) == 1: 1130 if len(self.logTree.selectedItems()) == 1:
1112 self.__updateGui(self.logTree.selectedItems()[0]) 1131 self.__updateGui(self.logTree.selectedItems()[0])
1132 self.__tagAct.setEnabled(True)
1133 else:
1134 self.__tagAct.setEnabled(False)
1113 1135
1114 self.__updateDiffButtons() 1136 self.__updateDiffButtons()
1115 self.__updatePhaseButton() 1137 self.__updatePhaseAction()
1116 self.__updateGraftButton() 1138 self.__updateGraftAction()
1117 1139
1118 @pyqtSlot() 1140 @pyqtSlot()
1119 def on_nextButton_clicked(self): 1141 def on_nextButton_clicked(self):
1120 """ 1142 """
1121 Private slot to handle the Next button. 1143 Private slot to handle the Next button.
1346 evt.accept() 1368 evt.accept()
1347 return 1369 return
1348 super().keyPressEvent(evt) 1370 super().keyPressEvent(evt)
1349 1371
1350 @pyqtSlot() 1372 @pyqtSlot()
1351 def on_phaseButton_clicked(self): 1373 def __phaseActTriggered(self):
1352 """ 1374 """
1353 Private slot to handle the Change Phase button. 1375 Private slot to handle the Change Phase action.
1354 """ 1376 """
1355 currentPhase = self.logTree.selectedItems()[0].text(self.PhaseColumn) 1377 currentPhase = self.logTree.selectedItems()[0].text(self.PhaseColumn)
1356 revs = [] 1378 revs = []
1357 for itm in self.logTree.selectedItems(): 1379 for itm in self.logTree.selectedItems():
1358 if itm.text(self.PhaseColumn) == currentPhase: 1380 if itm.text(self.PhaseColumn) == currentPhase:
1359 revs.append( 1381 revs.append(
1360 itm.text(self.RevisionColumn).split(":")[0].strip()) 1382 itm.text(self.RevisionColumn).split(":")[0].strip())
1361 1383
1362 if not revs: 1384 if not revs:
1363 self.phaseButton.setEnabled(False) 1385 self.__phaseAct.setEnabled(False)
1364 return 1386 return
1365 1387
1366 if currentPhase == "draft": 1388 if currentPhase == "draft":
1367 newPhase = "secret" 1389 newPhase = "secret"
1368 data = (revs, "s", True) 1390 data = (revs, "s", True)
1373 if res: 1395 if res:
1374 for itm in self.logTree.selectedItems(): 1396 for itm in self.logTree.selectedItems():
1375 itm.setText(self.PhaseColumn, newPhase) 1397 itm.setText(self.PhaseColumn, newPhase)
1376 1398
1377 @pyqtSlot() 1399 @pyqtSlot()
1378 def on_graftButton_clicked(self): 1400 def __graftActTriggered(self):
1379 """ 1401 """
1380 Private slot to handle the Copy Changesets button. 1402 Private slot to handle the Copy Changesets action.
1381 """ 1403 """
1382 revs = [] 1404 revs = []
1383 1405
1384 for itm in self.logTree.selectedItems(): 1406 for itm in self.logTree.selectedItems():
1385 branch = itm.text(self.BranchColumn) 1407 branch = itm.text(self.BranchColumn)
1398 yesDefault=True) 1420 yesDefault=True)
1399 if res: 1421 if res:
1400 e5App().getObject("Project").reopenProject() 1422 e5App().getObject("Project").reopenProject()
1401 else: 1423 else:
1402 self.on_refreshButton_clicked() 1424 self.on_refreshButton_clicked()
1425
1426 @pyqtSlot()
1427 def __tagActTriggered(self):
1428 """
1429 Private slot to tag the selected revision.
1430 """
1431 if len(self.logTree.selectedItems()):
1432 itm = self.logTree.selectedItems()[0]
1433 rev = itm.text(self.RevisionColumn).strip().split(":", 1)[0]
1434 tag = itm.text(self.TagsColumn).strip().split(", ", 1)[0]
1435 res = self.vcs.vcsTag(self.repodir, revision=rev, tagName=tag)
1436 if res:
1437 self.on_refreshButton_clicked()

eric ide

mercurial