--- a/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Sat Feb 11 18:19:56 2017 +0100 +++ b/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Sat Feb 11 19:47:41 2017 +0100 @@ -1298,9 +1298,13 @@ if self.__started: if self.__selectedRevisions: - self.logTree.setCurrentItem(self.logTree.findItems( + foundItems = self.logTree.findItems( self.__selectedRevisions[0], Qt.MatchExactly, - self.RevisionColumn)[0]) + self.RevisionColumn) + if foundItems: + self.logTree.setCurrentItem(foundItems[0]) + else: + self.logTree.setCurrentItem(self.logTree.topLevelItem(0)) else: self.logTree.setCurrentItem(self.logTree.topLevelItem(0)) self.__started = False @@ -1443,39 +1447,39 @@ the tool menu button. """ if self.initialCommandMode == "log" and self.projectMode: - if self.__phaseAct is not None: - # step 1: count entries with changeable phases - secret = 0 - draft = 0 - public = 0 - for itm in self.logTree.selectedItems(): - phase = itm.text(self.PhaseColumn) - if phase == self.phases["draft"]: - draft += 1 - elif phase == self.phases["secret"]: - secret += 1 - else: - public += 1 - - # step 2: set the status of the phase action - if public == 0 and \ - ((secret > 0 and draft == 0) or - (secret == 0 and draft > 0)): - self.__phaseAct.setEnabled(True) + # do the phase action + # step 1: count entries with changeable phases + secret = 0 + draft = 0 + public = 0 + for itm in self.logTree.selectedItems(): + phase = itm.text(self.PhaseColumn) + if phase == self.phases["draft"]: + draft += 1 + elif phase == self.phases["secret"]: + secret += 1 else: - self.__phaseAct.setEnabled(False) + public += 1 + + # step 2: set the status of the phase action + if public == 0 and \ + ((secret > 0 and draft == 0) or + (secret == 0 and draft > 0)): + self.__phaseAct.setEnabled(True) + else: + self.__phaseAct.setEnabled(False) - if self.__graftAct is not None: - # step 1: count selected entries not belonging to the - # current branch - otherBranches = 0 - for itm in self.logTree.selectedItems(): - branch = itm.text(self.BranchColumn) - if branch != self.__projectBranch: - otherBranches += 1 - - # step 2: set the status of the graft action - self.__graftAct.setEnabled(otherBranches > 0) + # do the graft action + # step 1: count selected entries not belonging to the + # current branch + otherBranches = 0 + for itm in self.logTree.selectedItems(): + branch = itm.text(self.BranchColumn) + if branch != self.__projectBranch: + otherBranches += 1 + + # step 2: set the status of the graft action + self.__graftAct.setEnabled(otherBranches > 0) selectedItemsCount = len(self.logTree.selectedItems()) self.__mergeAct.setEnabled(selectedItemsCount == 1) @@ -1484,6 +1488,8 @@ self.__bookmarkAct.setEnabled(selectedItemsCount == 1) self.__bookmarkMoveAct.setEnabled(selectedItemsCount == 1) + self.__pullAct.setText(self.tr("Pull Changes")) + self.__fetchAct.setText(self.tr("Fetch Changes")) if self.vcs.canPull(): self.__pullAct.setEnabled(True) self.__lfPullAct.setEnabled( @@ -1520,6 +1526,37 @@ selectedItemsCount == 1) self.actionsButton.setEnabled(True) + elif self.initialCommandMode == "incoming" and self.projectMode: + for act in [self.__phaseAct, self.__graftAct, self.__mergeAct, + self.__tagAct, self.__switchAct, self.__bookmarkAct, + self.__bookmarkMoveAct, self.__pushAct, + self.__pushAllAct, self.__stripAct, self.__bundleAct, + self.__gpgSignAct, self.__gpgVerifyAct]: + act.setEnabled(False) + + self.__pullAct.setText(self.tr("Pull Selected Changes")) + self.__fetchAct.setText(self.tr("Fetch Selected Changes")) + if self.vcs.canPull(): + # step 1: determine number of selected draft changesets + # i.e. those that can be pulled + selectedDraftItemsCount = 0 + for itm in self.logTree.selectedItems(): + phase = itm.text(self.PhaseColumn) + if phase == self.phases["draft"]: + selectedDraftItemsCount += 1 + self.__pullAct.setEnabled(selectedDraftItemsCount > 0) + self.__lfPullAct.setEnabled( + self.vcs.isExtensionActive("largefiles") and + selectedItemsCount > 0) + self.__fetchAct.setEnabled( + self.vcs.isExtensionActive("fetch") and + selectedDraftItemsCount > 0) + else: + self.__pullAct.setEnabled(False) + self.__lfPullAct.setEnabled(False) + self.__fetchAct.setEnabled(False) + + self.actionsButton.setEnabled(True) else: self.actionsButton.setEnabled(False) # TODO: add code to enable menu in incoming / outgoing mode as well @@ -2110,8 +2147,24 @@ """ Private slot to fetch changes from a remote repository. """ - shouldReopen = self.vcs.getExtensionObject("fetch").hgFetch( - self.repodir) + shouldReopen = False + refresh = False + + if self.initialCommandMode == "log": + shouldReopen = self.vcs.getExtensionObject("fetch").hgFetch( + self.repodir) + refresh = True + elif self.initialCommandMode == "incoming": + revs = [] + for itm in self.logTree.selectedItems(): + rev = itm.text(self.RevisionColumn).split(":")[1].strip() + phase = itm.text(self.PhaseColumn).strip() + if rev and phase == self.phases["draft"]: + revs.append(rev) + if revs: + shouldReopen = self.vcs.getExtensionObject("fetch").hgFetch( + self.repodir, ) + refresh = True if shouldReopen: res = E5MessageBox.yesNo( None, @@ -2123,14 +2176,31 @@ e5App().getObject("Project").reopenProject() return - self.on_refreshButton_clicked() + if refresh: + self.on_refreshButton_clicked() @pyqtSlot() def __pullActTriggered(self): """ Private slot to pull changes from a remote repository. """ - shouldReopen = self.vcs.hgPull(self.repodir) + shouldReopen = False + refresh = False + + if self.initialCommandMode == "log": + shouldReopen = self.vcs.hgPull(self.repodir) + refresh = True + elif self.initialCommandMode == "incoming": + revs = [] + for itm in self.logTree.selectedItems(): + rev = itm.text(self.RevisionColumn).split(":")[1].strip() + phase = itm.text(self.PhaseColumn).strip() + if rev and phase == self.phases["draft"]: + revs.append(rev) + if revs: + shouldReopen = self.vcs.hgPull(self.repodir, revisions=revs) + refresh = True + if shouldReopen: res = E5MessageBox.yesNo( None, @@ -2142,7 +2212,8 @@ e5App().getObject("Project").reopenProject() return - self.on_refreshButton_clicked() + if refresh: + self.on_refreshButton_clicked() @pyqtSlot() def __pushActTriggered(self):