eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py

changeset 7010
5d6f5a69a952
parent 7009
eaf5ed6ef298
child 7032
1dd0c392f685
equal deleted inserted replaced
7009:eaf5ed6ef298 7010:5d6f5a69a952
291 self.__tagAct = self.__actionsMenu.addAction( 291 self.__tagAct = self.__actionsMenu.addAction(
292 UI.PixmapCache.getIcon("vcsTag.png"), self.tr("Tag"), 292 UI.PixmapCache.getIcon("vcsTag.png"), self.tr("Tag"),
293 self.__tagActTriggered) 293 self.__tagActTriggered)
294 self.__tagAct.setToolTip(self.tr("Tag the selected revision")) 294 self.__tagAct.setToolTip(self.tr("Tag the selected revision"))
295 295
296 self.__closeHeadsAct = self.__actionsMenu.addAction(
297 UI.PixmapCache.getIcon("closehead"), self.tr("Close Heads"),
298 self.__closeHeadsActTriggered)
299 self.__closeHeadsAct.setToolTip(self.tr("Close the selected heads"))
300
296 self.__switchAct = self.__actionsMenu.addAction( 301 self.__switchAct = self.__actionsMenu.addAction(
297 UI.PixmapCache.getIcon("vcsSwitch.png"), self.tr("Switch"), 302 UI.PixmapCache.getIcon("vcsSwitch.png"), self.tr("Switch"),
298 self.__switchActTriggered) 303 self.__switchActTriggered)
299 self.__switchAct.setToolTip(self.tr( 304 self.__switchAct.setToolTip(self.tr(
300 "Switch the working directory to the selected revision")) 305 "Switch the working directory to the selected revision"))
876 for line in output.splitlines(): 881 for line in output.splitlines():
877 if line.strip().endswith("(closed)"): 882 if line.strip().endswith("(closed)"):
878 parts = line.split() 883 parts = line.split()
879 self.__closedBranchesRevs.append( 884 self.__closedBranchesRevs.append(
880 parts[-2].split(":", 1)[0]) 885 parts[-2].split(":", 1)[0])
886
887 def __getHeads(self):
888 """
889 Private method to get the list of all heads.
890 """
891 self.__headRevisions = []
892 errMsg = ""
893
894 args = self.vcs.initCommand("heads")
895 args.append("--closed")
896 args.append("--template")
897 args.append("{rev}\n")
898
899 output = ""
900 if self.__hgClient:
901 output, errMsg = self.__hgClient.runcommand(args)
902 else:
903 process = QProcess()
904 process.setWorkingDirectory(self.repodir)
905 process.start('hg', args)
906 procStarted = process.waitForStarted(5000)
907 if procStarted:
908 finished = process.waitForFinished(30000)
909 if finished and process.exitCode() == 0:
910 output = str(process.readAllStandardOutput(),
911 self.vcs.getEncoding(), 'replace')
912 else:
913 if not finished:
914 errMsg = self.tr(
915 "The hg process did not finish within 30s.")
916 else:
917 errMsg = self.tr("Could not start the hg executable.")
918
919 if errMsg:
920 E5MessageBox.critical(
921 self,
922 self.tr("Mercurial Error"),
923 errMsg)
924
925 if output:
926 for line in output.splitlines():
927 line = line.strip()
928 if line:
929 self.__headRevisions.append(line)
881 930
882 def __getRevisionOfTag(self, tag): 931 def __getRevisionOfTag(self, tag):
883 """ 932 """
884 Private method to get the revision of a tag. 933 Private method to get the revision of a tag.
885 934
1202 1251
1203 self.logTree.clear() 1252 self.logTree.clear()
1204 self.__started = True 1253 self.__started = True
1205 self.__identifyProject() 1254 self.__identifyProject()
1206 self.__getClosedBranches() 1255 self.__getClosedBranches()
1256 self.__getHeads()
1207 self.__getLogEntries(noEntries=noEntries) 1257 self.__getLogEntries(noEntries=noEntries)
1208 1258
1209 def __procFinished(self, exitCode, exitStatus): 1259 def __procFinished(self, exitCode, exitStatus):
1210 """ 1260 """
1211 Private slot connected to the finished signal. 1261 Private slot connected to the finished signal.
1631 selectedItemsCount > 0) 1681 selectedItemsCount > 0)
1632 self.__gpgVerifyAct.setEnabled( 1682 self.__gpgVerifyAct.setEnabled(
1633 self.vcs.isExtensionActive("gpg") and 1683 self.vcs.isExtensionActive("gpg") and
1634 selectedItemsCount == 1) 1684 selectedItemsCount == 1)
1635 1685
1686 if self.vcs.isExtensionActive("closehead"):
1687 revs = [itm.text(self.RevisionColumn).strip().split(":", 1)[0]
1688 for itm in self.logTree.selectedItems()
1689 if not itm.data(0, self.__incomingRole)]
1690 revs = [rev for rev in revs if rev in self.__headRevisions]
1691 self.__closeHeadsAct.setEnabled(len(revs) > 0)
1692 else:
1693 self.__closeHeadsAct.setEnabled(False)
1636 self.actionsButton.setEnabled(True) 1694 self.actionsButton.setEnabled(True)
1637 1695
1638 elif self.initialCommandMode == "incoming" and self.projectMode: 1696 elif self.initialCommandMode == "incoming" and self.projectMode:
1639 for act in [self.__phaseAct, self.__graftAct, self.__mergeAct, 1697 for act in [self.__phaseAct, self.__graftAct, self.__mergeAct,
1640 self.__tagAct, self.__switchAct, self.__bookmarkAct, 1698 self.__tagAct, self.__switchAct, self.__bookmarkAct,
2194 res = self.vcs.vcsTag(self.repodir, revision=rev, tagName=tag) 2252 res = self.vcs.vcsTag(self.repodir, revision=rev, tagName=tag)
2195 if res: 2253 if res:
2196 self.on_refreshButton_clicked() 2254 self.on_refreshButton_clicked()
2197 2255
2198 @pyqtSlot() 2256 @pyqtSlot()
2257 def __closeHeadsActTriggered(self):
2258 """
2259 Private slot to close the selected head revisions.
2260 """
2261 if self.vcs.isExtensionActive("closehead"):
2262 revs = [itm.text(self.RevisionColumn).strip().split(":", 1)[0]
2263 for itm in self.logTree.selectedItems()
2264 if not itm.data(0, self.__incomingRole)]
2265 revs = [rev for rev in revs if rev in self.__headRevisions]
2266 if revs:
2267 closeheadExtension = self.vcs.getExtensionObject("closehead")
2268 if closeheadExtension is not None:
2269 closeheadExtension.hgCloseheads(
2270 self.repodir, revisions=revs)
2271
2272 self.on_refreshButton_clicked()
2273
2274 @pyqtSlot()
2199 def __switchActTriggered(self): 2275 def __switchActTriggered(self):
2200 """ 2276 """
2201 Private slot to switch the working directory to the 2277 Private slot to switch the working directory to the
2202 selected revision. 2278 selected revision.
2203 """ 2279 """

eric ide

mercurial