eric6/Plugins/VcsPlugins/vcsMercurial/HgExportDialog.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e 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>
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter data for the Mercurial export command.
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
12 from PyQt5.QtCore import pyqtSlot, QDir
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
15 from E5Gui.E5PathPicker import E5PathPickerModes
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from .Ui_HgExportDialog import Ui_HgExportDialog
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 class HgExportDialog(QDialog, Ui_HgExportDialog):
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
6047
39586a2de99d Fixed some forgotten source code documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
22 Class implementing a dialog to enter data for the Mercurial export command.
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
6462
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
24 def __init__(self, bookmarksList, bookmarkAvailable, parent=None):
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Constructor
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
6462
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
28 @param bookmarksList list of defined bookmarks
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
29 @type list of str
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
30 @param bookmarkAvailable flag indicating the availability of the
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
31 "--bookmark" option
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
32 @type bool
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
33 @param parent reference to the parent widget
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
34 @type QWidget
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
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
36 super(HgExportDialog, self).__init__(parent)
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setupUi(self)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
39 self.directoryPicker.setMode(E5PathPickerModes.DirectoryMode)
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
40
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 # set default values for directory and pattern
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.patternEdit.setText("%b_%r_%h_%n_of_%N.diff")
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
45 self.directoryPicker.setText(QDir.tempPath())
6462
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
46
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
47 self.bookmarkCombo.addItem("")
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
48 self.bookmarkCombo.addItems(sorted(bookmarksList))
7110
948994b4f045 HgExportDialog: fixed a type causing an exception at runtime.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
49 self.bookmarkCombo.setEnabled(bookmarkAvailable)
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 def __updateOK(self):
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 Private slot to update the OK button.
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 enabled = True
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
57 if self.directoryPicker.text() == "":
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 enabled = False
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 elif self.patternEdit.text() == "":
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 enabled = False
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
61 elif (
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
62 self.changesetsEdit.toPlainText() == "" and
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
63 self.bookmarkCombo.currentText() == ""
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
64 ):
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 enabled = False
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 @pyqtSlot(str)
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
70 def on_directoryPicker_textChanged(self, txt):
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 Private slot to react on changes of the export directory edit.
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 @param txt contents of the line edit (string)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__updateOK()
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 @pyqtSlot(str)
2962
d6c9d1ca2da4 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
79 def on_patternEdit_textChanged(self, txt):
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 Private slot to react on changes of the export file name pattern edit.
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @param txt contents of the line edit (string)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.__updateOK()
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 @pyqtSlot()
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 def on_changesetsEdit_textChanged(self):
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 Private slot to react on changes of the changesets edit.
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.__updateOK()
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 def getParameters(self):
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 Public method to retrieve the export data.
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
2962
d6c9d1ca2da4 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
98 @return tuple naming the output file name, the list of revisions to
6462
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
99 export, the name of a bookmarked branch and flags indicating to
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
100 compare against the second parent, to treat all files as text,
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
101 to omit dates in the diff headers and to use the git extended
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
102 diff format
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
103 @rtype tuple of (str, list of str, str, bool, bool, bool, bool)
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 return (
2962
d6c9d1ca2da4 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
106 os.path.join(
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
107 self.directoryPicker.text(),
2962
d6c9d1ca2da4 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
108 self.patternEdit.text()),
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.changesetsEdit.toPlainText().splitlines(),
6462
58259e234dc9 hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6458
diff changeset
110 self.bookmarkCombo.currentText(),
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.switchParentCheckBox.isChecked(),
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.textCheckBox.isChecked(),
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.datesCheckBox.isChecked(),
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.gitCheckBox.isChecked()
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 )

eric ide

mercurial