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

Mon, 02 Dec 2024 15:48:03 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 02 Dec 2024 15:48:03 +0100
branch
eric7
changeset 11071
913935b0e580
parent 10439
21c28b0f9e41
child 11090
f5f5f5803935
permissions
-rw-r--r--

Mercurial Interface
- Extended the user configuration dialog to allow the (de-)activation of the 'fastexport' and 'uncommit' extensions.

5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
10439
21c28b0f9e41 Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
3 # Copyright (c) 2016 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to edit a host fingerprint.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
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
10 from PyQt6.QtCore import pyqtSlot
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
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
13 from .Ui_HgUserConfigHostFingerprintDialog import Ui_HgUserConfigHostFingerprintDialog
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
16 class HgUserConfigHostFingerprintDialog(QDialog, Ui_HgUserConfigHostFingerprintDialog):
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 Class implementing a dialog to edit a host fingerprint.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
20
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
21 supportedHashes = ("sha1", "sha256", "sha512")
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
22 fingerprintLength = {
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
23 "sha1": 40,
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
24 "sha256": 64,
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
25 "sha512": 128,
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
26 }
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
27
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
28 def __init__(self, parent=None, host="", fingerprint="", version=(0, 0, 0)):
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
31
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param parent reference to the parent widget
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @type QWidget
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param host host name
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @type str
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @param fingerprint fingerprint for the host
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 @type str
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
38 @param version Mercurial version info
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
39 @type tuple of three integers
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
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)
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.setupUi(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
43
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
44 self.__version = version
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
45
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
46 self.hashComboBox.addItem("")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
47 self.hashComboBox.addItems(HgUserConfigHostFingerprintDialog.supportedHashes)
11071
913935b0e580 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
48 if fingerprint and fingerprint.startswith("sha"):
913935b0e580 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
49 hashType, fingerprint = fingerprint.split(":", 1)
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
50 else:
11071
913935b0e580 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
51 hashType = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
52
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5441
diff changeset
53 index = self.hashComboBox.findText(hashType)
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
54 self.hashComboBox.setCurrentIndex(index)
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.hostEdit.setText(host)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.fingerprintEdit.setText(fingerprint)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
57
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
58 msh = self.minimumSizeHint()
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
59 self.resize(max(self.width(), msh.width()), msh.height())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
60
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
61 self.__updateOkButton()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
62
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
63 def __updateOkButton(self):
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
64 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
65 Private method to update the status of the Ok button.
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
66 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
67 enabled = bool(self.hostEdit.text()) and bool(self.fingerprintEdit.text())
11071
913935b0e580 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
68
913935b0e580 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
69 hashType = self.hashComboBox.currentText()
913935b0e580 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
70 enabled &= bool(hashType)
913935b0e580 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
71 if hashType:
913935b0e580 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
72 enabled &= (
913935b0e580 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
73 len(self.fingerprintEdit.text().replace(":", ""))
913935b0e580 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
74 == HgUserConfigHostFingerprintDialog.fingerprintLength[hashType]
913935b0e580 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
75 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
76
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
77 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enabled)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
78
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
79 @pyqtSlot(str)
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
80 def on_hostEdit_textChanged(self, txt):
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
81 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
82 Private slot to handle changes of the host edit.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
83
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
84 @param txt current text
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
85 @type str
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
86 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
87 self.__updateOkButton()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
88
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: 7923
diff changeset
89 @pyqtSlot(int)
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: 7923
diff changeset
90 def on_hashComboBox_currentIndexChanged(self, index):
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
91 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
92 Private slot to handle changes of the hash combo.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
93
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: 7923
diff changeset
94 @param index current index
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: 7923
diff changeset
95 @type int
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
96 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
97 self.__updateOkButton()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
98
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
99 @pyqtSlot(str)
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
100 def on_fingerprintEdit_textChanged(self, txt):
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
101 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
102 Private slot to handle changes of the fingerprint edit.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
103
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
104 @param txt current text
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
105 @type str
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
106 """
5441
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
107 if txt != txt.strip():
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
108 # get rid of whitespace
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
109 txt = txt.strip()
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
110 self.fingerprintEdit.setText(txt)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
111
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
112 if txt.startswith(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
113 tuple(h + ":" for h in HgUserConfigHostFingerprintDialog.supportedHashes)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
114 ):
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
115 parts = txt.split(":", 1)
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
116 if len(parts) == 2:
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
117 self.fingerprintEdit.setText(parts[1])
5441
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
118 hashIndex = self.hashComboBox.findText(parts[0].strip())
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
119 if hashIndex > -1:
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
120 self.hashComboBox.setCurrentIndex(hashIndex)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
121
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
122 self.__updateOkButton()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
123
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 def getData(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 Public method to retrieve the data.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
127
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 @return tuple containig the host name and the fingerprint
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 @rtype tuple of two str
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 """
11071
913935b0e580 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
131 fingerprint = "{0}:{1}".format(
913935b0e580 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
132 self.hashComboBox.currentText(), self.fingerprintEdit.text().strip()
8259
2bbec88047dd Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
133 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
134
5441
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
135 return self.hostEdit.text().strip(), fingerprint

eric ide

mercurial