Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostFingerprintDialog.py

changeset 5588
6ba512d9f46a
parent 5441
cd5343be7d72
child 6048
82ad8ec9548c
equal deleted inserted replaced
5587:ea526b78ee6c 5588:6ba512d9f46a
51 self.hashComboBox.addItems( 51 self.hashComboBox.addItems(
52 HgUserConfigHostFingerprintDialog.supportedHashes) 52 HgUserConfigHostFingerprintDialog.supportedHashes)
53 if self.__version < (3, 9, 0): 53 if self.__version < (3, 9, 0):
54 self.hashLabel.setEnabled(False) 54 self.hashLabel.setEnabled(False)
55 self.hashComboBox.setEnabled(False) 55 self.hashComboBox.setEnabled(False)
56 hash = "sha1" 56 hashType = "sha1"
57 else: 57 else:
58 if fingerprint and fingerprint.startswith("sha"): 58 if fingerprint and fingerprint.startswith("sha"):
59 hash, fingerprint = fingerprint.split(":", 1) 59 hashType, fingerprint = fingerprint.split(":", 1)
60 else: 60 else:
61 hash = "" 61 hashType = ""
62 62
63 index = self.hashComboBox.findText(hash) 63 index = self.hashComboBox.findText(hashType)
64 self.hashComboBox.setCurrentIndex(index) 64 self.hashComboBox.setCurrentIndex(index)
65 self.hostEdit.setText(host) 65 self.hostEdit.setText(host)
66 self.fingerprintEdit.setText(fingerprint) 66 self.fingerprintEdit.setText(fingerprint)
67 67
68 msh = self.minimumSizeHint() 68 msh = self.minimumSizeHint()
77 enabled = ( 77 enabled = (
78 bool(self.hostEdit.text()) and 78 bool(self.hostEdit.text()) and
79 bool(self.fingerprintEdit.text()) 79 bool(self.fingerprintEdit.text())
80 ) 80 )
81 if self.__version >= (3, 9, 0): 81 if self.__version >= (3, 9, 0):
82 hash = self.hashComboBox.currentText() 82 hashType = self.hashComboBox.currentText()
83 enabled &= bool(hash) 83 enabled &= bool(hashType)
84 if hash: 84 if hashType:
85 enabled &= ( 85 enabled &= (
86 len(self.fingerprintEdit.text().replace(":", "")) == 86 len(self.fingerprintEdit.text().replace(":", "")) ==
87 HgUserConfigHostFingerprintDialog.fingerprintLength[hash] 87 HgUserConfigHostFingerprintDialog.fingerprintLength[
88 ) 88 hashType])
89 89
90 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) 90 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
91 91
92 @pyqtSlot(str) 92 @pyqtSlot(str)
93 def on_hostEdit_textChanged(self, txt): 93 def on_hostEdit_textChanged(self, txt):
121 # get rid of whitespace 121 # get rid of whitespace
122 txt = txt.strip() 122 txt = txt.strip()
123 self.fingerprintEdit.setText(txt) 123 self.fingerprintEdit.setText(txt)
124 124
125 if txt.startswith(tuple( 125 if txt.startswith(tuple(
126 [h + ":" for h in 126 h + ":" for h in
127 HgUserConfigHostFingerprintDialog.supportedHashes])): 127 HgUserConfigHostFingerprintDialog.supportedHashes)):
128 parts = txt.split(":", 1) 128 parts = txt.split(":", 1)
129 if len(parts) == 2: 129 if len(parts) == 2:
130 self.fingerprintEdit.setText(parts[1]) 130 self.fingerprintEdit.setText(parts[1])
131 hashIndex = self.hashComboBox.findText(parts[0].strip()) 131 hashIndex = self.hashComboBox.findText(parts[0].strip())
132 if hashIndex > -1: 132 if hashIndex > -1:

eric ide

mercurial