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

branch
eric7
changeset 11071
913935b0e580
parent 11069
f26aa3302090
child 11074
97f6160548a6
equal deleted inserted replaced
11070:5d354c287553 11071:913935b0e580
81 81
82 self.fingerprintsList.headerItem().setText( 82 self.fingerprintsList.headerItem().setText(
83 self.fingerprintsList.columnCount(), "" 83 self.fingerprintsList.columnCount(), ""
84 ) 84 )
85 self.protocolsList.headerItem().setText(self.protocolsList.columnCount(), "") 85 self.protocolsList.headerItem().setText(self.protocolsList.columnCount(), "")
86
87 if self.__version < (3, 9, 0):
88 self.disableTls10WarningCheckBox.setEnabled(False)
89 self.minimumProtocolComboBox.setEnabled(False)
90 self.minimumProtcolGroupBox.setEnabled(False)
91 86
92 self.tabWidget.setCurrentIndex(0) 87 self.tabWidget.setCurrentIndex(0)
93 88
94 self.__editor = None 89 self.__editor = None
95 90
113 self.__config["ui"] = {} 108 self.__config["ui"] = {}
114 self.__config["ui"]["username"] = "{0} <{1}>".format( 109 self.__config["ui"]["username"] = "{0} <{1}>".format(
115 self.userNameEdit.text(), 110 self.userNameEdit.text(),
116 self.emailEdit.text(), 111 self.emailEdit.text(),
117 ) 112 )
113
118 ################################################################### 114 ###################################################################
119 ## extensions section 115 ## extensions section
120 ################################################################### 116 ###################################################################
121 if "extensions" not in self.__config: 117 if "extensions" not in self.__config:
122 self.__config["extensions"] = {} 118 self.__config["extensions"] = {}
170 else: 166 else:
171 if "largefiles" in self.__config["extensions"]: 167 if "largefiles" in self.__config["extensions"]:
172 del self.__config["extensions"]["largefiles"] 168 del self.__config["extensions"]["largefiles"]
173 self.__config["extensions"]["#largefiles"] = "" 169 self.__config["extensions"]["#largefiles"] = ""
174 170
175 if self.closeheadCheckBox.isChecked() and self.__version >= (4, 8, 0): 171 if self.closeheadCheckBox.isChecked():
176 self.__config["extensions"]["closehead"] = "" 172 self.__config["extensions"]["closehead"] = ""
177 else: 173 else:
178 if "closehead" in self.__config["extensions"]: 174 if "closehead" in self.__config["extensions"]:
179 del self.__config["extensions"]["closehead"] 175 del self.__config["extensions"]["closehead"]
180 self.__config["extensions"]["#closehead"] = "" 176 self.__config["extensions"]["#closehead"] = ""
177
178 if self.fastexportCheckBox.isChecked():
179 self.__config["extensions"]["fastexport"] = ""
180 else:
181 if "fastexport" in self.__config["extensions"]:
182 del self.__config["extensions"]["fastexport"]
183 self.__config["extensions"]["#fastexport"] = ""
184
185 if self.uncommitCheckBox.isChecked():
186 self.__config["extensions"]["uncommit"] = ""
187 else:
188 if "uncommit" in self.__config["uncommit"]:
189 del self.__config["extensions"]["uncommit"]
190 self.__config["extensions"]["#uncommit"] = ""
191
181 ################################################################### 192 ###################################################################
182 ## http_proxy section 193 ## http_proxy section
183 ################################################################### 194 ###################################################################
184 if self.proxyHostEdit.text(): 195 if self.proxyHostEdit.text():
185 self.__config["http_proxy"] = { 196 self.__config["http_proxy"] = {
190 if self.proxyBypassEdit.text(): 201 if self.proxyBypassEdit.text():
191 self.__config["http_proxy"]["no"] = self.proxyBypassEdit.text() 202 self.__config["http_proxy"]["no"] = self.proxyBypassEdit.text()
192 else: 203 else:
193 if "http_proxy" in self.__config: 204 if "http_proxy" in self.__config:
194 del self.__config["http_proxy"] 205 del self.__config["http_proxy"]
206
195 ################################################################### 207 ###################################################################
196 ## hostfingerprints/hostsecurity section 208 ## hostfingerprints/hostsecurity section
197 ################################################################### 209 ###################################################################
198 if self.__version < (3, 9, 0): 210 #
199 # 211 # hostsecurity section
200 # delete hostsecurity section 212 #
201 # 213 if "hostsecurity" not in self.__config:
202 if "hostsecurity" in self.__config: 214 self.__config["hostsecurity"] = {}
203 del self.__config["hostsecurity"] 215
204 216 if self.fingerprintsList.topLevelItemCount() > 0:
205 # 217 self.__clearFingerprints()
206 # hostfingerprints section 218 fingerprints = self.__assembleFingerprints()
207 # 219 for host in fingerprints:
208 if self.fingerprintsList.topLevelItemCount() > 0: 220 key = "{0}:fingerprints".format(host)
209 self.__config["hostfingerprints"] = {} 221 self.__config["hostsecurity"][key] = ", ".join(fingerprints[host])
210 for row in range(self.fingerprintsList.topLevelItemCount()): 222 else:
211 itm = self.fingerprintsList.topLevelItem(row) 223 self.__clearFingerprints()
212 fingerprint = itm.text(1) 224
213 if fingerprint.startswith("sha1:"): 225 if self.disableTls10WarningCheckBox.isChecked():
214 fingerprint = fingerprint[5:] 226 disabletls10warning = "true"
215 self.__config["hostfingerprints"][itm.text(0)] = fingerprint 227 else:
216 else: 228 disabletls10warning = "false"
217 if "hostfingerprints" in self.__config: 229 self.__config["hostsecurity"]["disabletls10warning"] = disabletls10warning
218 del self.__config["hostfingerprints"] 230
219 else: 231 if self.minimumProtocolComboBox.currentIndex() == 0:
220 # 232 self.__config.remove_option("hostsecurity", "minimumprotocol")
221 # delete hostfingerprints section 233 else:
222 # 234 minimumProtocol = self.minimumProtocolComboBox.itemData(
223 if "hostfingerprints" in self.__config: 235 self.minimumProtocolComboBox.currentIndex()
224 del self.__config["hostfingerprints"] 236 )
225 237 self.__config["hostsecurity"]["minimumprotocol"] = minimumProtocol
226 # 238
227 # hostsecurity section 239 if self.protocolsList.topLevelItemCount() > 0:
228 # 240 self.__clearMinimumProtocols()
229 if "hostsecurity" not in self.__config: 241 minimumProtocols = self.__assembleMinimumProtocols()
230 self.__config["hostsecurity"] = {} 242 for host in minimumProtocols:
231 243 key = "{0}:minimumprotocol".format(host)
232 if self.fingerprintsList.topLevelItemCount() > 0: 244 self.__config["hostsecurity"][key] = minimumProtocols[host]
233 self.__clearFingerprints() 245 else:
234 fingerprints = self.__assembleFingerprints() 246 self.__clearMinimumProtocols()
235 for host in fingerprints: 247
236 key = "{0}:fingerprints".format(host) 248 if len(self.__config.options("hostsecurity")) == 0:
237 self.__config["hostsecurity"][key] = ", ".join(fingerprints[host]) 249 del self.__config["hostsecurity"]
238 else:
239 self.__clearFingerprints()
240
241 if self.disableTls10WarningCheckBox.isChecked():
242 disabletls10warning = "true"
243 else:
244 disabletls10warning = "false"
245 self.__config["hostsecurity"]["disabletls10warning"] = disabletls10warning
246
247 if self.minimumProtocolComboBox.currentIndex() == 0:
248 self.__config.remove_option("hostsecurity", "minimumprotocol")
249 else:
250 minimumProtocol = self.minimumProtocolComboBox.itemData(
251 self.minimumProtocolComboBox.currentIndex()
252 )
253 self.__config["hostsecurity"]["minimumprotocol"] = minimumProtocol
254
255 if self.protocolsList.topLevelItemCount() > 0:
256 self.__clearMinimumProtocols()
257 minimumProtocols = self.__assembleMinimumProtocols()
258 for host in minimumProtocols:
259 key = "{0}:minimumprotocol".format(host)
260 self.__config["hostsecurity"][key] = minimumProtocols[host]
261 else:
262 self.__clearMinimumProtocols()
263
264 if len(self.__config.options("hostsecurity")) == 0:
265 del self.__config["hostsecurity"]
266 ################################################################### 250 ###################################################################
267 251
268 cfgFile = getConfigPath() 252 cfgFile = getConfigPath()
269 with open(cfgFile, "w") as configFile: 253 with open(cfgFile, "w") as configFile:
270 self.__config.write(configFile) 254 self.__config.write(configFile)
300 "histedit" in self.__config["extensions"] 284 "histedit" in self.__config["extensions"]
301 ) 285 )
302 self.closeheadCheckBox.setChecked( 286 self.closeheadCheckBox.setChecked(
303 "closehead" in self.__config["extensions"] 287 "closehead" in self.__config["extensions"]
304 ) 288 )
305 self.closeheadCheckBox.setEnabled(self.__version >= (4, 8, 0)) 289 self.fastexportCheckBox.setChecked(
290 "fastexport" in self.__config["extensions"]
291 )
292 self.uncommitCheckBox.setChecked(
293 "uncommit" in self.__config["extensions"]
294 )
306 295
307 # step 3: extract large files information 296 # step 3: extract large files information
308 if "largefiles" in self.__config: 297 if "largefiles" in self.__config:
309 if "minsize" in self.__config["largefiles"]: 298 if "minsize" in self.__config["largefiles"]:
310 self.lfFileSizeSpinBox.setValue( 299 self.lfFileSizeSpinBox.setValue(
330 self.__config["http_proxy"]["passwd"] 319 self.__config["http_proxy"]["passwd"]
331 ) 320 )
332 if "no" in self.__config["http_proxy"]: 321 if "no" in self.__config["http_proxy"]:
333 self.proxyBypassEdit.setText(self.__config["http_proxy"]["no"]) 322 self.proxyBypassEdit.setText(self.__config["http_proxy"]["no"])
334 323
335 # step 5a: extract host fingerprints 324 # step 5: extract hostsecurity fingerprints
336 if "hostfingerprints" in self.__config:
337 for host in self.__config.options("hostfingerprints"):
338 if self.__version < (3, 9, 0):
339 QTreeWidgetItem(
340 self.fingerprintsList,
341 [host, self.__config["hostfingerprints"][host]],
342 )
343 else:
344 # convert to hostsecurity fingerprint
345 QTreeWidgetItem(
346 self.fingerprintsList,
347 [host, "sha1:" + self.__config["hostfingerprints"][host]],
348 )
349
350 # step 5b: extract hostsecurity fingerprints
351 if "hostsecurity" in self.__config: 325 if "hostsecurity" in self.__config:
352 for key in self.__config.options("hostsecurity"): 326 for key in self.__config.options("hostsecurity"):
353 if key.endswith(":fingerprints"): 327 if key.endswith(":fingerprints"):
354 host = key.replace(":fingerprints", "") 328 host = key.replace(":fingerprints", "")
355 fingerprints = self.__config["hostsecurity"][key].split(",") 329 fingerprints = self.__config["hostsecurity"][key].split(",")
356 for fingerprint in fingerprints: 330 for fingerprint in fingerprints:
357 if self.__version < (3, 9, 0):
358 # downgrade from a newer version
359 if fingerprint.startswith("sha1:"):
360 fingerprint = fingerprint[5:]
361 else:
362 # Mercurial < 3.9.0 supports sha1
363 # fingerprints only
364 continue
365 QTreeWidgetItem( 331 QTreeWidgetItem(
366 self.fingerprintsList, 332 self.fingerprintsList,
367 [host, fingerprint.replace("\\", "").strip()], 333 [host, fingerprint.replace("\\", "").strip()],
368 ) 334 )
369 335
415 self.gpgCheckBox.setChecked(False) 381 self.gpgCheckBox.setChecked(False)
416 self.queuesCheckBox.setChecked(False) 382 self.queuesCheckBox.setChecked(False)
417 self.rebaseCheckBox.setChecked(False) 383 self.rebaseCheckBox.setChecked(False)
418 self.histeditCheckBox.setChecked(False) 384 self.histeditCheckBox.setChecked(False)
419 self.closeheadCheckBox.setChecked(False) 385 self.closeheadCheckBox.setChecked(False)
386 self.fastexportCheckBox.setChecked(False)
387 self.uncommitCheckBox.setChecked(False)
420 self.largefilesCheckBox.setChecked(False) 388 self.largefilesCheckBox.setChecked(False)
421 389
422 self.lfFileSizeSpinBox.setValue(10) 390 self.lfFileSizeSpinBox.setValue(10)
423 self.lfFilePatternsEdit.clear() 391 self.lfFilePatternsEdit.clear()
424 self.lfUserCachePicker.clear() 392 self.lfUserCachePicker.clear()

eric ide

mercurial