Plugins/VcsPlugins/vcsMercurial/HgCommitDialog.py

changeset 5330
381665763704
parent 5329
ebec303b4e50
child 5389
9b1c800daff3
--- a/Plugins/VcsPlugins/vcsMercurial/HgCommitDialog.py	Wed Nov 16 20:03:45 2016 +0100
+++ b/Plugins/VcsPlugins/vcsMercurial/HgCommitDialog.py	Thu Nov 17 18:59:13 2016 +0100
@@ -9,14 +9,12 @@
 
 from __future__ import unicode_literals
 
-from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt
+from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QDateTime
 from PyQt5.QtWidgets import QWidget, QDialogButtonBox
 
 from .Ui_HgCommitDialog import Ui_HgCommitDialog
 
 
-# TODO: add capability to set the author
-# TODO: add capability to set date and time, 
 class HgCommitDialog(QWidget, Ui_HgCommitDialog):
     """
     Class implementing a dialog to enter the commit message.
@@ -63,6 +61,13 @@
             if len(message) > 60:
                 abbrMsg += "..."
             self.recentComboBox.addItem(abbrMsg, message)
+        
+        commitAuthors = self.__vcs.getPlugin().getPreferences('CommitAuthors')
+        self.authorComboBox.clear()
+        self.authorComboBox.addItem("")
+        self.authorComboBox.addItems(commitAuthors)
+        
+        self.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
     
     def on_buttonBox_clicked(self, button):
         """
@@ -102,9 +107,9 @@
         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
+            the last commit, a flag indicating to commit subrepositories as
+            well, name of the author and date/time of the commit
+        @rtype tuple of str, bool, bool, str, str
         """
         msg = self.logEdit.toPlainText()
         if msg:
@@ -117,8 +122,28 @@
             self.__vcs.getPlugin().setPreferences(
                 'Commits', commitMessages)
         
+        author = self.authorComboBox.currentText()
+        if author:
+            commitAuthors = \
+                self.__vcs.getPlugin().getPreferences('CommitAuthors')
+            if author in commitAuthors:
+                commitAuthors.remove(author)
+            commitAuthors.insert(0, author)
+            no = self.__vcs.getPlugin().getPreferences("CommitAuthorsLimit")
+            del commitAuthors[no:]
+            self.__vcs.getPlugin().setPreferences(
+                'CommitAuthors', commitAuthors)
+        
+        if self.dateTimeGroup.isChecked():
+            dateTime = \
+                self.dateTimeEdit.dateTime().toString("yyyy-MM-dd hh:mm")
+        else:
+            dateTime = ""
+        
         return (
             msg,
             self.amendCheckBox.isChecked(),
-            self.subrepoCheckBox.isChecked()
+            self.subrepoCheckBox.isChecked(),
+            author,
+            dateTime,
         )

eric ide

mercurial