Fixed the handling of the switch action of the Mercurial log browser dialog context menu in the presence of a bookmark.

Tue, 15 Nov 2016 19:02:50 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 15 Nov 2016 19:02:50 +0100
changeset 5324
337c27027c66
parent 5323
8c2a414262a4
child 5325
d0b6adb1721f

Fixed the handling of the switch action of the Mercurial log browser dialog context menu in the presence of a bookmark.

Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py file | annotate | diff | comparison | revisions
--- a/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Tue Nov 15 19:01:53 2016 +0100
+++ b/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Tue Nov 15 19:02:50 2016 +0100
@@ -47,6 +47,7 @@
     DateColumn = 5
     MessageColumn = 6
     TagsColumn = 7
+    BookmarksColumn = 8
     
     LargefilesCacheL = ".hglf/"
     LargefilesCacheW = ".hglf\\"
@@ -178,9 +179,9 @@
         """
         Private method to initialize the actions menu.
         """
-        # TODO: add some eye candy
         self.__actionsMenu = QMenu()
         self.__graftAct = self.__actionsMenu.addAction(
+            UI.PixmapCache.getIcon("vcsGraft.png"),
             self.tr("Copy Changesets"), self.__graftActTriggered)
         self.__graftAct.setToolTip(self.tr(
             "Copy the selected changesets to the current branch"))
@@ -195,21 +196,25 @@
             """ the same current phase.</p>"""))
         
         self.__tagAct = self.__actionsMenu.addAction(
-            self.tr("Tag"), self.__tagActTriggered)
+            UI.PixmapCache.getIcon("vcsTag.png"), self.tr("Tag"),
+            self.__tagActTriggered)
         self.__tagAct.setToolTip(self.tr("Tag the selected revision"))
         
         self.__switchAct = self.__actionsMenu.addAction(
-            self.tr("Switch"), self.__switchActTriggered)
+            UI.PixmapCache.getIcon("vcsSwitch.png"), self.tr("Switch"),
+            self.__switchActTriggered)
         self.__switchAct.setToolTip(self.tr(
             "Switch the working directory to the selected revision"))
         
         self.__actionsMenu.addSeparator()
         
         self.__bookmarkAct = self.__actionsMenu.addAction(
+            UI.PixmapCache.getIcon("addBookmark.png"),
             self.tr("Define Bookmark..."), self.__bookmarkActTriggered)
         self.__bookmarkAct.setToolTip(
             self.tr("Bookmark the selected revision"))
         self.__bookmarkMoveAct = self.__actionsMenu.addAction(
+            UI.PixmapCache.getIcon("moveBookmark.png"),
             self.tr("Move Bookmark..."), self.__bookmarkMoveActTriggered)
         self.__bookmarkMoveAct.setToolTip(
             self.tr("Move bookmark to the selected revision"))
@@ -217,7 +222,8 @@
         self.__actionsMenu.addSeparator()
         
         self.__pullAct = self.__actionsMenu.addAction(
-            self.tr("Pull Changes"), self.__pullActTriggered)
+            UI.PixmapCache.getIcon("vcsUpdate.png"), self.tr("Pull Changes"),
+            self.__pullActTriggered)
         self.__pullAct.setToolTip(self.tr(
             "Pull changes from a remote repository"))
         self.__lfPullAct = self.__actionsMenu.addAction(
@@ -232,11 +238,13 @@
         self.__actionsMenu.addSeparator()
         
         self.__pushAct = self.__actionsMenu.addAction(
+            UI.PixmapCache.getIcon("vcsCommit.png"),
             self.tr("Push Selected Changes"), self.__pushActTriggered)
         self.__pushAct.setToolTip(self.tr(
             "Push changes of the selected changeset and its ancestors"
             " to a remote repository"))
         self.__pushAllAct = self.__actionsMenu.addAction(
+            UI.PixmapCache.getIcon("vcsCommit.png"),
             self.tr("Push All Changes"), self.__pushAllActTriggered)
         self.__pushAllAct.setToolTip(self.tr(
             "Push all changes to a remote repository"))
@@ -244,6 +252,7 @@
         self.__actionsMenu.addSeparator()
         
         self.__stripAct = self.__actionsMenu.addAction(
+            UI.PixmapCache.getIcon("fileDelete.png"),
             self.tr("Strip Changesets"), self.__stripActTriggered)
         self.__stripAct.setToolTip(self.tr(
             "Strip changesets from a repository"))
@@ -1726,6 +1735,21 @@
         if len(self.logTree.selectedItems()) == 1:
             itm = self.logTree.selectedItems()[0]
             rev = itm.text(self.RevisionColumn).strip().split(":", 1)[0]
+            bookmarks = [bm.strip() for bm in 
+                         itm.text(self.BookmarksColumn).strip().split(",")
+                         if bm.strip()]
+            if bookmarks:
+                bookmark, ok = QInputDialog.getItem(
+                    self,
+                    self.tr("Switch"),
+                    self.tr("Select bookmark to switch to (leave empty to"
+                            " use revision):"),
+                    [""] + bookmarks,
+                    0, False)
+                if not ok:
+                    return
+                if bookmark:
+                    rev = bookmark
             if rev:
                 shouldReopen = self.vcs.vcsUpdate(self.repodir, revision=rev)
                 if shouldReopen:

eric ide

mercurial