Mon, 22 Apr 2024 18:23:20 +0200
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
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 | |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10438
diff
changeset
|
3 | # Copyright (c) 2011 - 2024 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 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
10 | from PyQt6.QtCore import QDateTime, pyqtSlot |
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
|
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 | |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
13 | from eric7.EricWidgets.EricApplication import ericApp |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
14 | from eric7.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) |
10690
fab36645aa7d
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
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 | |
10690
fab36645aa7d
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
68 | @param _txt contents of the line edit (unused) |
10438
4cd7e5a8b3cf
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
69 | @type str |
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
|
70 | """ |
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
|
71 | self.__updateOK() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
72 | |
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
|
73 | 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
|
74 | """ |
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
|
75 | 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
|
76 | |
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
|
77 | @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
|
78 | 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
|
79 | 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
|
80 | indicating to enforce the import |
7414
d02ed92ef3b2
Updated source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7396
diff
changeset
|
81 | @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
|
82 | """ |
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
|
83 | 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
|
84 | 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
|
85 | 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
|
86 | 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
|
87 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
88 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
89 | return ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
90 | self.patchFilePicker.text(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
91 | self.noCommitCheckBox.isChecked(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
92 | self.messageEdit.toPlainText(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
93 | date, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
94 | self.userEdit.text(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
95 | self.secretCheckBox.isChecked(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
96 | self.stripSpinBox.value(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
97 | self.forceCheckBox.isChecked(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
98 | ) |