eric6/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesListGuardsDialog.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 7533
88261c96484b
permissions
-rw-r--r--

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

1046
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
5dd14be5d6a1 Continued with support for Mercurial queues 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) 2011 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
1046
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to show the guards of a selected patch.
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
5dd14be5d6a1 Continued with support for Mercurial queues 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, QCoreApplication
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
13 from PyQt5.QtWidgets import QDialog, QListWidgetItem
1046
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from .Ui_HgQueuesListGuardsDialog import Ui_HgQueuesListGuardsDialog
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import UI.PixmapCache
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 class HgQueuesListGuardsDialog(QDialog, Ui_HgQueuesListGuardsDialog):
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Class implementing a dialog to show the guards of a selected patch.
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 def __init__(self, vcs, patchesList, parent=None):
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Constructor
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param vcs reference to the vcs object
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param patchesList list of patches (list of strings)
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param parent reference to the parent widget (QWidget)
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
32 super(HgQueuesListGuardsDialog, self).__init__(parent)
1046
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.setupUi(self)
4278
ccd1e13cb9bd Fixed issues where dialogs could not be minimized on some desktop environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
34 self.setWindowFlags(Qt.Window)
1046
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.vcs = vcs
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
37 self.__hgClient = vcs.getClient()
1046
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.patchSelector.addItems([""] + patchesList)
1260
9488a3aceb0e Added code to some Mercurial dialogs to improve user experience.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1256
diff changeset
40
9488a3aceb0e Added code to some Mercurial dialogs to improve user experience.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1256
diff changeset
41 self.show()
9488a3aceb0e Added code to some Mercurial dialogs to improve user experience.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1256
diff changeset
42 QCoreApplication.processEvents()
1046
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 def closeEvent(self, e):
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
46 Protected slot implementing a close event handler.
1046
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 @param e close event (QCloseEvent)
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
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
50 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
51 self.__hgClient.cancel()
1046
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 e.accept()
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 def start(self, path):
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 Public slot to start the list command.
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 @param path name of directory to be listed (string)
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 dname, fname = self.vcs.splitPath(path)
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 # find the root of the repo
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 repodir = dname
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 repodir = os.path.dirname(repodir)
1318
6fa303bd65d6 Fixed issues in various Mercurial files that could cause infinite loops on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1260
diff changeset
67 if os.path.splitdrive(repodir)[1] == os.sep:
1046
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 return
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.__repodir = repodir
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.on_patchSelector_activated("")
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 @pyqtSlot(str)
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 def on_patchSelector_activated(self, patch):
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 Private slot to get the list of guards for the given patch name.
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 @param patch selected patch name (empty for current patch)
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.guardsList.clear()
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.patchNameLabel.setText("")
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
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: 3190
diff changeset
83 args = self.vcs.initCommand("qguard")
1046
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 if patch:
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 args.append(patch)
5dd14be5d6a1 Continued with support for Mercurial queues extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
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
87 output = self.__hgClient.runcommand(args)[0].strip()
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
88
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
89 if output:
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
90 patchName, guards = output.split(":", 1)
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
91 self.patchNameLabel.setText(patchName)
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
92 guardsList = guards.strip().split()
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
93 for guard in guardsList:
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
94 if guard.startswith("+"):
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
95 icon = UI.PixmapCache.getIcon("plus.png")
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
96 guard = guard[1:]
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
97 elif guard.startswith("-"):
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
98 icon = UI.PixmapCache.getIcon("minus.png")
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
99 guard = guard[1:]
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
100 else:
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
101 icon = None
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
102 guard = self.tr("Unguarded")
1255
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
103 itm = QListWidgetItem(guard, self.guardsList)
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
104 if icon:
e1d8a8a4d40c Continued implementing an interface to the Mercurial command server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
105 itm.setIcon(icon)

eric ide

mercurial