Plugins/VcsPlugins/vcsMercurial/HgCommitDialog.py

changeset 5330
381665763704
parent 5329
ebec303b4e50
child 5389
9b1c800daff3
equal deleted inserted replaced
5329:ebec303b4e50 5330:381665763704
7 Module implementing a dialog to enter the commit message. 7 Module implementing a dialog to enter the commit message.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt 12 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QDateTime
13 from PyQt5.QtWidgets import QWidget, QDialogButtonBox 13 from PyQt5.QtWidgets import QWidget, QDialogButtonBox
14 14
15 from .Ui_HgCommitDialog import Ui_HgCommitDialog 15 from .Ui_HgCommitDialog import Ui_HgCommitDialog
16 16
17 17
18 # TODO: add capability to set the author
19 # TODO: add capability to set date and time,
20 class HgCommitDialog(QWidget, Ui_HgCommitDialog): 18 class HgCommitDialog(QWidget, Ui_HgCommitDialog):
21 """ 19 """
22 Class implementing a dialog to enter the commit message. 20 Class implementing a dialog to enter the commit message.
23 21
24 @signal accepted() emitted, if the dialog was accepted 22 @signal accepted() emitted, if the dialog was accepted
61 for message in commitMessages: 59 for message in commitMessages:
62 abbrMsg = message[:60] 60 abbrMsg = message[:60]
63 if len(message) > 60: 61 if len(message) > 60:
64 abbrMsg += "..." 62 abbrMsg += "..."
65 self.recentComboBox.addItem(abbrMsg, message) 63 self.recentComboBox.addItem(abbrMsg, message)
64
65 commitAuthors = self.__vcs.getPlugin().getPreferences('CommitAuthors')
66 self.authorComboBox.clear()
67 self.authorComboBox.addItem("")
68 self.authorComboBox.addItems(commitAuthors)
69
70 self.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
66 71
67 def on_buttonBox_clicked(self, button): 72 def on_buttonBox_clicked(self, button):
68 """ 73 """
69 Private slot called by a button of the button box clicked. 74 Private slot called by a button of the button box clicked.
70 75
100 def getCommitData(self): 105 def getCommitData(self):
101 """ 106 """
102 Public method to retrieve the entered data for the commit. 107 Public method to retrieve the entered data for the commit.
103 108
104 @return tuple containing the log message, a flag indicating to amend 109 @return tuple containing the log message, a flag indicating to amend
105 the last commit and a flag indicating to commit subrepositories 110 the last commit, a flag indicating to commit subrepositories as
106 as well 111 well, name of the author and date/time of the commit
107 @rtype tuple of str, bool, bool 112 @rtype tuple of str, bool, bool, str, str
108 """ 113 """
109 msg = self.logEdit.toPlainText() 114 msg = self.logEdit.toPlainText()
110 if msg: 115 if msg:
111 commitMessages = self.__vcs.getPlugin().getPreferences('Commits') 116 commitMessages = self.__vcs.getPlugin().getPreferences('Commits')
112 if msg in commitMessages: 117 if msg in commitMessages:
115 no = self.__vcs.getPlugin().getPreferences("CommitMessages") 120 no = self.__vcs.getPlugin().getPreferences("CommitMessages")
116 del commitMessages[no:] 121 del commitMessages[no:]
117 self.__vcs.getPlugin().setPreferences( 122 self.__vcs.getPlugin().setPreferences(
118 'Commits', commitMessages) 123 'Commits', commitMessages)
119 124
125 author = self.authorComboBox.currentText()
126 if author:
127 commitAuthors = \
128 self.__vcs.getPlugin().getPreferences('CommitAuthors')
129 if author in commitAuthors:
130 commitAuthors.remove(author)
131 commitAuthors.insert(0, author)
132 no = self.__vcs.getPlugin().getPreferences("CommitAuthorsLimit")
133 del commitAuthors[no:]
134 self.__vcs.getPlugin().setPreferences(
135 'CommitAuthors', commitAuthors)
136
137 if self.dateTimeGroup.isChecked():
138 dateTime = \
139 self.dateTimeEdit.dateTime().toString("yyyy-MM-dd hh:mm")
140 else:
141 dateTime = ""
142
120 return ( 143 return (
121 msg, 144 msg,
122 self.amendCheckBox.isChecked(), 145 self.amendCheckBox.isChecked(),
123 self.subrepoCheckBox.isChecked() 146 self.subrepoCheckBox.isChecked(),
147 author,
148 dateTime,
124 ) 149 )

eric ide

mercurial