--- a/Plugins/VcsPlugins/vcsMercurial/HgCommitDialog.py Wed Nov 16 19:12:01 2016 +0100 +++ b/Plugins/VcsPlugins/vcsMercurial/HgCommitDialog.py Wed Nov 16 20:03:45 2016 +0100 @@ -14,8 +14,6 @@ from .Ui_HgCommitDialog import Ui_HgCommitDialog -import Preferences - # TODO: add capability to set the author # TODO: add capability to set date and time, @@ -41,6 +39,8 @@ super(HgCommitDialog, self).__init__(parent, Qt.WindowFlags(Qt.Window)) self.setupUi(self) + self.__vcs = vcs + self.logEdit.setPlainText(msg) if mq: @@ -55,46 +55,14 @@ @param evt the event (QShowEvent) """ - self.recentCommitMessages = Preferences.toList( - Preferences.Prefs.settings.value('Mercurial/Commits')) + commitMessages = self.__vcs.getPlugin().getPreferences('Commits') self.recentComboBox.clear() self.recentComboBox.addItem("") - self.recentComboBox.addItems(self.recentCommitMessages) - - def logMessage(self): - """ - Public method to retrieve the log message. - - @return the log message (string) - """ - msg = self.logEdit.toPlainText() - if msg: - if msg in self.recentCommitMessages: - self.recentCommitMessages.remove(msg) - self.recentCommitMessages.insert(0, msg) - no = int(Preferences.Prefs.settings.value( - 'Mercurial/CommitMessages', 20)) - del self.recentCommitMessages[no:] - Preferences.Prefs.settings.setValue( - 'Mercurial/Commits', self.recentCommitMessages) - return msg - - def amend(self): - """ - Public method to retrieve the state of the amend flag. - - @return state of the amend flag (boolean) - """ - return self.amendCheckBox.isChecked() - - def commitSubrepositories(self): - """ - Public method to retrieve the state of the commit sub-repositories - flag. - - @return state of the sub-repositories flag (boolean) - """ - return self.subrepoCheckBox.isChecked() + for message in commitMessages: + abbrMsg = message[:60] + if len(message) > 60: + abbrMsg += "..." + self.recentComboBox.addItem(abbrMsg, message) def on_buttonBox_clicked(self, button): """ @@ -127,4 +95,30 @@ @param txt text of the selected entry (string) """ if txt: - self.logEdit.setPlainText(txt) + self.logEdit.setPlainText(self.recentComboBox.currentData()) + + def getCommitData(self): + """ + Public method to retrieve the entered data for the commit. + + @return tuple containing the log message, a flag indicating to amend + the last commit and a flag indicating to commit subrepositories + as well + @rtype tuple of str, bool, bool + """ + msg = self.logEdit.toPlainText() + if msg: + commitMessages = self.__vcs.getPlugin().getPreferences('Commits') + if msg in commitMessages: + commitMessages.remove(msg) + commitMessages.insert(0, msg) + no = self.__vcs.getPlugin().getPreferences("CommitMessages") + del commitMessages[no:] + self.__vcs.getPlugin().setPreferences( + 'Commits', commitMessages) + + return ( + msg, + self.amendCheckBox.isChecked(), + self.subrepoCheckBox.isChecked() + )