Thu, 07 Jul 2022 11:23:56 +0200
Reorganized the project structure to use the source layout in order to support up-to-date build systems with "pyproject.toml".
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 | """ |
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
|
23 | 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
|
24 | """ |
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 | Constructor |
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 | |
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
|
27 | @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
|
28 | @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
|
29 | @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
|
30 | @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
|
31 | """ |
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
|
32 | 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
|
33 | self.setupUi(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
|
34 | |
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
|
35 | self.patchFilePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
4593
cc745fa6c914
Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
36 | self.patchFilePicker.setFilters(self.tr( |
cc745fa6c914
Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
37 | "Patch Files (*.diff *.patch);;All Files (*)")) |
3186
a05eff845522
Changed all the file or directory selection buttons to QToolButton and gave them an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
38 | |
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
|
39 | self.secretCheckBox.setEnabled(vcs.version >= (5, 3, 0)) |
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
|
40 | |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
41 | self.buttonBox.button( |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
42 | QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
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
|
43 | |
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
|
44 | 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
|
45 | 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
|
46 | language = project.getProjectSpellLanguage() |
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 | self.messageEdit.setLanguageWithPWL( |
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
|
48 | language, pwl or None, pel or None) |
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
|
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) |
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
|
52 | |
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 |
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
|
60 | |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
61 | self.buttonBox.button( |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
62 | QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
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 | |
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
|
64 | @pyqtSlot(str) |
4593
cc745fa6c914
Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
65 | 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
|
66 | """ |
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
|
67 | Private slot to react on changes of the patch file edit. |
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 | |
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 | @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
|
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() |
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 | |
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. |
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 | |
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") |
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
|
85 | if self.dateEdit.dateTime() != self.__initDateTime else |
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 | "" |
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 | ) |
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
|
88 | |
4593
cc745fa6c914
Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
89 | return (self.patchFilePicker.text(), self.noCommitCheckBox.isChecked(), |
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
|
90 | self.messageEdit.toPlainText(), date, self.userEdit.text(), |
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
|
91 | self.secretCheckBox.isChecked(), self.stripSpinBox.value(), |
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
|
92 | self.forceCheckBox.isChecked()) |