Plugins/VcsPlugins/vcsMercurial/HgGraftDialog.py

Sat, 14 Dec 2013 23:44:25 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sat, 14 Dec 2013 23:44:25 +0100
branch
Py2 comp.
changeset 3145
a9de05d4a22f
parent 3060
5883ce99ee12
child 3161
06f57a834adf
permissions
-rw-r--r--

# __IGNORE_WARNING__ added/ removed.

1655
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
2302
f29e9405c851 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1990
diff changeset
3 # Copyright (c) 2012 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
1655
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter the data for a graft session.
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
10 from __future__ import unicode_literals
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
11
1655
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt4.QtCore import pyqtSlot, QDateTime
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt4.QtGui import QDialog, QDialogButtonBox
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from .Ui_HgGraftDialog import Ui_HgGraftDialog
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class HgGraftDialog(QDialog, Ui_HgGraftDialog):
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing a dialog to enter the data for a graft session.
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
2543
eb9472947653 Added a 'Copy Changesets' button to the Mercurial log browser dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
22 def __init__(self, vcs, revs=None, parent=None):
1655
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Constructor
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
1990
7fee3661c4f9 Added support for --log and --dry-run to the hg graft operation and added code to disable the (deprecated) transplant menu for Mercurial 2.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1655
diff changeset
26 @param vcs reference to the VCS object (Hg)
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2543
diff changeset
27 @param revs list of revisions to show in the revisions pane (list of
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2543
diff changeset
28 strings)
1655
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param parent reference to the parent widget (QWidget)
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
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(HgGraftDialog, self).__init__(parent)
1655
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 self.setupUi(self)
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
1990
7fee3661c4f9 Added support for --log and --dry-run to the hg graft operation and added code to disable the (deprecated) transplant menu for Mercurial 2.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1655
diff changeset
35
7fee3661c4f9 Added support for --log and --dry-run to the hg graft operation and added code to disable the (deprecated) transplant menu for Mercurial 2.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1655
diff changeset
36 if vcs.version < (2, 3):
7fee3661c4f9 Added support for --log and --dry-run to the hg graft operation and added code to disable the (deprecated) transplant menu for Mercurial 2.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1655
diff changeset
37 self.logCheckBox.setEnabled(False)
7fee3661c4f9 Added support for --log and --dry-run to the hg graft operation and added code to disable the (deprecated) transplant menu for Mercurial 2.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1655
diff changeset
38 self.logCheckBox.setChecked(False)
7fee3661c4f9 Added support for --log and --dry-run to the hg graft operation and added code to disable the (deprecated) transplant menu for Mercurial 2.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1655
diff changeset
39 self.logCheckBox.setVisible(False)
2543
eb9472947653 Added a 'Copy Changesets' button to the Mercurial log browser dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
40
eb9472947653 Added a 'Copy Changesets' button to the Mercurial log browser dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
41 if revs:
eb9472947653 Added a 'Copy Changesets' button to the Mercurial log browser dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
42 self.revisionsEdit.setPlainText("\n".join(sorted(revs)))
1655
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.__updateOk()
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 def __updateOk(self):
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 Private slot to update the state of the OK button.
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 enable = self.revisionsEdit.toPlainText() != ""
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 if self.userGroup.isChecked():
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 enable = enable and \
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3023
diff changeset
53 (self.currentUserCheckBox.isChecked() or
1655
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.userEdit.text() != "")
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @pyqtSlot()
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 def on_revisionsEdit_textChanged(self):
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 Private slot to react upon changes of revisions.
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.__updateOk()
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @pyqtSlot(bool)
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 def on_userGroup_toggled(self, checked):
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 Private slot to handle changes of the user group state.
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 @param checked flag giving the checked state (boolean)
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.__updateOk()
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 @pyqtSlot(bool)
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 def on_currentUserCheckBox_toggled(self, checked):
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 Private slot to handle changes of the currentuser state.
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 @param checked flag giving the checked state (boolean)
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.__updateOk()
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @pyqtSlot(str)
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 def on_userEdit_textChanged(self, txt):
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 Private slot to handle changes of the user name.
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 @param txt text of the edit (string)
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.__updateOk()
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 def getData(self):
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 Public method to retrieve the entered data.
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 @return tuple with list of revisions, a tuple giving a
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 flag indicating to set the user, a flag indicating to use the
1990
7fee3661c4f9 Added support for --log and --dry-run to the hg graft operation and added code to disable the (deprecated) transplant menu for Mercurial 2.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1655
diff changeset
98 current user and the user name, another tuple giving a flag
1655
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 indicating to set the date, a flag indicating to use the
1990
7fee3661c4f9 Added support for --log and --dry-run to the hg graft operation and added code to disable the (deprecated) transplant menu for Mercurial 2.3.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1655
diff changeset
100 current date and the date, a flag indicating to append graft info
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2543
diff changeset
101 to the log message and a flag indicating a dry-run (list of
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2543
diff changeset
102 strings, (boolean, boolean, string), (boolean, boolean, string),
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2543
diff changeset
103 boolean, boolean)
1655
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 """
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 userData = (self.userGroup.isChecked(),
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 self.currentUserCheckBox.isChecked(),
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.userEdit.text())
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 dateData = (self.dateGroup.isChecked(),
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.currentDateCheckBox.isChecked(),
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.dateTimeEdit.dateTime().toString("yyyy-MM-dd hh:mm"))
d2b583fdde1c Added support for the graft command as of Mercurial 2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 return (self.revisionsEdit.toPlainText().strip().splitlines(),
3023
34ce20603bf7 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3008
diff changeset
112 userData, dateData,
34ce20603bf7 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3008
diff changeset
113 self.logCheckBox.isChecked(),
34ce20603bf7 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3008
diff changeset
114 self.dryRunCheckBox.isChecked())

eric ide

mercurial