eric6/Plugins/VcsPlugins/vcsMercurial/ShelveExtension/HgShelveBrowserDialog.py

Mon, 13 Jan 2020 19:23:08 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 13 Jan 2020 19:23:08 +0100
changeset 7370
5fb53279f2df
parent 7360
9190402e4505
child 7771
787a6b3f8c9f
permissions
-rw-r--r--

Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.

3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
3 # Copyright (c) 2014 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
4543
2e6a880670e9 Fixed a few code style issues (forgotten future imports, copyrights,...).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3909
diff changeset
4 #
2e6a880670e9 Fixed a few code style issues (forgotten future imports, copyrights,...).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3909
diff changeset
5
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing Mercurial shelve browser dialog.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
12 from PyQt5.QtCore import pyqtSlot, Qt, QPoint
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
13 from PyQt5.QtGui import QCursor
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 from PyQt5.QtWidgets import (
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
15 QWidget, QDialogButtonBox, QTreeWidgetItem, QAbstractButton, QMenu,
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
16 QHeaderView, QApplication
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
17 )
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from .Ui_HgShelveBrowserDialog import Ui_HgShelveBrowserDialog
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 class HgShelveBrowserDialog(QWidget, Ui_HgShelveBrowserDialog):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Class implementing Mercurial shelve browser dialog.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 NameColumn = 0
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 AgeColumn = 1
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 MessageColumn = 2
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 def __init__(self, vcs, parent=None):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Constructor
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param vcs reference to the vcs object
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param parent parent widget (QWidget)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3306
diff changeset
37 super(HgShelveBrowserDialog, self).__init__(parent)
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.setupUi(self)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.__position = QPoint()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.__fileStatisticsRole = Qt.UserRole
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.__totalStatisticsRole = Qt.UserRole + 1
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.shelveList.header().setSortIndicator(0, Qt.AscendingOrder)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.refreshButton = self.buttonBox.addButton(
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.tr("&Refresh"), QDialogButtonBox.ActionRole)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.refreshButton.setToolTip(
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.tr("Press to refresh the list of shelves"))
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.refreshButton.setEnabled(False)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.vcs = vcs
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.__hgClient = vcs.getClient()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.__resetUI()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.__contextMenu = QMenu()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.__unshelveAct = self.__contextMenu.addAction(
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.tr("Restore selected shelve"), self.__unshelve)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.__deleteAct = self.__contextMenu.addAction(
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.tr("Delete selected shelves"), self.__deleteShelves)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.__contextMenu.addAction(
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.tr("Delete all shelves"), self.__cleanupShelves)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 def closeEvent(self, e):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
70 Protected slot implementing a close event handler.
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 @param e close event (QCloseEvent)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
74 if self.__hgClient.isExecuting():
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
75 self.__hgClient.cancel()
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.__position = self.pos()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 e.accept()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 def show(self):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 Public slot to show the dialog.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 if not self.__position.isNull():
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.move(self.__position)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.__resetUI()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3306
diff changeset
89 super(HgShelveBrowserDialog, self).show()
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 def __resetUI(self):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 Private method to reset the user interface.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.shelveList.clear()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 def __resizeColumnsShelves(self):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 Private method to resize the shelve list columns.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.shelveList.header().resizeSections(QHeaderView.ResizeToContents)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.shelveList.header().setStretchLastSection(True)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 def __generateShelveEntry(self, name, age, message, fileStatistics,
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 totals):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 Private method to generate the shelve items.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 @param name name of the shelve (string)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 @param age age of the shelve (string)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 @param message shelve message (string)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 @param fileStatistics per file change statistics (tuple of
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 four strings with file name, number of changes, number of
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 added lines and number of deleted lines)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 @param totals overall statistics (tuple of three strings with
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 number of changed files, number of added lines and number
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 of deleted lines)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 itm = QTreeWidgetItem(self.shelveList, [name, age, message])
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 itm.setData(0, self.__fileStatisticsRole, fileStatistics)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 itm.setData(0, self.__totalStatisticsRole, totals)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 def __getShelveEntries(self):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 Private method to retrieve the list of shelves.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 QApplication.processEvents()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 QApplication.processEvents()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.buf = []
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 self.errors.clear()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 self.intercept = False
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138
3302
e92f0dd51979 Removed the Mercurial support for a command options dialog and added useable global options to the Mercurial config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3297
diff changeset
139 args = self.vcs.initCommand("shelve")
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 args.append("--list")
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 args.append("--stat")
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
143 out, err = self.__hgClient.runcommand(args)
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
144 self.buf = out.splitlines(True)
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
145 if err:
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
146 self.__showError(err)
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
147 self.__processBuffer()
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
148 self.__finish()
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 def start(self, projectDir):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 Public slot to start the hg shelve command.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 @param projectDir name of the project directory (string)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 self.errorGroup.hide()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 QApplication.processEvents()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self.__projectDir = projectDir
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 # find the root of the repo
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 self.repodir = self.__projectDir
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 while not os.path.isdir(os.path.join(self.repodir, self.vcs.adminDir)):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 self.repodir = os.path.dirname(self.repodir)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 if os.path.splitdrive(self.repodir)[1] == os.sep:
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 return
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 self.activateWindow()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 self.raise_()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 self.shelveList.clear()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 self.__started = True
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 self.__getShelveEntries()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 def __finish(self):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 Private slot called when the process finished or the user pressed
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 the button.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 QApplication.restoreOverrideCursor()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.refreshButton.setEnabled(True)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 def __processBuffer(self):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 Private method to process the buffered output of the hg shelve command.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 lastWasFileStats = False
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 firstLine = True
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 itemData = {}
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 for line in self.buf:
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 if firstLine:
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 name, line = line.split("(", 1)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 age, message = line.split(")", 1)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 itemData["name"] = name.strip()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 itemData["age"] = age.strip()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 itemData["message"] = message.strip()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 itemData["files"] = []
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 firstLine = False
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 elif '|' in line:
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 # file stats: foo.py | 3 ++-
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 file, changes = line.strip().split("|", 1)
3306
0a4e5082cbc6 Last changes to the Mercurial shelve extension interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3302
diff changeset
207 if changes.strip().endswith(("+", "-")):
0a4e5082cbc6 Last changes to the Mercurial shelve extension interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3302
diff changeset
208 total, addDelete = changes.strip().split(None, 1)
0a4e5082cbc6 Last changes to the Mercurial shelve extension interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3302
diff changeset
209 additions = str(addDelete.count("+"))
0a4e5082cbc6 Last changes to the Mercurial shelve extension interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3302
diff changeset
210 deletions = str(addDelete.count("-"))
0a4e5082cbc6 Last changes to the Mercurial shelve extension interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3302
diff changeset
211 else:
0a4e5082cbc6 Last changes to the Mercurial shelve extension interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3302
diff changeset
212 total = changes.strip()
0a4e5082cbc6 Last changes to the Mercurial shelve extension interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3302
diff changeset
213 additions = '0'
0a4e5082cbc6 Last changes to the Mercurial shelve extension interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3302
diff changeset
214 deletions = '0'
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 itemData["files"].append((file, total, additions, deletions))
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 lastWasFileStats = True
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 elif lastWasFileStats:
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 # summary line
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 # 2 files changed, 15 insertions(+), 1 deletions(-)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 total, added, deleted = line.strip().split(",", 2)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 total = total.split()[0]
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 added = added.split()[0]
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 deleted = deleted.split()[0]
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 itemData["summary"] = (total, added, deleted)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 self.__generateShelveEntry(
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 itemData["name"], itemData["age"], itemData["message"],
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 itemData["files"], itemData["summary"])
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 lastWasFileStats = False
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 firstLine = True
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 itemData = {}
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 self.__resizeColumnsShelves()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 if self.__started:
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 self.shelveList.setCurrentItem(self.shelveList.topLevelItem(0))
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 self.__started = False
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 def __showError(self, out):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 Private slot to show some error.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 @param out error to be shown (string)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 self.errorGroup.show()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 self.errors.insertPlainText(out)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 self.errors.ensureCursorVisible()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 @pyqtSlot(QAbstractButton)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 def on_buttonBox_clicked(self, button):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 Private slot called by a button of the button box clicked.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 @param button button that was clicked (QAbstractButton)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 if button == self.buttonBox.button(QDialogButtonBox.Close):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 self.close()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 self.cancelled = True
7370
5fb53279f2df Mercurial: removed some old code dealing with using the hg commandline executable instead of the command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
261 self.__hgClient.cancel()
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 elif button == self.refreshButton:
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 self.on_refreshButton_clicked()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 def on_shelveList_currentItemChanged(self, current, previous):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 Private slot called, when the current item of the shelve list changes.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 @param current reference to the new current item (QTreeWidgetItem)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 @param previous reference to the old current item (QTreeWidgetItem)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 self.statisticsList.clear()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 if current:
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 for dataSet in current.data(0, self.__fileStatisticsRole):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 QTreeWidgetItem(self.statisticsList, list(dataSet))
3908
3c5699886961 Little improvement to the Shelve Browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
277 self.statisticsList.header().resizeSections(
3c5699886961 Little improvement to the Shelve Browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
278 QHeaderView.ResizeToContents)
3c5699886961 Little improvement to the Shelve Browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
279 self.statisticsList.header().setStretchLastSection(True)
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 totals = current.data(0, self.__totalStatisticsRole)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 self.filesLabel.setText(
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 self.tr("%n file(s) changed", None, int(totals[0])))
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 self.insertionsLabel.setText(
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 self.tr("%n line(s) inserted", None, int(totals[1])))
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 self.deletionsLabel.setText(
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 self.tr("%n line(s) deleted", None, int(totals[2])))
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 else:
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 self.filesLabel.setText("")
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 self.insertionsLabel.setText("")
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 self.deletionsLabel.setText("")
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 @pyqtSlot(QPoint)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 def on_shelveList_customContextMenuRequested(self, pos):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
296 Private slot to show the context menu of the shelve list.
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 @param pos position of the mouse pointer (QPoint)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 selectedItemsCount = len(self.shelveList.selectedItems())
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 self.__unshelveAct.setEnabled(selectedItemsCount == 1)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 self.__deleteAct.setEnabled(selectedItemsCount > 0)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 self.__contextMenu.popup(self.mapToGlobal(pos))
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 @pyqtSlot()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 def on_refreshButton_clicked(self):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 Private slot to refresh the list of shelves.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 self.refreshButton.setEnabled(False)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 self.start(self.__projectDir)
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 def __unshelve(self):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 Private slot to restore the selected shelve of changes.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 itm = self.shelveList.selectedItems()[0]
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 if itm is not None:
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 name = itm.text(self.NameColumn)
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
326 self.vcs.getExtensionObject("shelve").hgUnshelve(
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
327 self.__projectDir, shelveName=name)
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 self.on_refreshButton_clicked()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 def __deleteShelves(self):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 Private slot to delete the selected shelves.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 shelveNames = []
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 for itm in self.shelveList.selectedItems():
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 shelveNames.append(itm.text(self.NameColumn))
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 if shelveNames:
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
338 self.vcs.getExtensionObject("shelve").hgDeleteShelves(
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
339 self.__projectDir, shelveNames=shelveNames)
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 self.on_refreshButton_clicked()
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 def __cleanupShelves(self):
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 """
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 Private slot to delete all shelves.
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 """
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
346 self.vcs.getExtensionObject("shelve").hgCleanupShelves(
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
347 self.__projectDir)
3297
7b7e8124fb51 Continued implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 self.on_refreshButton_clicked()

eric ide

mercurial