Plugins/VcsPlugins/vcsMercurial/FetchExtension/HgFetchDialog.py

changeset 5512
f148796813d4
parent 5389
9b1c800daff3
child 6048
82ad8ec9548c
equal deleted inserted replaced
5511:54632671aa3b 5512:f148796813d4
12 from PyQt5.QtCore import pyqtSlot 12 from PyQt5.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QDialog 13 from PyQt5.QtWidgets import QDialog
14 14
15 from .Ui_HgFetchDialog import Ui_HgFetchDialog 15 from .Ui_HgFetchDialog import Ui_HgFetchDialog
16 16
17 import Preferences
18
19 17
20 class HgFetchDialog(QDialog, Ui_HgFetchDialog): 18 class HgFetchDialog(QDialog, Ui_HgFetchDialog):
21 """ 19 """
22 Class implementing a dialog to enter data to be used for a fetch operation. 20 Class implementing a dialog to enter data to be used for a fetch operation.
23 """ 21 """
24 def __init__(self, parent=None): 22 def __init__(self, vcs, parent=None):
25 """ 23 """
26 Constructor 24 Constructor
27 25
28 @param parent reference to the parent widget (QWidget) 26 @param vcs reference to the Mercurial vcs object
27 @type Hg
28 @param parent reference to the parent widget
29 @type QWidget
29 """ 30 """
30 super(HgFetchDialog, self).__init__(parent) 31 super(HgFetchDialog, self).__init__(parent)
31 self.setupUi(self) 32 self.setupUi(self)
32 33
33 self.recentCommitMessages = Preferences.toList( 34 self.__vcs = vcs
34 Preferences.Prefs.settings.value('Mercurial/Commits')) 35
36 commitMessages = self.__vcs.getPlugin().getPreferences('Commits')
35 self.recentComboBox.clear() 37 self.recentComboBox.clear()
36 self.recentComboBox.addItem("") 38 self.recentComboBox.addItem("")
37 self.recentComboBox.addItems(self.recentCommitMessages) 39 for message in commitMessages:
40 abbrMsg = message[:60]
41 if len(message) > 60:
42 abbrMsg += "..."
43 self.recentComboBox.addItem(abbrMsg, message)
38 44
39 @pyqtSlot(str) 45 @pyqtSlot(str)
40 def on_recentComboBox_activated(self, txt): 46 def on_recentComboBox_activated(self, txt):
41 """ 47 """
42 Private slot to select a commit message from recent ones. 48 Private slot to select a commit message from recent ones.
43 49
44 @param txt text of the selected entry (string) 50 @param txt text of the selected entry (string)
45 """ 51 """
46 if txt: 52 if txt:
47 self.messageEdit.setPlainText(txt) 53 self.messageEdit.setPlainText(self.recentComboBox.currentData())
48 54
49 def getData(self): 55 def getData(self):
50 """ 56 """
51 Public method to get the data for the fetch operation. 57 Public method to get the data for the fetch operation.
52 58
53 @return tuple with the commit message and a flag indicating to switch 59 @return tuple with the commit message and a flag indicating to switch
54 the merge order (string, boolean) 60 the merge order (string, boolean)
55 """ 61 """
56 msg = self.messageEdit.toPlainText() 62 msg = self.messageEdit.toPlainText()
57 if msg: 63 if msg:
58 if msg in self.recentCommitMessages: 64 commitMessages = self.__vcs.getPlugin().getPreferences('Commits')
59 self.recentCommitMessages.remove(msg) 65 if msg in commitMessages:
60 self.recentCommitMessages.insert(0, msg) 66 commitMessages.remove(msg)
61 no = int(Preferences.Prefs.settings.value( 67 commitMessages.insert(0, msg)
62 'Mercurial/CommitMessages', 20)) 68 no = self.__vcs.getPlugin().getPreferences("CommitMessages")
63 del self.recentCommitMessages[no:] 69 del commitMessages[no:]
64 Preferences.Prefs.settings.setValue( 70 self.__vcs.getPlugin().setPreferences(
65 'Mercurial/Commits', 71 'Commits', commitMessages)
66 self.recentCommitMessages)
67 72
68 return msg, self.switchCheckBox.isChecked() 73 return msg, self.switchCheckBox.isChecked()

eric ide

mercurial