src/eric7/Plugins/VcsPlugins/vcsMercurial/HgDialog.py

Sat, 23 Dec 2023 15:48:12 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 23 Dec 2023 15:48:12 +0100
branch
eric7
changeset 10439
21c28b0f9e41
parent 10438
4cd7e5a8b3cf
child 10595
59579e8aff98
permissions
-rw-r--r--

Updated copyright for 2024.

178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
10439
21c28b0f9e41 Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10438
diff changeset
3 # Copyright (c) 2010 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog starting a process and showing its output.
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
10 from PyQt6.QtCore import QCoreApplication, QEventLoop, Qt
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
13 from eric7 import Preferences, Utilities
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
15 from .Ui_HgDialog import Ui_HgDialog
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
17
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class HgDialog(QDialog, Ui_HgDialog):
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing a dialog starting a process and showing its output.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
21
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 It starts a QProcess and displays a dialog that
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 shows the output of the process. The dialog is modal,
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 which causes a synchronized execution of the process.
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
26
3310
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3302
diff changeset
27 def __init__(self, text, hg=None, useClient=True, parent=None):
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
30
10438
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
31 @param text text to be shown by the label
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
32 @type str
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
33 @param hg reference to the Mercurial interface object
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
34 @type Hg
3310
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3302
diff changeset
35 @param useClient flag indicating to use the command server client
10438
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
36 if possible
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
37 @type bool
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
38 @param parent parent widget
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
39 @type QWidget
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
41 super().__init__(parent)
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.setupUi(self)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8047
diff changeset
43 self.setWindowFlags(Qt.WindowType.Window)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
44
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
45 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
46 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
47
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
48 self.username = ""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
49 self.password = ""
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: 3290
diff changeset
50 self.vcs = hg
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
51
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.outputGroup.setTitle(text)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
53
1260
9488a3aceb0e Added code to some Mercurial dialogs to improve user experience.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1245
diff changeset
54 self.show()
9488a3aceb0e Added code to some Mercurial dialogs to improve user experience.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1245
diff changeset
55 QCoreApplication.processEvents()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
56
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 def __finish(self):
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
59 Private slot called when the process finished or the user pressed
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2771
diff changeset
60 the button.
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
62 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
63 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
64 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
65 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setFocus(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
66 Qt.FocusReason.OtherFocusReason
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
67 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
68
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
69 if (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
70 Preferences.getVCS("AutoClose")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
71 and self.normal
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
72 and self.errors.toPlainText() == ""
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
73 ):
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.accept()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
75
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 def on_buttonBox_clicked(self, button):
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 Private slot called by a button of the button box clicked.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
79
10438
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
80 @param button button that was clicked
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
81 @type QAbstractButton
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
83 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close):
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.close()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
85 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel):
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
86 self.vcs.getClient().cancel()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
87
10069
435cc5875135 Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
88 def startProcess(self, args, showArgs=True, client=None):
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 Public slot used to start the process.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
91
7971
ff2971513d6d Mercurial: completed more code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7970
diff changeset
92 @param args list of arguments for the process
ff2971513d6d Mercurial: completed more code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7970
diff changeset
93 @type list of str
ff2971513d6d Mercurial: completed more code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7970
diff changeset
94 @param showArgs flag indicating to show the arguments
ff2971513d6d Mercurial: completed more code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7970
diff changeset
95 @type bool
ff2971513d6d Mercurial: completed more code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7970
diff changeset
96 @param client reference to a non-standard command client
ff2971513d6d Mercurial: completed more code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7970
diff changeset
97 @type HgClient
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 @return flag indicating a successful start of the process
7971
ff2971513d6d Mercurial: completed more code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7970
diff changeset
99 @rtype bool
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.errorGroup.hide()
7441
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
102 self.inputGroup.hide()
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 self.normal = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
104
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 self.__hasAddOrDelete = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
106 if args[0] in [
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
107 "qpush",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
108 "qpop",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
109 "qgoto",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
110 "rebase",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
111 "update",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
112 "import",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
113 "revert",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
114 "graft",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
115 "shelve",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
116 "unshelve",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
117 "strip",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
118 "histedit",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
119 ] or (
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
120 args[0] in ["pull", "unbundle"]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
121 and ("--update" in args[1:] or "--rebase" in args[1:])
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
122 ):
660
7a1d92437921 Added code to check, if a pull --update modified the project structure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
123 self.__updateCommand = True
661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 660
diff changeset
124 else:
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 660
diff changeset
125 self.__updateCommand = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
126
189
17bb2db7a347 Added administration actions to the Mercurial plugin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 178
diff changeset
127 if showArgs:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
128 self.resultbox.append(" ".join(args))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
129 self.resultbox.append("")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
130
7971
ff2971513d6d Mercurial: completed more code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7970
diff changeset
131 if client is None:
ff2971513d6d Mercurial: completed more code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7970
diff changeset
132 client = self.vcs.getClient()
ff2971513d6d Mercurial: completed more code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7970
diff changeset
133 out, err = client.runcommand(
7441
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
134 args,
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
135 prompt=self.__getInput,
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
136 output=self.__showOutput,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
137 error=self.__showError,
7441
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
138 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
139
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
140 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
141 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
142 if out:
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 self.__showOutput(out)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
144
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
145 self.normal = True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
146
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
147 self.__finish()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
148
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
149 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
150
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 def normalExit(self):
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 Public method to check for a normal process termination.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
154
10438
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
155 @return flag indicating normal process termination
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
156 @rtype bool
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 return self.normal
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
159
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 def normalExitWithoutErrors(self):
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 Public method to check for a normal process termination without
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 error messages.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
164
10438
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
165 @return flag indicating normal process termination
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
166 @rtype bool
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 return self.normal and self.errors.toPlainText() == ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
169
1240
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
170 def __showOutput(self, out):
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
171 """
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
172 Private slot to show some output.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
173
10438
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
174 @param out output to be shown
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
175 @type str
1240
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
176 """
5020
d0afdfd8e45b Added capability to filter ANSI escape sequences out of output strings. This is limited to color sequences at the moment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
177 self.resultbox.insertPlainText(Utilities.filterAnsiSequences(out))
1240
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
178 self.resultbox.ensureCursorVisible()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
179
1240
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
180 # check for a changed project file
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
181 if self.__updateCommand:
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
182 for line in out.splitlines():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
183 if ".epj" in line or ".e4p" in line:
1240
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
184 self.__hasAddOrDelete = True
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
185 break
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
186
1006
ec194fa790d2 Slight improvement of the Mercurial interface with respect to responsiveness.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
187 QCoreApplication.processEvents()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
188
1240
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
189 def __showError(self, out):
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
190 """
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
191 Private slot to show some error.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
192
10438
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
193 @param out error to be shown
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
194 @type str
1240
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
195 """
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
196 self.errorGroup.show()
5020
d0afdfd8e45b Added capability to filter ANSI escape sequences out of output strings. This is limited to color sequences at the moment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
197 self.errors.insertPlainText(Utilities.filterAnsiSequences(out))
1240
4d5fc346bd3b Started implementing an interface to the Mercurial command server (as of Mercurial >= 1.9).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
198 self.errors.ensureCursorVisible()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
199
1006
ec194fa790d2 Slight improvement of the Mercurial interface with respect to responsiveness.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
200 QCoreApplication.processEvents()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
201
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 def hasAddOrDelete(self):
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 Public method to check, if the last action contained an add or delete.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
205
10438
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
206 @return flag indicating the presence of an add or delete
4cd7e5a8b3cf Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
207 @rtype bool
178
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 """
dd9f0bca5e2f Added plugin for Mercurial version control system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 return self.__hasAddOrDelete
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
210
7441
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
211 def __getInput(self, size, message):
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
212 """
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
213 Private method to get some input from the user.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
214
7441
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
215 @param size maximum length of the requested input
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
216 @type int
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
217 @param message message sent by the server
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
218 @type str
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
219 @return tuple containing data entered by the user and
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
220 a flag indicating a password input
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
221 @rtype tuple of (str, bool)
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
222 """
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
223 self.inputGroup.show()
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
224 self.input.setMaxLength(size)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8047
diff changeset
225 self.input.setFocus(Qt.FocusReason.OtherFocusReason)
7700
a3cf077a8db3 HgDialog: changed code to ensure, the last line is visible when the input pane is shown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7679
diff changeset
226
a3cf077a8db3 HgDialog: changed code to ensure, the last line is visible when the input pane is shown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7679
diff changeset
227 self.resultbox.ensureCursorVisible()
7736
751c47317591 HgDialog: some fine tuning when showing the input area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7735
diff changeset
228 self.errors.ensureCursorVisible()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
229
7441
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
230 loop = QEventLoop(self)
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
231 self.sendButton.clicked[bool].connect(loop.quit)
7735
c54ee930ecd8 HgDialog: fixed an issue handling the returnPressed signal of the input widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7700
diff changeset
232 self.input.returnPressed.connect(loop.quit)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7736
diff changeset
233 loop.exec()
7441
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
234 message = self.input.text() + "\n"
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
235 isPassword = self.passwordCheckBox.isChecked()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
236
7441
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
237 self.input.clear()
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
238 self.inputGroup.hide()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
239
7441
f115f4469795 HgDialog: extended the dialog to allow inputting user responses to client prompts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7370
diff changeset
240 return message, isPassword

eric ide

mercurial