eric6/Plugins/VcsPlugins/vcsMercurial/HgUserConfigDialog.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
3806
743e085ba266 Added forgotten file header to the Mercurial user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
4 #
743e085ba266 Added forgotten file header to the Mercurial user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
5
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter some user data.
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
10 import os
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7010
diff changeset
11 from configparser import ConfigParser
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
12
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
13 from PyQt5.QtCore import pyqtSlot, Qt, QEvent
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
14 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
16 from E5Gui.E5PathPicker import E5PathPickerModes
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
17 from E5Gui import E5MessageBox
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
18
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
19 import Globals
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
20
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
21 from .HgUtilities import getConfigPath
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
22 from .HgUserConfigHostFingerprintDialog import (
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
23 HgUserConfigHostFingerprintDialog
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
24 )
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
25 from .HgUserConfigHostMinimumProtocolDialog import (
5641
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
26 HgUserConfigHostMinimumProtocolDialog
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
27 )
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
28
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
29 from .Ui_HgUserConfigDialog import Ui_HgUserConfigDialog
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
31 import UI.PixmapCache
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
32
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
34 class HgUserConfigDialog(QDialog, Ui_HgUserConfigDialog):
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 Class implementing a dialog to enter some user data.
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
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: 5268
diff changeset
38 def __init__(self, version=(0, 0, 0), parent=None):
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 Constructor
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
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: 5268
diff changeset
42 @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: 5268
diff changeset
43 @type tuple of three integers
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: 5268
diff changeset
44 @param parent reference to the parent widget
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: 5268
diff changeset
45 @type QWidget
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
47 super(HgUserConfigDialog, self).__init__(parent)
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.setupUi(self)
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
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: 5268
diff changeset
50 self.__version = version
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: 5268
diff changeset
51
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
52 self.__minimumProtocols = {
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
53 "tls1.0": self.tr("TLS 1.0"),
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
54 "tls1.1": self.tr("TLS 1.1"),
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
55 "tls1.2": self.tr("TLS 1.2"),
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
56 }
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
57
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
58 self.lfUserCachePicker.setMode(E5PathPickerModes.DirectoryMode)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
59 if Globals.isLinuxPlatform():
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
60 self.lfUserCachePicker.setDefaultDirectory(os.path.expanduser(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
61 "~/.cache/largefiles"))
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
62 elif Globals.isMacPlatform():
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
63 self.lfUserCachePicker.setDefaultDirectory(os.path.expanduser(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
64 "~/Library/Caches/largefiles"))
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
65 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
66 self.lfUserCachePicker.setDefaultDirectory(os.path.expanduser(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
67 "~\\AppData\\Local\\largefiles"))
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
68
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
69 self.fpAddButton.setIcon(UI.PixmapCache.getIcon("plus"))
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
70 self.fpDeleteButton.setIcon(UI.PixmapCache.getIcon("minus"))
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
71 self.fpEditButton.setIcon(UI.PixmapCache.getIcon("edit"))
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
72
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
73 self.protocolAddButton.setIcon(UI.PixmapCache.getIcon("plus"))
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
74 self.protocolDeleteButton.setIcon(UI.PixmapCache.getIcon("minus"))
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
75 self.protocolEditButton.setIcon(UI.PixmapCache.getIcon("edit"))
5637
468856aafa10 Started to extend the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5629
diff changeset
76
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
77 self.minimumProtocolComboBox.addItem(self.tr("Default"), "")
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
78 for protocol in sorted(self.__minimumProtocols.keys()):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
79 self.minimumProtocolComboBox.addItem(
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
80 self.__minimumProtocols[protocol], protocol)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
81
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
82 self.fingerprintsList.headerItem().setText(
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
83 self.fingerprintsList.columnCount(), "")
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
84 self.protocolsList.headerItem().setText(
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
85 self.protocolsList.columnCount(), "")
5637
468856aafa10 Started to extend the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5629
diff changeset
86
468856aafa10 Started to extend the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5629
diff changeset
87 if self.__version < (3, 9, 0):
468856aafa10 Started to extend the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5629
diff changeset
88 self.disableTls10WarningCheckBox.setEnabled(False)
468856aafa10 Started to extend the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5629
diff changeset
89 self.minimumProtocolComboBox.setEnabled(False)
468856aafa10 Started to extend the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5629
diff changeset
90 self.minimumProtcolGroupBox.setEnabled(False)
468856aafa10 Started to extend the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5629
diff changeset
91
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
92 self.tabWidget.setCurrentIndex(0)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
93
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
94 self.__editor = None
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
96 self.__config = None
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
97 self.readUserConfig()
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
98
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
99 self.__updateFingerprintsButtons()
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
100 self.__updateProtocolsButtons()
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
101
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
102 def writeUserConfig(self):
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
103 """
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
104 Public method to write the user configuration file.
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
106 if self.__config is None:
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7010
diff changeset
107 self.__config = ConfigParser()
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
109 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
110 ## ui section
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
111 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
112 if "ui" not in self.__config:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
113 self.__config["ui"] = {}
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
114 self.__config["ui"]["username"] = "{0} <{1}>".format(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
115 self.userNameEdit.text(),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
116 self.emailEdit.text(),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
117 )
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
118 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
119 ## extensions section
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
120 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
121 if "extensions" not in self.__config:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
122 self.__config["extensions"] = {}
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
123
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 if self.gpgCheckBox.isChecked():
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
125 self.__config["extensions"]["gpg"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
126 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
127 if "gpg" in self.__config["extensions"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
128 del self.__config["extensions"]["gpg"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
129 self.__config["extensions"]["#gpg"] = ""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
130
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 if self.purgeCheckBox.isChecked():
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
132 self.__config["extensions"]["purge"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
133 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
134 if "purge" in self.__config["extensions"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
135 del self.__config["extensions"]["purge"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
136 self.__config["extensions"]["#purge"] = ""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
137
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 if self.queuesCheckBox.isChecked():
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
139 self.__config["extensions"]["mq"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
140 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
141 if "mq" in self.__config["extensions"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
142 del self.__config["extensions"]["mq"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
143 self.__config["extensions"]["#mq"] = ""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
144
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 if self.rebaseCheckBox.isChecked():
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
146 self.__config["extensions"]["rebase"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
147 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
148 if "rebase" in self.__config["extensions"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
149 del self.__config["extensions"]["rebase"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
150 self.__config["extensions"]["#rebase"] = ""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
151
3288
1a68ecb67c06 Started implementing support for the Mercurial Shelve extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3246
diff changeset
152 if self.shelveCheckBox.isChecked():
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
153 self.__config["extensions"]["shelve"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
154 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
155 if "shelve" in self.__config["extensions"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
156 del self.__config["extensions"]["shelve"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
157 self.__config["extensions"]["#shelve"] = ""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
158
5268
748e4c50523b Added support for the Mercurial strip extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5265
diff changeset
159 if self.stripCheckBox.isChecked():
748e4c50523b Added support for the Mercurial strip extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5265
diff changeset
160 self.__config["extensions"]["strip"] = ""
748e4c50523b Added support for the Mercurial strip extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5265
diff changeset
161 else:
748e4c50523b Added support for the Mercurial strip extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5265
diff changeset
162 if "strip" in self.__config["extensions"]:
748e4c50523b Added support for the Mercurial strip extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5265
diff changeset
163 del self.__config["extensions"]["strip"]
748e4c50523b Added support for the Mercurial strip extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5265
diff changeset
164 self.__config["extensions"]["#strip"] = ""
748e4c50523b Added support for the Mercurial strip extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5265
diff changeset
165
5299
1ecd89554ddb Added the histedit option to the Mercurial user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5295
diff changeset
166 if self.histeditCheckBox.isChecked():
1ecd89554ddb Added the histedit option to the Mercurial user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5295
diff changeset
167 self.__config["extensions"]["histedit"] = ""
1ecd89554ddb Added the histedit option to the Mercurial user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5295
diff changeset
168 else:
1ecd89554ddb Added the histedit option to the Mercurial user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5295
diff changeset
169 if "histedit" in self.__config["extensions"]:
1ecd89554ddb Added the histedit option to the Mercurial user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5295
diff changeset
170 del self.__config["extensions"]["histedit"]
1ecd89554ddb Added the histedit option to the Mercurial user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5295
diff changeset
171 self.__config["extensions"]["#histedit"] = ""
1ecd89554ddb Added the histedit option to the Mercurial user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5295
diff changeset
172
3308
955abb40a903 Started implementing support for the Mercurial largefiles extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3288
diff changeset
173 if self.largefilesCheckBox.isChecked():
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
174 self.__config["extensions"]["largefiles"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
175 ###############################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
176 ## largefiles section
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
177 ###############################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
178 if "largefiles" not in self.__config:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
179 self.__config["largefiles"] = {}
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
180 self.__config["largefiles"]["minsize"] = (
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
181 str(self.lfFileSizeSpinBox.value())
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
182 )
3308
955abb40a903 Started implementing support for the Mercurial largefiles extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3288
diff changeset
183 lfFilePatterns = self.lfFilePatternsEdit.text()
955abb40a903 Started implementing support for the Mercurial largefiles extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3288
diff changeset
184 if lfFilePatterns:
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
185 self.__config["largefiles"]["patterns"] = lfFilePatterns
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
186 elif "patterns" in self.__config["largefiles"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
187 del self.__config["largefiles"]["patterns"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
188 lfUserCache = self.lfUserCachePicker.text()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
189 if lfUserCache:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
190 self.__config["largefiles"]["usercache"] = lfUserCache
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
191 elif "usercache" in self.__config["largefiles"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
192 del self.__config["largefiles"]["usercache"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
193 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
194 if "largefiles" in self.__config["extensions"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
195 del self.__config["extensions"]["largefiles"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
196 self.__config["extensions"]["#largefiles"] = ""
7010
5d6f5a69a952 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
197
5d6f5a69a952 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
198 if self.closeheadCheckBox.isChecked() and self.__version >= (4, 8, 0):
5d6f5a69a952 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
199 self.__config["extensions"]["closehead"] = ""
5d6f5a69a952 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
200 else:
5d6f5a69a952 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
201 if "closehead" in self.__config["extensions"]:
5d6f5a69a952 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
202 del self.__config["extensions"]["closehead"]
5d6f5a69a952 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
203 self.__config["extensions"]["#closehead"] = ""
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
204 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
205 ## http_proxy section
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
206 ###################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
207 if self.proxyHostEdit.text():
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
208 self.__config["http_proxy"] = {
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
209 "host": self.proxyHostEdit.text(),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
210 "user": self.proxyUserEdit.text(),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
211 "passwd": self.proxyPasswordEdit.text()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
212 }
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
213 if self.proxyBypassEdit.text():
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
214 self.__config["http_proxy"]["no"] = (
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
215 self.proxyBypassEdit.text()
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
216 )
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
217 else:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
218 if "http_proxy" in self.__config:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
219 del self.__config["http_proxy"]
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
220 ###################################################################
5629
1df33bb9df28 Added a few TODO markers to the hg user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
221 ## hostfingerprints/hostsecurity section
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
222 ###################################################################
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: 5268
diff changeset
223 if self.__version < (3, 9, 0):
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: 5268
diff changeset
224 #
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: 5268
diff changeset
225 # delete hostsecurity section
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: 5268
diff changeset
226 #
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: 5268
diff changeset
227 if "hostsecurity" in self.__config:
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: 5268
diff changeset
228 del self.__config["hostsecurity"]
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: 5268
diff changeset
229
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: 5268
diff changeset
230 #
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: 5268
diff changeset
231 # hostfingerprints section
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: 5268
diff changeset
232 #
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: 5268
diff changeset
233 if self.fingerprintsList.topLevelItemCount() > 0:
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: 5268
diff changeset
234 self.__config["hostfingerprints"] = {}
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: 5268
diff changeset
235 for row in range(self.fingerprintsList.topLevelItemCount()):
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: 5268
diff changeset
236 itm = self.fingerprintsList.topLevelItem(row)
5340
abbb6f750607 Fixed an issue with the Mercurial user config dialog downgrading from a newer Mercurial version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5299
diff changeset
237 fingerprint = itm.text(1)
abbb6f750607 Fixed an issue with the Mercurial user config dialog downgrading from a newer Mercurial version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5299
diff changeset
238 if fingerprint.startswith("sha1:"):
abbb6f750607 Fixed an issue with the Mercurial user config dialog downgrading from a newer Mercurial version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5299
diff changeset
239 fingerprint = fingerprint[5:]
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
240 self.__config["hostfingerprints"][itm.text(0)] = (
5340
abbb6f750607 Fixed an issue with the Mercurial user config dialog downgrading from a newer Mercurial version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5299
diff changeset
241 fingerprint
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
242 )
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: 5268
diff changeset
243 else:
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: 5268
diff changeset
244 if "hostfingerprints" in self.__config:
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: 5268
diff changeset
245 del self.__config["hostfingerprints"]
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
246 else:
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: 5268
diff changeset
247 #
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: 5268
diff changeset
248 # delete hostfingerprints section
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: 5268
diff changeset
249 #
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
250 if "hostfingerprints" in self.__config:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
251 del self.__config["hostfingerprints"]
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: 5268
diff changeset
252
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: 5268
diff changeset
253 #
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: 5268
diff changeset
254 # hostsecurity section
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: 5268
diff changeset
255 #
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
256 if "hostsecurity" not in self.__config:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
257 self.__config["hostsecurity"] = {}
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
258
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: 5268
diff changeset
259 if self.fingerprintsList.topLevelItemCount() > 0:
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: 5268
diff changeset
260 self.__clearFingerprints()
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: 5268
diff changeset
261 fingerprints = self.__assembleFingerprints()
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: 5268
diff changeset
262 for host in fingerprints:
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: 5268
diff changeset
263 key = "{0}:fingerprints".format(host)
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
264 self.__config["hostsecurity"][key] = (
5295
87f1f8056814 Fixed a few issues in the new code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5292
diff changeset
265 ", ".join(fingerprints[host])
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
266 )
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: 5268
diff changeset
267 else:
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
268 self.__clearFingerprints()
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
269
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
270 if self.disableTls10WarningCheckBox.isChecked():
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
271 disabletls10warning = "true"
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
272 else:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
273 disabletls10warning = "false"
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
274 self.__config["hostsecurity"]["disabletls10warning"] = (
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
275 disabletls10warning
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
276 )
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
277
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
278 if self.minimumProtocolComboBox.currentIndex() == 0:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
279 self.__config.remove_option("hostsecurity", "minimumprotocol")
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
280 else:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
281 minimumProtocol = self.minimumProtocolComboBox.itemData(
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
282 self.minimumProtocolComboBox.currentIndex())
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
283 self.__config["hostsecurity"]["minimumprotocol"] = (
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
284 minimumProtocol
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
285 )
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
286
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
287 if self.protocolsList.topLevelItemCount() > 0:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
288 self.__clearMinimumProtocols()
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
289 minimumProtocols = self.__assembleMinimumProtocols()
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
290 for host in minimumProtocols:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
291 key = "{0}:minimumprotocol".format(host)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
292 self.__config["hostsecurity"][key] = minimumProtocols[host]
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
293 else:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
294 self.__clearMinimumProtocols()
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
295
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
296 if len(self.__config.options("hostsecurity")) == 0:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
297 del self.__config["hostsecurity"]
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
298 ###################################################################
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
299
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
300 cfgFile = getConfigPath()
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
301 with open(cfgFile, "w") as configFile:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
302 self.__config.write(configFile)
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
303
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
304 def readUserConfig(self):
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
305 """
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
306 Public method to read the user configuration file.
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
307 """
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
308 cfgFile = getConfigPath()
3231
a7c9914d1c41 Added dialogs to enter the contents for initial .hgrc/mercurial.ini and .hg/hgrc files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7010
diff changeset
310 self.__config = ConfigParser(delimiters=("=",))
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
311 if self.__config.read(cfgFile):
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
312 # step 1: extract user name and email
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
313 try:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
314 username = self.__config["ui"]["username"].strip()
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
315 if "<" in username and username.endswith(">"):
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
316 name, email = username[:-1].rsplit("<", 1)
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
317 else:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
318 name = username
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
319 email = ""
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
320 self.userNameEdit.setText(name.strip()),
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
321 self.emailEdit.setText(email.strip()),
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
322 except KeyError:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
323 pass
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
324
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
325 # step 2: extract extensions information
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
326 if "extensions" in self.__config:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
327 self.gpgCheckBox.setChecked(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
328 "gpg" in self.__config["extensions"])
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
329 self.purgeCheckBox.setChecked(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
330 "purge" in self.__config["extensions"])
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
331 self.queuesCheckBox.setChecked(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
332 "mq" in self.__config["extensions"])
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
333 self.rebaseCheckBox.setChecked(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
334 "rebase" in self.__config["extensions"])
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
335 self.shelveCheckBox.setChecked(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
336 "shelve" in self.__config["extensions"])
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
337 self.largefilesCheckBox.setChecked(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
338 "largefiles" in self.__config["extensions"])
5268
748e4c50523b Added support for the Mercurial strip extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5265
diff changeset
339 self.stripCheckBox.setChecked(
748e4c50523b Added support for the Mercurial strip extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5265
diff changeset
340 "strip" in self.__config["extensions"])
5299
1ecd89554ddb Added the histedit option to the Mercurial user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5295
diff changeset
341 self.histeditCheckBox.setChecked(
1ecd89554ddb Added the histedit option to the Mercurial user config dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5295
diff changeset
342 "histedit" in self.__config["extensions"])
7010
5d6f5a69a952 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
343 self.closeheadCheckBox.setChecked(
5d6f5a69a952 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
344 "closehead" in self.__config["extensions"])
5d6f5a69a952 Mercurial Interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
345 self.closeheadCheckBox.setEnabled(self.__version >= (4, 8, 0))
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
346
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
347 # step 3: extract large files information
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
348 if "largefiles" in self.__config:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
349 if "minsize" in self.__config["largefiles"]:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
350 self.lfFileSizeSpinBox.setValue(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
351 self.__config.getint("largefiles", "minsize"))
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
352 if "patterns" in self.__config["largefiles"]:
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
353 self.lfFilePatternsEdit.setText(
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
354 self.__config["largefiles"]["patterns"])
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
355 if "usercache" in self.__config["largefiles"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
356 self.lfUserCachePicker.setText(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
357 self.__config["largefiles"]["usercache"])
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
358
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
359 # step 4: extract http proxy information
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
360 if "http_proxy" in self.__config:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
361 if "host" in self.__config["http_proxy"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
362 self.proxyHostEdit.setText(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
363 self.__config["http_proxy"]["host"])
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
364 if "user" in self.__config["http_proxy"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
365 self.proxyUserEdit.setText(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
366 self.__config["http_proxy"]["user"])
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
367 if "passwd" in self.__config["http_proxy"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
368 self.proxyPasswordEdit.setText(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
369 self.__config["http_proxy"]["passwd"])
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
370 if "no" in self.__config["http_proxy"]:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
371 self.proxyBypassEdit.setText(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
372 self.__config["http_proxy"]["no"])
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
373
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: 5268
diff changeset
374 # step 5a: extract host fingerprints
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
375 if "hostfingerprints" in self.__config:
5265
787d87769425 Little fix to HgUserConfigDialog to make it compatible to Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
376 for host in self.__config.options("hostfingerprints"):
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: 5268
diff changeset
377 if self.__version < (3, 9, 0):
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: 5268
diff changeset
378 QTreeWidgetItem(self.fingerprintsList, [
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: 5268
diff changeset
379 host,
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: 5268
diff changeset
380 self.__config["hostfingerprints"][host]
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: 5268
diff changeset
381 ])
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: 5268
diff changeset
382 else:
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: 5268
diff changeset
383 # convert to hostsecurity fingerprint
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: 5268
diff changeset
384 QTreeWidgetItem(self.fingerprintsList, [
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: 5268
diff changeset
385 host,
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: 5268
diff changeset
386 "sha1:" + self.__config["hostfingerprints"][host]
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: 5268
diff changeset
387 ])
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: 5268
diff changeset
388
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: 5268
diff changeset
389 # step 5b: extract hostsecurity fingerprints
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: 5268
diff changeset
390 if "hostsecurity" in self.__config:
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: 5268
diff changeset
391 for key in self.__config.options("hostsecurity"):
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: 5268
diff changeset
392 if key.endswith(":fingerprints"):
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: 5268
diff changeset
393 host = key.replace(":fingerprints", "")
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
394 fingerprints = (
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: 5268
diff changeset
395 self.__config["hostsecurity"][key].split(",")
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
396 )
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: 5268
diff changeset
397 for fingerprint in fingerprints:
5340
abbb6f750607 Fixed an issue with the Mercurial user config dialog downgrading from a newer Mercurial version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5299
diff changeset
398 if self.__version < (3, 9, 0):
abbb6f750607 Fixed an issue with the Mercurial user config dialog downgrading from a newer Mercurial version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5299
diff changeset
399 # downgrade from a newer version
abbb6f750607 Fixed an issue with the Mercurial user config dialog downgrading from a newer Mercurial version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5299
diff changeset
400 if fingerprint.startswith("sha1:"):
abbb6f750607 Fixed an issue with the Mercurial user config dialog downgrading from a newer Mercurial version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5299
diff changeset
401 fingerprint = fingerprint[5:]
abbb6f750607 Fixed an issue with the Mercurial user config dialog downgrading from a newer Mercurial version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5299
diff changeset
402 else:
abbb6f750607 Fixed an issue with the Mercurial user config dialog downgrading from a newer Mercurial version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5299
diff changeset
403 # Mercurial < 3.9.0 supports sha1
abbb6f750607 Fixed an issue with the Mercurial user config dialog downgrading from a newer Mercurial version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5299
diff changeset
404 # fingerprints only
abbb6f750607 Fixed an issue with the Mercurial user config dialog downgrading from a newer Mercurial version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5299
diff changeset
405 continue
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: 5268
diff changeset
406 QTreeWidgetItem(self.fingerprintsList, [
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: 5268
diff changeset
407 host,
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: 5268
diff changeset
408 fingerprint.replace("\\", "").strip()
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: 5268
diff changeset
409 ])
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
410
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
411 elif key == "disabletls10warning":
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
412 self.disableTls10WarningCheckBox.setChecked(
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
413 self.__config.getboolean(
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
414 "hostsecurity", "disabletls10warning"))
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
415
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
416 elif key == "minimumprotocol":
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
417 minimumProtocol = self.__config["hostsecurity"][key]
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
418 index = self.minimumProtocolComboBox.findData(
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
419 minimumProtocol)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
420 if index == -1:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
421 index = 0
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
422 self.minimumProtocolComboBox.setCurrentIndex(index)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
423
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
424 elif key.endswith(":minimumprotocol"):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
425 host = key.replace(":minimumprotocol", "")
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
426 protocol = self.__config["hostsecurity"][key].strip()
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
427 if protocol in self.__minimumProtocols:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
428 itm = QTreeWidgetItem(self.protocolsList, [
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
429 host,
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
430 self.__minimumProtocols[protocol]
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
431 ])
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
432 itm.setData(1, Qt.UserRole, protocol)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
433
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
434 self.__finalizeFingerprintsColumns()
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
435 self.__finalizeProtocolsColumns()
5262
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
436
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
437 @pyqtSlot()
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
438 def accept(self):
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
439 """
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
440 Public slot to accept the dialog.
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
441 """
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
442 self.writeUserConfig()
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
443
235d6a030128 Continued refactoring the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5104
diff changeset
444 super(HgUserConfigDialog, self).accept()
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
445
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
446 def __clearDialog(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
447 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
448 Private method to clear the data of the dialog.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
449 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
450 self.userNameEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
451 self.emailEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
452
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
453 self.gpgCheckBox.setChecked(False)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
454 self.purgeCheckBox.setChecked(False)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
455 self.queuesCheckBox.setChecked(False)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
456 self.rebaseCheckBox.setChecked(False)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
457 self.shelveCheckBox.setChecked(False)
5268
748e4c50523b Added support for the Mercurial strip extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5265
diff changeset
458 self.stripCheckBox.setChecked(False)
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
459 self.largefilesCheckBox.setChecked(False)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
460 self.lfFileSizeSpinBox.setValue(10)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
461 self.lfFilePatternsEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
462 self.lfUserCachePicker.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
463
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
464 self.proxyHostEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
465 self.proxyUserEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
466 self.proxyPasswordEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
467 self.proxyBypassEdit.clear()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
468
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
469 self.fingerprintsList.clear()
5641
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
470 self.__finalizeFingerprintsColumns()
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
471 self.__updateFingerprintsButtons()
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
472
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
473 self.protocolsList.clear()
5641
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
474 self.__finalizeProtocolsColumns()
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
475 self.__updateProtocolsButtons()
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
476
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
477 #######################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
478 ## Methods and slots for the host fingerprint handling below
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
479 #######################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
480
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
481 def __clearFingerprints(self):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
482 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
483 Private method to clear the fingerprints from the hostsecurity section.
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
484 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
485 if "hostsecurity" in self.__config:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
486 for key in self.__config.options("hostsecurity"):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
487 if key.endswith(":fingerprints"):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
488 self.__config.remove_option("hostsecurity", key)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
489
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
490 def __assembleFingerprints(self):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
491 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
492 Private method to assemble a list of host fingerprints.
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
493
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
494 @return dictionary with list of fingerprints per host
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
495 @rtype dict with str as key and list of str as value
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
496 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
497 hostFingerprints = {}
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
498 for row in range(self.fingerprintsList.topLevelItemCount()):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
499 itm = self.fingerprintsList.topLevelItem(row)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
500 host = itm.text(0)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
501 fingerprint = itm.text(1)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
502 if host in hostFingerprints:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
503 hostFingerprints[host].append(fingerprint)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
504 else:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
505 hostFingerprints[host] = [fingerprint]
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
506 return hostFingerprints
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
507
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
508 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
509 def on_fingerprintsList_currentItemChanged(self, current, previous):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
510 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
511 Private slot handling a change of the current fingerprints item.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
512
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
513 @param current reference to the current item
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
514 @type QTreeWidgetItem
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
515 @param previous reference to the previous current item
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
516 @type QTreeWidgetItem
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
517 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
518 self.__updateFingerprintsButtons()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
519
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
520 @pyqtSlot()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
521 def on_fpAddButton_clicked(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
522 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
523 Private slot to add a fingerprints entry.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
524 """
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: 5268
diff changeset
525 dlg = HgUserConfigHostFingerprintDialog(self, version=self.__version)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7679
diff changeset
526 if dlg.exec() == QDialog.Accepted:
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
527 host, fingerprint = dlg.getData()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
528 itm = QTreeWidgetItem(self.fingerprintsList, [host, fingerprint])
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
529 self.__finalizeFingerprintsColumns()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
530 self.fingerprintsList.setCurrentItem(itm)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
531 self.fingerprintsList.scrollToItem(itm)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
532
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
533 @pyqtSlot()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
534 def on_fpDeleteButton_clicked(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
535 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
536 Private slot to delete the current fingerprints item.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
537 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
538 itm = self.fingerprintsList.currentItem()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
539 if itm is not None:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
540 host = itm.text(0)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
541 yes = E5MessageBox.yesNo(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
542 self,
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
543 self.tr("Delete Host Fingerprint"),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
544 self.tr("""<p>Shall the fingerprint for host <b>{0}</b>"""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
545 """ really be deleted?</p>""").format(host))
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
546 if yes:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
547 self.fingerprintsList.takeTopLevelItem(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
548 self.fingerprintsList.indexOfTopLevelItem(itm))
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
549 del itm
5641
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
550 self.__finalizeFingerprintsColumns()
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
551
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
552 @pyqtSlot()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
553 def on_fpEditButton_clicked(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
554 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
555 Private slot to edit the current fingerprints item.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
556 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
557 itm = self.fingerprintsList.currentItem()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
558 if itm is not None:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
559 host = itm.text(0)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
560 fingerprint = itm.text(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: 5268
diff changeset
561 dlg = HgUserConfigHostFingerprintDialog(self, host, fingerprint,
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: 5268
diff changeset
562 version=self.__version)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7679
diff changeset
563 if dlg.exec() == QDialog.Accepted:
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
564 host, fingerprint = dlg.getData()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
565 itm.setText(0, host)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
566 itm.setText(1, fingerprint)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
567 self.__finalizeFingerprintsColumns()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
568 self.fingerprintsList.scrollToItem(itm)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
569
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
570 def __finalizeFingerprintsColumns(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
571 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
572 Private method to resize and sort the host fingerprints columns.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
573 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
574 for col in range(self.fingerprintsList.columnCount()):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
575 self.fingerprintsList.resizeColumnToContents(col)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
576 self.fingerprintsList.sortItems(0, Qt.AscendingOrder)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
577
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
578 def __updateFingerprintsButtons(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
579 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
580 Private slot to update the host fingerprints edit buttons.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
581 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
582 enable = self.fingerprintsList.currentItem() is not None
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
583 self.fpDeleteButton.setEnabled(enable)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
584 self.fpEditButton.setEnabled(enable)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
585
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
586 #######################################################################
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
587 ## Methods and slots for the host minimum protocol handling below
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
588 #######################################################################
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
589
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
590 def __clearMinimumProtocols(self):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
591 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
592 Private method to clear the minimum protocols from the hostsecurity
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
593 section.
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
594 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
595 if "hostsecurity" in self.__config:
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
596 for key in self.__config.options("hostsecurity"):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
597 if key.endswith(":minimumprotocol"):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
598 self.__config.remove_option("hostsecurity", key)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
599
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
600 def __assembleMinimumProtocols(self):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
601 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
602 Private method to assemble a list of host minimum protocols.
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
603
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
604 @return dictionary with list of minimum protocol per host
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
605 @rtype dict with str as key and str as value
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
606 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
607 minimumProtocols = {}
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
608 for row in range(self.protocolsList.topLevelItemCount()):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
609 itm = self.protocolsList.topLevelItem(row)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
610 host = itm.text(0)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
611 minimumProtocol = itm.data(1, Qt.UserRole)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
612 minimumProtocols[host] = minimumProtocol
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
613 return minimumProtocols
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
614
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
615 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
616 def on_protocolsList_currentItemChanged(self, current, previous):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
617 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
618 Private slot handling a change of the current minimum protocol item.
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
619
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
620 @param current reference to the current item
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
621 @type QTreeWidgetItem
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
622 @param previous reference to the previous current item
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
623 @type QTreeWidgetItem
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
624 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
625 self.__updateProtocolsButtons()
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
626
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
627 @pyqtSlot()
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
628 def on_protocolAddButton_clicked(self):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
629 """
5641
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
630 Private slot to add a minimum protocol entry.
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
631 """
5641
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
632 dlg = HgUserConfigHostMinimumProtocolDialog(self.__minimumProtocols,
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
633 self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7679
diff changeset
634 if dlg.exec() == QDialog.Accepted:
5641
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
635 host, protocol = dlg.getData()
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
636 itm = QTreeWidgetItem(self.protocolsList, [
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
637 host,
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
638 self.__minimumProtocols[protocol]
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
639 ])
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
640 itm.setData(1, Qt.UserRole, protocol)
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
641 self.__finalizeProtocolsColumns()
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
642 self.protocolsList.setCurrentItem(itm)
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
643 self.protocolsList.scrollToItem(itm)
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
644
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
645 @pyqtSlot()
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
646 def on_protocolDeleteButton_clicked(self):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
647 """
5641
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
648 Private slot to delete the current minimum protocol item.
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
649 """
5641
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
650 itm = self.protocolsList.currentItem()
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
651 if itm is not None:
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
652 host = itm.text(0)
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
653 yes = E5MessageBox.yesNo(
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
654 self,
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
655 self.tr("Delete Host Minimum Protocol"),
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
656 self.tr("""<p>Shall the minimum protocol entry for host"""
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
657 """ <b>{0}</b> really be deleted?</p>""").format(host))
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
658 if yes:
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
659 self.protocolsList.takeTopLevelItem(
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
660 self.protocolsList.indexOfTopLevelItem(itm))
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
661 del itm
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
662 self.__finalizeProtocolsColumns()
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
663
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
664 @pyqtSlot()
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
665 def on_protocolEditButton_clicked(self):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
666 """
5641
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
667 Private slot to edit the current minimum protocol item.
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
668 """
5641
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
669 itm = self.protocolsList.currentItem()
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
670 if itm is not None:
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
671 host = itm.text(0)
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
672 protocol = itm.data(1, Qt.UserRole)
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
673 dlg = HgUserConfigHostMinimumProtocolDialog(
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
674 self.__minimumProtocols, self, host, protocol)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7679
diff changeset
675 if dlg.exec() == QDialog.Accepted:
5641
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
676 host, protocol = dlg.getData()
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
677 itm.setText(0, host)
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
678 itm.setText(1, self.__minimumProtocols[protocol])
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
679 itm.setData(1, Qt.UserRole, protocol)
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
680 self.__finalizeProtocolsColumns()
3ced21e990eb Extended the user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5640
diff changeset
681 self.protocolsList.scrollToItem(itm)
5640
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
682
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
683 def __finalizeProtocolsColumns(self):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
684 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
685 Private method to resize and sort the host fingerprints columns.
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
686 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
687 for col in range(self.protocolsList.columnCount()):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
688 self.protocolsList.resizeColumnToContents(col)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
689 self.protocolsList.sortItems(0, Qt.AscendingOrder)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
690
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
691 def __updateProtocolsButtons(self):
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
692 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
693 Private slot to update the host minimum protocol edit buttons.
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
694 """
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
695 enable = self.protocolsList.currentItem() is not None
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
696 self.protocolDeleteButton.setEnabled(enable)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
697 self.protocolEditButton.setEnabled(enable)
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
698
2e046f1818ed Continued extending the Mercurial user configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5637
diff changeset
699 #######################################################################
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
700 ## Slot to edit the user configuration in an editor below
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
701 #######################################################################
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
702
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
703 @pyqtSlot()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
704 def on_editorButton_clicked(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
705 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
706 Private slot to open the user configuration file in a text editor.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
707 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
708 from QScintilla.MiniEditor import MiniEditor
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
709 cfgFile = getConfigPath()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
710
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
711 yes = E5MessageBox.yesNo(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
712 self,
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
713 self.tr("Edit User Configuration"),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
714 self.tr("""You will loose all changes made in this dialog."""
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
715 """ Shall the data be saved first?"""),
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
716 icon=E5MessageBox.Warning,
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
717 yesDefault=True)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
718 if yes:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
719 self.writeUserConfig()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
720
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
721 self.__editor = MiniEditor(cfgFile, "Properties", self)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
722 self.__editor.setWindowModality(Qt.WindowModal)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
723 self.__editor.installEventFilter(self)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
724 self.__editor.show()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
725
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
726 def eventFilter(self, watched, event):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
727 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
728 Public method called to filter the event queue.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
729
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
730 @param watched reference to the object being watched
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
731 @type QObject
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
732 @param event event to be handled
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
733 @type QEvent
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
734 @return flag indicating, if we handled the event
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
735 @rtype bool
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
736 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
737 if watched is self.__editor and event.type() == QEvent.Close:
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
738 self.__editor.closeEvent(event)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
739 if event.isAccepted():
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
740 self.__clearDialog()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
741 self.readUserConfig()
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
742 return True
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
743
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5262
diff changeset
744 return False

eric ide

mercurial