Plugins/VcsPlugins/vcsMercurial/HgExportDialog.py

Mon, 25 Mar 2013 03:11:06 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Mon, 25 Mar 2013 03:11:06 +0100
branch
Py2 comp.
changeset 2525
8b507a9a2d40
parent 2302
f29e9405c851
child 3057
10516539f238
permissions
-rw-r--r--

Script changes: Future import added, super calls modified and unicode behavior for str.

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
2302
f29e9405c851 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2132
diff changeset
3 # Copyright (c) 2011 - 2013 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
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
10 from __future__ import unicode_literals # __IGNORE_WARNING__
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
11
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import os
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from PyQt4.QtCore import pyqtSlot, QDir
2132
8f013b041e8a Changed a few occurances of QFileDialog to E5FileDialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
15 from PyQt4.QtGui import QDialog, QDialogButtonBox
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 E5Gui import E5FileDialog
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from E5Gui.E5Completers import E5DirCompleter
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 from .Ui_HgExportDialog import Ui_HgExportDialog
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import Utilities
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 class HgExportDialog(QDialog, Ui_HgExportDialog):
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Class documentation goes here.
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 def __init__(self, parent=None):
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 Constructor
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param parent reference to the parent widget (QWidget)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
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
35 super(HgExportDialog, self).__init__(parent)
1315
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.setupUi(self)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.__directoryCompleter = E5DirCompleter(self.directoryEdit)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 # set default values for directory and pattern
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.patternEdit.setText("%b_%r_%h_%n_of_%N.diff")
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.directoryEdit.setText(QDir.tempPath())
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 def __updateOK(self):
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 Private slot to update the OK button.
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 enabled = True
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 if self.directoryEdit.text() == "":
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 enabled = False
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 elif self.patternEdit.text() == "":
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 enabled = False
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 elif self.changesetsEdit.toPlainText() == "":
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 enabled = False
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 @pyqtSlot(str)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 def on_directoryEdit_textChanged(self, p0):
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 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
65
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @param txt contents of the line edit (string)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.__updateOK()
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 @pyqtSlot()
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 def on_directoryButton_clicked(self):
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 Private slot called by pressing the export directory selection button.
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 dn = E5FileDialog.getExistingDirectory(
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self,
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.trUtf8("Export Patches"),
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.directoryEdit.text(),
2132
8f013b041e8a Changed a few occurances of QFileDialog to E5FileDialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
79 E5FileDialog.Options(E5FileDialog.Option(0)))
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 if dn:
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.directoryEdit.setText(Utilities.toNativeSeparators(dn))
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @pyqtSlot(str)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 def on_patternEdit_textChanged(self, p0):
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 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
88
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 @param txt contents of the line edit (string)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.__updateOK()
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 @pyqtSlot()
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 def on_changesetsEdit_textChanged(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 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
97
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 @param txt contents of the line edit (string)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 self.__updateOK()
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 def getParameters(self):
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 Public method to retrieve the export data.
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 @return tuple naming the output file name, the list of revisions to export,
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 and flags indicating to compare against the second parent, to treat all
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 files as text, to omit dates in the diff headers and to use the git extended
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 diff format (string, list of strings, boolean, boolean, boolean, boolean)
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 return (
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 os.path.join(Utilities.toNativeSeparators(self.directoryEdit.text()),
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.patternEdit.text()),
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.changesetsEdit.toPlainText().splitlines(),
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 self.switchParentCheckBox.isChecked(),
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.textCheckBox.isChecked(),
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self.datesCheckBox.isChecked(),
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.gitCheckBox.isChecked()
faafd2aa48d5 Added support for exporting patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 )

eric ide

mercurial