Wed, 13 Jul 2022 14:55:47 +0200
Reformatted the source code using the 'Black' utility.
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
8881
54e42bc2437a
Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8629
diff
changeset
|
3 | # Copyright (c) 2011 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to enter data for the Mercurial import command. |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
10 | from PyQt6.QtCore import pyqtSlot, QDateTime |
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
11 | from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
8629
1b58dc890b87
Extended the Quick Commit (and other commit alike dialogs) to respect the project spell check language settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8358
diff
changeset
|
13 | from EricWidgets.EricApplication import ericApp |
8358
144a6b854f70
Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8356
diff
changeset
|
14 | from EricWidgets.EricPathPicker import EricPathPickerModes |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | from .Ui_HgImportDialog import Ui_HgImportDialog |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | class HgImportDialog(QDialog, Ui_HgImportDialog): |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | """ |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | Class implementing a dialog to enter data for the Mercurial import command. |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
23 | |
7396
c6399bce2c0b
Mercurial: added support for the '--secure' flag of hg import as of Mercurial 5.3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
24 | def __init__(self, vcs, parent=None): |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | """ |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
27 | |
7396
c6399bce2c0b
Mercurial: added support for the '--secure' flag of hg import as of Mercurial 5.3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
28 | @param vcs reference to the VCS object |
c6399bce2c0b
Mercurial: added support for the '--secure' flag of hg import as of Mercurial 5.3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
29 | @type Hg |
c6399bce2c0b
Mercurial: added support for the '--secure' flag of hg import as of Mercurial 5.3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
30 | @param parent reference to the parent widget |
c6399bce2c0b
Mercurial: added support for the '--secure' flag of hg import as of Mercurial 5.3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
31 | @type QWidget |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
33 | super().__init__(parent) |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | self.setupUi(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
35 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
36 | self.patchFilePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
37 | self.patchFilePicker.setFilters( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
38 | self.tr("Patch Files (*.diff *.patch);;All Files (*)") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
39 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | |
7396
c6399bce2c0b
Mercurial: added support for the '--secure' flag of hg import as of Mercurial 5.3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
41 | self.secretCheckBox.setEnabled(vcs.version >= (5, 3, 0)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
43 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | |
8629
1b58dc890b87
Extended the Quick Commit (and other commit alike dialogs) to respect the project spell check language settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8358
diff
changeset
|
45 | project = ericApp().getObject("Project") |
1b58dc890b87
Extended the Quick Commit (and other commit alike dialogs) to respect the project spell check language settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8358
diff
changeset
|
46 | pwl, pel = project.getProjectDictionaries() |
1b58dc890b87
Extended the Quick Commit (and other commit alike dialogs) to respect the project spell check language settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8358
diff
changeset
|
47 | language = project.getProjectSpellLanguage() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
48 | self.messageEdit.setLanguageWithPWL(language, pwl or None, pel or None) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
49 | |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | self.__initDateTime = QDateTime.currentDateTime() |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | self.dateEdit.setDateTime(self.__initDateTime) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
52 | |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | def __updateOK(self): |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | """ |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | Private slot to update the OK button. |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | """ |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | enabled = True |
4593
cc745fa6c914
Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
58 | if self.patchFilePicker.text() == "": |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | enabled = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
60 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
61 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
62 | |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | @pyqtSlot(str) |
4593
cc745fa6c914
Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
64 | def on_patchFilePicker_textChanged(self, txt): |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | """ |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | Private slot to react on changes of the patch file edit. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
67 | |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | @param txt contents of the line edit (string) |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | """ |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | self.__updateOK() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
71 | |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | def getParameters(self): |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | """ |
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | Public method to retrieve the import data. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
75 | |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | @return tuple naming the patch file, a flag indicating to not commit, |
7396
c6399bce2c0b
Mercurial: added support for the '--secure' flag of hg import as of Mercurial 5.3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
77 | a commit message, a commit date, a commit user, a flag indicating |
c6399bce2c0b
Mercurial: added support for the '--secure' flag of hg import as of Mercurial 5.3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
78 | to commit with the secret phase, a strip count and a flag |
c6399bce2c0b
Mercurial: added support for the '--secure' flag of hg import as of Mercurial 5.3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
79 | indicating to enforce the import |
7414
d02ed92ef3b2
Updated source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7396
diff
changeset
|
80 | @rtype tuple of (str, bool, str, str, str, bool, int, bool) |
1311
95685f9ad9f8
Added support for importing patches to the Mercurial interface and made it's revert action check, if the project should be reread.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | """ |
8259
2bbec88047dd
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
82 | date = ( |
2bbec88047dd
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
83 | self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
84 | if self.dateEdit.dateTime() != self.__initDateTime |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
85 | else "" |
8259
2bbec88047dd
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
86 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
87 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
88 | return ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
89 | self.patchFilePicker.text(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
90 | self.noCommitCheckBox.isChecked(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
91 | self.messageEdit.toPlainText(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
92 | date, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
93 | self.userEdit.text(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
94 | self.secretCheckBox.isChecked(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
95 | self.stripSpinBox.value(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
96 | self.forceCheckBox.isChecked(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
97 | ) |