--- a/src/eric7/Plugins/VcsPlugins/vcsMercurial/ProjectBrowserHelper.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Plugins/VcsPlugins/vcsMercurial/ProjectBrowserHelper.py Wed Jul 13 14:55:47 2022 +0200 @@ -24,11 +24,19 @@ """ Class implementing the VCS project browser helper for Mercurial. """ - def __init__(self, vcsObject, browserObject, projectObject, - isTranslationsBrowser, parent=None, name=None): + + def __init__( + self, + vcsObject, + browserObject, + projectObject, + isTranslationsBrowser, + parent=None, + name=None, + ): """ Constructor - + @param vcsObject reference to the vcs object @param browserObject reference to the project browser object @param projectObject reference to the project object @@ -37,38 +45,44 @@ @param parent parent widget (QWidget) @param name name of this object (string) """ - VcsProjectBrowserHelper.__init__(self, vcsObject, browserObject, - projectObject, isTranslationsBrowser, - parent, name) - + VcsProjectBrowserHelper.__init__( + self, + vcsObject, + browserObject, + projectObject, + isTranslationsBrowser, + parent, + name, + ) + # instantiate the extensions - from .ShelveExtension.ProjectBrowserHelper import ( - ShelveProjectBrowserHelper + from .ShelveExtension.ProjectBrowserHelper import ShelveProjectBrowserHelper + from .LargefilesExtension.ProjectBrowserHelper import ( + LargefilesProjectBrowserHelper, ) - from .LargefilesExtension.ProjectBrowserHelper import ( - LargefilesProjectBrowserHelper - ) + self.__extensions = { "shelve": ShelveProjectBrowserHelper( - vcsObject, browserObject, projectObject), + vcsObject, browserObject, projectObject + ), "largefiles": LargefilesProjectBrowserHelper( - vcsObject, browserObject, projectObject), + vcsObject, browserObject, projectObject + ), } - + self.__extensionMenuTitles = {} for extension in self.__extensions: self.__extensionMenuTitles[ - self.__extensions[extension].menuTitle()] = extension + self.__extensions[extension].menuTitle() + ] = extension self.__extensionMenus = {} for extension in self.__extensions: - self.__extensionMenus[extension] = ( - self.__extensions[extension].initMenus() - ) - + self.__extensionMenus[extension] = self.__extensions[extension].initMenus() + def __showExtensionMenu(self, key, controlled): """ Private slot showing the extensions menu. - + @param key menu key (string, one of 'mainMenu', 'multiMenu', 'backMenu', 'dirMenu' or 'dirMultiMenu') @param controlled flag indicating to show the menu for a @@ -78,23 +92,24 @@ for extensionName in self.__extensionMenus: if key in self.__extensionMenus[extensionName]: self.__extensionMenus[extensionName][key].setEnabled( - self.vcs.isExtensionActive(extensionName)) + self.vcs.isExtensionActive(extensionName) + ) if self.__extensionMenus[extensionName][key].isEnabled(): # adjust individual extension menu entries - self.__extensions[extensionName].showExtensionMenu( - key, controlled) - if (not self.__extensionMenus[extensionName][key] - .isEnabled() and self.__extensionMenus[extensionName][key] - .isTearOffMenuVisible()): + self.__extensions[extensionName].showExtensionMenu(key, controlled) + if ( + not self.__extensionMenus[extensionName][key].isEnabled() + and self.__extensionMenus[extensionName][key].isTearOffMenuVisible() + ): self.__extensionMenus[extensionName][key].hideTearOffMenu() - + def showContextMenu(self, menu, standardItems): """ Public slot called before the context menu is shown. - + It enables/disables the VCS menu entries depending on the overall VCS status and the file status. - + @param menu reference to the menu to be shown @param standardItems array of standard items that need activation/deactivation depending on the overall VCS status @@ -107,7 +122,7 @@ act.setEnabled(False) for act in standardItems: act.setEnabled(False) - if not hasattr(self.browser.currentItem(), 'fileName'): + if not hasattr(self.browser.currentItem(), "fileName"): self.annotateAct.setEnabled(False) else: controlled = False @@ -118,15 +133,15 @@ for act in standardItems: act.setEnabled(True) self.__showExtensionMenu("mainMenu", controlled) - + def showContextMenuMulti(self, menu, standardItems): """ Public slot called before the context menu (multiple selections) is shown. - + It enables/disables the VCS menu entries depending on the overall VCS status and the files status. - + @param menu reference to the menu to be shown @param standardItems array of standard items that need activation/deactivation depending on the overall VCS status @@ -138,7 +153,7 @@ for itm in items: if itm.data(1) == vcsName: vcsItems += 1 - + if vcsItems > 0: controlled = True if vcsItems != len(items): @@ -160,14 +175,14 @@ for act in standardItems: act.setEnabled(True) self.__showExtensionMenu("multiMenu", controlled) - + def showContextMenuDir(self, menu, standardItems): """ Public slot called before the context menu is shown. - + It enables/disables the VCS menu entries depending on the overall VCS status and the directory status. - + @param menu reference to the menu to be shown @param standardItems array of standard items that need activation/deactivation depending on the overall VCS status @@ -189,14 +204,14 @@ for act in standardItems: act.setEnabled(True) self.__showExtensionMenu("dirMenu", controlled) - + def showContextMenuDirMulti(self, menu, standardItems): """ Public slot called before the context menu is shown. - + It enables/disables the VCS menu entries depending on the overall VCS status and the directory status. - + @param menu reference to the menu to be shown @param standardItems array of standard items that need activation/deactivation depending on the overall VCS status @@ -208,7 +223,7 @@ for itm in items: if itm.data(1) == vcsName: vcsItems += 1 - + if vcsItems > 0: controlled = True if vcsItems != len(items): @@ -230,456 +245,518 @@ for act in standardItems: act.setEnabled(True) self.__showExtensionMenu("dirMultiMenu", controlled) - + ########################################################################### ## Private menu generation methods below ########################################################################### - + def __addExtensionsMenu(self, menu, key): """ Private method to add an extension menu entry. - + @param menu menu to add it to (QMenu) @param key menu key (string, one of 'mainMenu', 'multiMenu', 'backMenu', 'dirMenu' or 'dirMultiMenu') @return reference to the menu action (QAction) """ act = None - if key in ['mainMenu', 'multiMenu', 'backMenu', 'dirMenu', - 'dirMultiMenu']: + if key in ["mainMenu", "multiMenu", "backMenu", "dirMenu", "dirMultiMenu"]: extensionsMenu = QMenu(self.tr("Extensions"), menu) extensionsMenu.setTearOffEnabled(True) for extensionMenuTitle in sorted(self.__extensionMenuTitles): extensionName = self.__extensionMenuTitles[extensionMenuTitle] if key in self.__extensionMenus[extensionName]: - extensionsMenu.addMenu( - self.__extensionMenus[extensionName][key]) + extensionsMenu.addMenu(self.__extensionMenus[extensionName][key]) if not extensionsMenu.isEmpty(): if not menu.isEmpty(): menu.addSeparator() act = menu.addMenu(extensionsMenu) return act - + ########################################################################### ## Protected menu generation methods below ########################################################################### - + def _addVCSMenu(self, mainMenu): """ Protected method used to add the VCS menu to all project browsers. - + @param mainMenu reference to the menu to be amended """ self.vcsMenuActions = [] self.vcsAddMenuActions = [] - + menu = QMenu(self.tr("Version Control")) - + act = menu.addAction( UI.PixmapCache.getIcon( - os.path.join("VcsPlugins", "vcsMercurial", "icons", - "mercurial.svg")), - self.vcs.vcsName(), self._VCSInfoDisplay) + os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.svg") + ), + self.vcs.vcsName(), + self._VCSInfoDisplay, + ) font = act.font() font.setBold(True) act.setFont(font) menu.addSeparator() - + act = menu.addAction( UI.PixmapCache.getIcon("vcsCommit"), - self.tr('Commit changes to repository...'), - self._VCSCommit) + self.tr("Commit changes to repository..."), + self._VCSCommit, + ) self.vcsMenuActions.append(act) - self.__addExtensionsMenu(menu, 'mainMenu') + self.__addExtensionsMenu(menu, "mainMenu") menu.addSeparator() act = menu.addAction( - UI.PixmapCache.getIcon("vcsAdd"), - self.tr('Add to repository'), - self._VCSAdd) + UI.PixmapCache.getIcon("vcsAdd"), self.tr("Add to repository"), self._VCSAdd + ) self.vcsAddMenuActions.append(act) act = menu.addAction( UI.PixmapCache.getIcon("vcsRemove"), - self.tr('Remove from repository (and disk)'), - self._VCSRemove) + self.tr("Remove from repository (and disk)"), + self._VCSRemove, + ) self.vcsMenuActions.append(act) act = menu.addAction( UI.PixmapCache.getIcon("vcsRemove"), - self.tr('Remove from repository only'), - self.__HgForget) + self.tr("Remove from repository only"), + self.__HgForget, + ) self.vcsMenuActions.append(act) menu.addSeparator() - act = menu.addAction(self.tr('Copy'), self.__HgCopy) + act = menu.addAction(self.tr("Copy"), self.__HgCopy) self.vcsMenuActions.append(act) - act = menu.addAction(self.tr('Move'), self.__HgMove) + act = menu.addAction(self.tr("Move"), self.__HgMove) self.vcsMenuActions.append(act) menu.addSeparator() act = menu.addAction( UI.PixmapCache.getIcon("vcsLog"), - self.tr('Show log browser'), self._VCSLogBrowser) + self.tr("Show log browser"), + self._VCSLogBrowser, + ) self.vcsMenuActions.append(act) menu.addSeparator() act = menu.addAction( - UI.PixmapCache.getIcon("vcsStatus"), - self.tr('Show status'), self._VCSStatus) + UI.PixmapCache.getIcon("vcsStatus"), self.tr("Show status"), self._VCSStatus + ) self.vcsMenuActions.append(act) menu.addSeparator() act = menu.addAction( UI.PixmapCache.getIcon("vcsDiff"), - self.tr('Show differences'), self._VCSDiff) + self.tr("Show differences"), + self._VCSDiff, + ) self.vcsMenuActions.append(act) act = menu.addAction( UI.PixmapCache.getIcon("vcsSbsDiff"), - self.tr('Show differences side-by-side'), self.__HgSbsDiff) + self.tr("Show differences side-by-side"), + self.__HgSbsDiff, + ) self.vcsMenuActions.append(act) act = menu.addAction( UI.PixmapCache.getIcon("vcsDiff"), - self.tr('Show differences (extended)'), - self.__HgExtendedDiff) + self.tr("Show differences (extended)"), + self.__HgExtendedDiff, + ) self.vcsMenuActions.append(act) act = menu.addAction( UI.PixmapCache.getIcon("vcsSbsDiff"), - self.tr('Show differences side-by-side (extended)'), - self.__HgSbsExtendedDiff) + self.tr("Show differences side-by-side (extended)"), + self.__HgSbsExtendedDiff, + ) self.vcsMenuActions.append(act) self.annotateAct = menu.addAction( - self.tr('Show annotated file'), - self.__HgAnnotate) + self.tr("Show annotated file"), self.__HgAnnotate + ) self.vcsMenuActions.append(self.annotateAct) menu.addSeparator() act = menu.addAction( UI.PixmapCache.getIcon("vcsRevert"), - self.tr('Revert changes'), self.__HgRevert) - self.vcsMenuActions.append(act) - act = menu.addAction( - self.tr('Conflicts resolved'), self.__HgResolved) + self.tr("Revert changes"), + self.__HgRevert, + ) self.vcsMenuActions.append(act) - act = menu.addAction( - self.tr('Conflicts unresolved'), self.__HgUnresolved) + act = menu.addAction(self.tr("Conflicts resolved"), self.__HgResolved) self.vcsMenuActions.append(act) - act = menu.addAction( - self.tr('Re-Merge'), self.__HgReMerge) + act = menu.addAction(self.tr("Conflicts unresolved"), self.__HgUnresolved) + self.vcsMenuActions.append(act) + act = menu.addAction(self.tr("Re-Merge"), self.__HgReMerge) self.vcsMenuActions.append(act) menu.addSeparator() - menu.addAction(self.tr('Select all local file entries'), - self.browser.selectLocalEntries) - menu.addAction(self.tr('Select all versioned file entries'), - self.browser.selectVCSEntries) - menu.addAction(self.tr('Select all local directory entries'), - self.browser.selectLocalDirEntries) - menu.addAction(self.tr('Select all versioned directory entries'), - self.browser.selectVCSDirEntries) + menu.addAction( + self.tr("Select all local file entries"), self.browser.selectLocalEntries + ) + menu.addAction( + self.tr("Select all versioned file entries"), self.browser.selectVCSEntries + ) + menu.addAction( + self.tr("Select all local directory entries"), + self.browser.selectLocalDirEntries, + ) + menu.addAction( + self.tr("Select all versioned directory entries"), + self.browser.selectVCSDirEntries, + ) menu.addSeparator() menu.addAction(self.tr("Configure..."), self.__HgConfigure) - + mainMenu.addSeparator() mainMenu.addMenu(menu) self.menu = menu - + def _addVCSMenuMulti(self, mainMenu): """ Protected method used to add the VCS menu for multi selection to all project browsers. - + @param mainMenu reference to the menu to be amended """ self.vcsMultiMenuActions = [] self.vcsAddMultiMenuActions = [] - + menu = QMenu(self.tr("Version Control")) - + act = menu.addAction( UI.PixmapCache.getIcon( - os.path.join("VcsPlugins", "vcsMercurial", "icons", - "mercurial.svg")), - self.vcs.vcsName(), self._VCSInfoDisplay) + os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.svg") + ), + self.vcs.vcsName(), + self._VCSInfoDisplay, + ) font = act.font() font.setBold(True) act.setFont(font) menu.addSeparator() - + act = menu.addAction( UI.PixmapCache.getIcon("vcsCommit"), - self.tr('Commit changes to repository...'), - self._VCSCommit) + self.tr("Commit changes to repository..."), + self._VCSCommit, + ) self.vcsMultiMenuActions.append(act) - self.__addExtensionsMenu(menu, 'multiMenu') + self.__addExtensionsMenu(menu, "multiMenu") menu.addSeparator() act = menu.addAction( - UI.PixmapCache.getIcon("vcsAdd"), - self.tr('Add to repository'), self._VCSAdd) + UI.PixmapCache.getIcon("vcsAdd"), self.tr("Add to repository"), self._VCSAdd + ) self.vcsAddMultiMenuActions.append(act) act = menu.addAction( UI.PixmapCache.getIcon("vcsRemove"), - self.tr('Remove from repository (and disk)'), - self._VCSRemove) + self.tr("Remove from repository (and disk)"), + self._VCSRemove, + ) self.vcsMultiMenuActions.append(act) act = menu.addAction( UI.PixmapCache.getIcon("vcsRemove"), - self.tr('Remove from repository only'), - self.__HgForget) + self.tr("Remove from repository only"), + self.__HgForget, + ) self.vcsMultiMenuActions.append(act) menu.addSeparator() act = menu.addAction( - UI.PixmapCache.getIcon("vcsStatus"), - self.tr('Show status'), self._VCSStatus) + UI.PixmapCache.getIcon("vcsStatus"), self.tr("Show status"), self._VCSStatus + ) self.vcsMultiMenuActions.append(act) menu.addSeparator() act = menu.addAction( UI.PixmapCache.getIcon("vcsDiff"), - self.tr('Show differences'), self._VCSDiff) + self.tr("Show differences"), + self._VCSDiff, + ) self.vcsMultiMenuActions.append(act) act = menu.addAction( UI.PixmapCache.getIcon("vcsDiff"), - self.tr('Show differences (extended)'), - self.__HgExtendedDiff) + self.tr("Show differences (extended)"), + self.__HgExtendedDiff, + ) self.vcsMultiMenuActions.append(act) menu.addSeparator() act = menu.addAction( UI.PixmapCache.getIcon("vcsRevert"), - self.tr('Revert changes'), self.__HgRevert) - self.vcsMultiMenuActions.append(act) - act = menu.addAction( - self.tr('Conflicts resolved'), self.__HgResolved) + self.tr("Revert changes"), + self.__HgRevert, + ) self.vcsMultiMenuActions.append(act) - act = menu.addAction( - self.tr('Conflicts unresolved'), self.__HgUnresolved) + act = menu.addAction(self.tr("Conflicts resolved"), self.__HgResolved) self.vcsMultiMenuActions.append(act) - act = menu.addAction( - self.tr('Re-Merge'), self.__HgReMerge) + act = menu.addAction(self.tr("Conflicts unresolved"), self.__HgUnresolved) + self.vcsMultiMenuActions.append(act) + act = menu.addAction(self.tr("Re-Merge"), self.__HgReMerge) self.vcsMultiMenuActions.append(act) menu.addSeparator() - menu.addAction(self.tr('Select all local file entries'), - self.browser.selectLocalEntries) - menu.addAction(self.tr('Select all versioned file entries'), - self.browser.selectVCSEntries) - menu.addAction(self.tr('Select all local directory entries'), - self.browser.selectLocalDirEntries) - menu.addAction(self.tr('Select all versioned directory entries'), - self.browser.selectVCSDirEntries) + menu.addAction( + self.tr("Select all local file entries"), self.browser.selectLocalEntries + ) + menu.addAction( + self.tr("Select all versioned file entries"), self.browser.selectVCSEntries + ) + menu.addAction( + self.tr("Select all local directory entries"), + self.browser.selectLocalDirEntries, + ) + menu.addAction( + self.tr("Select all versioned directory entries"), + self.browser.selectVCSDirEntries, + ) menu.addSeparator() menu.addAction(self.tr("Configure..."), self.__HgConfigure) - + mainMenu.addSeparator() mainMenu.addMenu(menu) self.menuMulti = menu - + def _addVCSMenuBack(self, mainMenu): """ Protected method used to add the VCS menu to all project browsers. - + @param mainMenu reference to the menu to be amended """ menu = QMenu(self.tr("Version Control")) - + act = menu.addAction( UI.PixmapCache.getIcon( - os.path.join("VcsPlugins", "vcsMercurial", "icons", - "mercurial.svg")), - self.vcs.vcsName(), self._VCSInfoDisplay) + os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.svg") + ), + self.vcs.vcsName(), + self._VCSInfoDisplay, + ) font = act.font() font.setBold(True) act.setFont(font) menu.addSeparator() - - menu.addAction(self.tr('Select all local file entries'), - self.browser.selectLocalEntries) - menu.addAction(self.tr('Select all versioned file entries'), - self.browser.selectVCSEntries) - menu.addAction(self.tr('Select all local directory entries'), - self.browser.selectLocalDirEntries) - menu.addAction(self.tr('Select all versioned directory entries'), - self.browser.selectVCSDirEntries) + + menu.addAction( + self.tr("Select all local file entries"), self.browser.selectLocalEntries + ) + menu.addAction( + self.tr("Select all versioned file entries"), self.browser.selectVCSEntries + ) + menu.addAction( + self.tr("Select all local directory entries"), + self.browser.selectLocalDirEntries, + ) + menu.addAction( + self.tr("Select all versioned directory entries"), + self.browser.selectVCSDirEntries, + ) menu.addSeparator() menu.addAction(self.tr("Configure..."), self.__HgConfigure) - + mainMenu.addSeparator() mainMenu.addMenu(menu) self.menuBack = menu - + def _addVCSMenuDir(self, mainMenu): """ Protected method used to add the VCS menu to all project browsers. - + @param mainMenu reference to the menu to be amended """ if mainMenu is None: return - + self.vcsDirMenuActions = [] self.vcsAddDirMenuActions = [] - + menu = QMenu(self.tr("Version Control")) - + act = menu.addAction( UI.PixmapCache.getIcon( - os.path.join("VcsPlugins", "vcsMercurial", "icons", - "mercurial.svg")), - self.vcs.vcsName(), self._VCSInfoDisplay) + os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.svg") + ), + self.vcs.vcsName(), + self._VCSInfoDisplay, + ) font = act.font() font.setBold(True) act.setFont(font) menu.addSeparator() - + act = menu.addAction( UI.PixmapCache.getIcon("vcsCommit"), - self.tr('Commit changes to repository...'), - self._VCSCommit) + self.tr("Commit changes to repository..."), + self._VCSCommit, + ) self.vcsDirMenuActions.append(act) - self.__addExtensionsMenu(menu, 'dirMenu') + self.__addExtensionsMenu(menu, "dirMenu") menu.addSeparator() act = menu.addAction( - UI.PixmapCache.getIcon("vcsAdd"), - self.tr('Add to repository'), self._VCSAdd) + UI.PixmapCache.getIcon("vcsAdd"), self.tr("Add to repository"), self._VCSAdd + ) self.vcsAddDirMenuActions.append(act) act = menu.addAction( UI.PixmapCache.getIcon("vcsRemove"), - self.tr('Remove from repository (and disk)'), - self._VCSRemove) + self.tr("Remove from repository (and disk)"), + self._VCSRemove, + ) self.vcsDirMenuActions.append(act) menu.addSeparator() - act = menu.addAction(self.tr('Copy'), self.__HgCopy) + act = menu.addAction(self.tr("Copy"), self.__HgCopy) self.vcsDirMenuActions.append(act) - act = menu.addAction(self.tr('Move'), self.__HgMove) + act = menu.addAction(self.tr("Move"), self.__HgMove) self.vcsDirMenuActions.append(act) menu.addSeparator() act = menu.addAction( UI.PixmapCache.getIcon("vcsLog"), - self.tr('Show log browser'), self._VCSLogBrowser) + self.tr("Show log browser"), + self._VCSLogBrowser, + ) self.vcsDirMenuActions.append(act) menu.addSeparator() act = menu.addAction( - UI.PixmapCache.getIcon("vcsStatus"), - self.tr('Show status'), self._VCSStatus) + UI.PixmapCache.getIcon("vcsStatus"), self.tr("Show status"), self._VCSStatus + ) self.vcsDirMenuActions.append(act) menu.addSeparator() act = menu.addAction( UI.PixmapCache.getIcon("vcsDiff"), - self.tr('Show differences'), self._VCSDiff) + self.tr("Show differences"), + self._VCSDiff, + ) self.vcsDirMenuActions.append(act) act = menu.addAction( UI.PixmapCache.getIcon("vcsDiff"), - self.tr('Show differences (extended)'), - self.__HgExtendedDiff) + self.tr("Show differences (extended)"), + self.__HgExtendedDiff, + ) self.vcsDirMenuActions.append(act) menu.addSeparator() act = menu.addAction( UI.PixmapCache.getIcon("vcsRevert"), - self.tr('Revert changes'), self.__HgRevert) - self.vcsDirMenuActions.append(act) - act = menu.addAction( - self.tr('Conflicts resolved'), self.__HgResolved) + self.tr("Revert changes"), + self.__HgRevert, + ) self.vcsDirMenuActions.append(act) - act = menu.addAction( - self.tr('Conflicts unresolved'), self.__HgUnresolved) + act = menu.addAction(self.tr("Conflicts resolved"), self.__HgResolved) self.vcsDirMenuActions.append(act) - act = menu.addAction( - self.tr('Re-Merge'), self.__HgReMerge) + act = menu.addAction(self.tr("Conflicts unresolved"), self.__HgUnresolved) + self.vcsDirMenuActions.append(act) + act = menu.addAction(self.tr("Re-Merge"), self.__HgReMerge) self.vcsDirMenuActions.append(act) menu.addSeparator() - menu.addAction(self.tr('Select all local file entries'), - self.browser.selectLocalEntries) - menu.addAction(self.tr('Select all versioned file entries'), - self.browser.selectVCSEntries) - menu.addAction(self.tr('Select all local directory entries'), - self.browser.selectLocalDirEntries) - menu.addAction(self.tr('Select all versioned directory entries'), - self.browser.selectVCSDirEntries) + menu.addAction( + self.tr("Select all local file entries"), self.browser.selectLocalEntries + ) + menu.addAction( + self.tr("Select all versioned file entries"), self.browser.selectVCSEntries + ) + menu.addAction( + self.tr("Select all local directory entries"), + self.browser.selectLocalDirEntries, + ) + menu.addAction( + self.tr("Select all versioned directory entries"), + self.browser.selectVCSDirEntries, + ) menu.addSeparator() menu.addAction(self.tr("Configure..."), self.__HgConfigure) - + mainMenu.addSeparator() mainMenu.addMenu(menu) self.menuDir = menu - + def _addVCSMenuDirMulti(self, mainMenu): """ Protected method used to add the VCS menu to all project browsers. - + @param mainMenu reference to the menu to be amended """ if mainMenu is None: return - + self.vcsDirMultiMenuActions = [] self.vcsAddDirMultiMenuActions = [] - + menu = QMenu(self.tr("Version Control")) - + act = menu.addAction( UI.PixmapCache.getIcon( - os.path.join("VcsPlugins", "vcsMercurial", "icons", - "mercurial.svg")), - self.vcs.vcsName(), self._VCSInfoDisplay) + os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.svg") + ), + self.vcs.vcsName(), + self._VCSInfoDisplay, + ) font = act.font() font.setBold(True) act.setFont(font) menu.addSeparator() - + act = menu.addAction( UI.PixmapCache.getIcon("vcsCommit"), - self.tr('Commit changes to repository...'), - self._VCSCommit) + self.tr("Commit changes to repository..."), + self._VCSCommit, + ) self.vcsDirMultiMenuActions.append(act) - self.__addExtensionsMenu(menu, 'dirMultiMenu') + self.__addExtensionsMenu(menu, "dirMultiMenu") menu.addSeparator() act = menu.addAction( - UI.PixmapCache.getIcon("vcsAdd"), - self.tr('Add to repository'), self._VCSAdd) + UI.PixmapCache.getIcon("vcsAdd"), self.tr("Add to repository"), self._VCSAdd + ) self.vcsAddDirMultiMenuActions.append(act) act = menu.addAction( UI.PixmapCache.getIcon("vcsRemove"), - self.tr('Remove from repository (and disk)'), - self._VCSRemove) + self.tr("Remove from repository (and disk)"), + self._VCSRemove, + ) self.vcsDirMultiMenuActions.append(act) menu.addSeparator() act = menu.addAction( - UI.PixmapCache.getIcon("vcsStatus"), - self.tr('Show status'), self._VCSStatus) + UI.PixmapCache.getIcon("vcsStatus"), self.tr("Show status"), self._VCSStatus + ) self.vcsDirMultiMenuActions.append(act) menu.addSeparator() act = menu.addAction( UI.PixmapCache.getIcon("vcsDiff"), - self.tr('Show differences'), self._VCSDiff) + self.tr("Show differences"), + self._VCSDiff, + ) self.vcsDirMultiMenuActions.append(act) act = menu.addAction( UI.PixmapCache.getIcon("vcsDiff"), - self.tr('Show differences (extended)'), - self.__HgExtendedDiff) + self.tr("Show differences (extended)"), + self.__HgExtendedDiff, + ) self.vcsDirMultiMenuActions.append(act) menu.addSeparator() act = menu.addAction( UI.PixmapCache.getIcon("vcsRevert"), - self.tr('Revert changes'), self.__HgRevert) - self.vcsDirMultiMenuActions.append(act) - act = menu.addAction( - self.tr('Conflicts resolved'), self.__HgResolved) + self.tr("Revert changes"), + self.__HgRevert, + ) self.vcsDirMultiMenuActions.append(act) - act = menu.addAction( - self.tr('Conflicts unresolved'), self.__HgUnresolved) + act = menu.addAction(self.tr("Conflicts resolved"), self.__HgResolved) self.vcsDirMultiMenuActions.append(act) - act = menu.addAction( - self.tr('Re-Merge'), self.__HgReMerge) + act = menu.addAction(self.tr("Conflicts unresolved"), self.__HgUnresolved) + self.vcsDirMultiMenuActions.append(act) + act = menu.addAction(self.tr("Re-Merge"), self.__HgReMerge) self.vcsDirMultiMenuActions.append(act) menu.addSeparator() - menu.addAction(self.tr('Select all local file entries'), - self.browser.selectLocalEntries) - menu.addAction(self.tr('Select all versioned file entries'), - self.browser.selectVCSEntries) - menu.addAction(self.tr('Select all local directory entries'), - self.browser.selectLocalDirEntries) - menu.addAction(self.tr('Select all versioned directory entries'), - self.browser.selectVCSDirEntries) + menu.addAction( + self.tr("Select all local file entries"), self.browser.selectLocalEntries + ) + menu.addAction( + self.tr("Select all versioned file entries"), self.browser.selectVCSEntries + ) + menu.addAction( + self.tr("Select all local directory entries"), + self.browser.selectLocalDirEntries, + ) + menu.addAction( + self.tr("Select all versioned directory entries"), + self.browser.selectVCSDirEntries, + ) menu.addSeparator() menu.addAction(self.tr("Configure..."), self.__HgConfigure) - + mainMenu.addSeparator() mainMenu.addMenu(menu) self.menuDirMulti = menu - + ########################################################################### ## Menu handling methods below ########################################################################### - + def __HgRevert(self): """ Private slot called by the context menu to revert changes made. @@ -692,7 +769,7 @@ name = itm.dirName() names.append(name) self.vcs.vcsRevert(names) - + def __HgCopy(self): """ Private slot called by the context menu to copy the selected file. @@ -703,7 +780,7 @@ except AttributeError: fn = itm.dirName() self.vcs.hgCopy(fn, self.project) - + def __HgMove(self): """ Private slot called by the context menu to move the selected file. @@ -723,12 +800,12 @@ for mf in movefiles: self.browser.closeSourceWindow.emit(mf) self.browser.project.startFileSystemMonitoring() - + def __HgExtendedDiff(self): """ Private slot called by the context menu to show the difference of a file to the repository. - + This gives the chance to enter the revisions to compare. """ names = [] @@ -738,7 +815,7 @@ except AttributeError: names.append(itm.dirName()) self.vcs.hgExtendedDiff(names) - + def __HgSbsDiff(self): """ Private slot called by the context menu to show the difference of a @@ -747,18 +824,18 @@ itm = self.browser.currentItem() fn = itm.fileName() self.vcs.vcsSbsDiff(fn) - + def __HgSbsExtendedDiff(self): """ Private slot called by the context menu to show the difference of a file to the repository side-by-side. - + It allows the selection of revisions to compare. """ itm = self.browser.currentItem() fn = itm.fileName() self.vcs.vcsSbsDiff(fn, extended=True) - + def __HgAnnotate(self): """ Private slot called by the context menu to show the annotations of a @@ -767,7 +844,7 @@ itm = self.browser.currentItem() fn = itm.fileName() self.vcs.hgAnnotate(fn) - + def __HgResolved(self): """ Private slot called by the context menu to mark conflicts of a file @@ -780,7 +857,7 @@ except AttributeError: names.append(itm.dirName()) self.vcs.vcsResolved(names) - + def __HgUnresolved(self): """ Private slot called by the context menu to mark conflicts of a file @@ -793,7 +870,7 @@ except AttributeError: names.append(itm.dirName()) self.vcs.vcsResolved(names, unresolve=True) - + def __HgReMerge(self): """ Private slot called by the context menu to re-merge a file. @@ -805,49 +882,48 @@ except AttributeError: names.append(itm.dirName()) self.vcs.hgReMerge(names) - + def __HgForget(self): """ Private slot called by the context menu to remove the selected file from the Mercurial repository leaving a copy in the project directory. """ - from UI.DeleteFilesConfirmationDialog import ( - DeleteFilesConfirmationDialog - ) + from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog + if self.isTranslationsBrowser: items = self.browser.getSelectedItems([ProjectBrowserFileItem]) names = [itm.fileName() for itm in items] - + dlg = DeleteFilesConfirmationDialog( self.parent(), self.tr("Remove from repository only"), self.tr( - "Do you really want to remove these files" - " from the repository?"), - names) + "Do you really want to remove these files" " from the repository?" + ), + names, + ) else: items = self.browser.getSelectedItems() names = [itm.fileName() for itm in items] - files = [self.browser.project.getRelativePath(name) - for name in names] - + files = [self.browser.project.getRelativePath(name) for name in names] + dlg = DeleteFilesConfirmationDialog( self.parent(), self.tr("Remove from repository only"), self.tr( - "Do you really want to remove these files" - " from the repository?"), - files) - + "Do you really want to remove these files" " from the repository?" + ), + files, + ) + if dlg.exec() == QDialog.DialogCode.Accepted: self.vcs.vcsForget(names) - + for fn in names: self._updateVCSStatus(fn) - + def __HgConfigure(self): """ Private method to open the configuration dialog. """ - ericApp().getObject("UserInterface").showPreferences( - "zzz_mercurialPage") + ericApp().getObject("UserInterface").showPreferences("zzz_mercurialPage")