eric6/Plugins/VcsPlugins/vcsMercurial/HgImportDialog.py

Tue, 02 Mar 2021 17:17:09 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 02 Mar 2021 17:17:09 +0100
changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
permissions
-rw-r--r--

Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.

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
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
40 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
41 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
42
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.__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
44 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
45
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 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
47 """
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 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
49 """
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 enabled = True
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
51 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
52 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
53
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
54 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
55 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
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 @pyqtSlot(str)
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
58 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
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 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
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 @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
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 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
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 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
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 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
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 @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
71 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
72 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
73 indicating to enforce the import
7414
d02ed92ef3b2 Updated source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7396
diff changeset
74 @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
75 """
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 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
77 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
78 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
79 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
80
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
81 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
82 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
83 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
84 self.forceCheckBox.isChecked())

eric ide

mercurial