Wed, 30 Dec 2020 11:00:05 +0100
Updated copyright for 2021.
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 | |
7923
91e843545d9a
Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
3 | # Copyright (c) 2011 - 2021 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 | |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
10 | from PyQt5.QtCore import pyqtSlot, QDateTime |
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
11 | from PyQt5.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 | |
4593
cc745fa6c914
Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
13 | from E5Gui.E5PathPicker import E5PathPickerModes |
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
|
14 | |
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 | 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
|
16 | |
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 | 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
|
19 | """ |
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 | 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
|
21 | """ |
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
|
22 | 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
|
23 | """ |
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 | 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
|
25 | |
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
|
26 | @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
|
27 | @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
|
28 | @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
|
29 | @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
|
30 | """ |
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2302
diff
changeset
|
31 | super(HgImportDialog, self).__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
|
32 | 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
|
33 | |
4593
cc745fa6c914
Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
34 | self.patchFilePicker.setMode(E5PathPickerModes.OpenFileMode) |
cc745fa6c914
Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
35 | 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
|
36 | "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
|
37 | |
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
|
38 | 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
|
39 | |
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
|
40 | self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(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
|
41 | |
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
|
42 | 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
|
43 | 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
|
44 | |
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
|
45 | 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
|
46 | """ |
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
|
47 | 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
|
48 | """ |
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
|
49 | enabled = True |
4593
cc745fa6c914
Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
50 | 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
|
51 | 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
|
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 | self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) |
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 | @pyqtSlot(str) |
4593
cc745fa6c914
Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
56 | 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
|
57 | """ |
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
|
58 | 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
|
59 | |
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 | @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
|
61 | """ |
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
|
62 | 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
|
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 | 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
|
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 | 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
|
67 | |
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 | @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
|
69 | 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
|
70 | 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
|
71 | indicating to enforce the import |
7414
d02ed92ef3b2
Updated source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7396
diff
changeset
|
72 | @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
|
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 | if self.dateEdit.dateTime() != 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
|
75 | date = self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm") |
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 | else: |
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 | date = "" |
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
|
78 | |
4593
cc745fa6c914
Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
79 | 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
|
80 | 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
|
81 | 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
|
82 | self.forceCheckBox.isChecked()) |