eric6/Plugins/VcsPlugins/vcsMercurial/FetchExtension/HgFetchDialog.py

changeset 7679
5816200f021b
parent 7678
285c786c4a9c
child 7680
a2840715cfa0
equal deleted inserted replaced
7678:285c786c4a9c 7679:5816200f021b
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter data to be used for a fetch operation.
8 """
9
10
11 from PyQt5.QtCore import pyqtSlot
12 from PyQt5.QtWidgets import QDialog
13
14 from .Ui_HgFetchDialog import Ui_HgFetchDialog
15
16
17 class HgFetchDialog(QDialog, Ui_HgFetchDialog):
18 """
19 Class implementing a dialog to enter data to be used for a fetch operation.
20 """
21 def __init__(self, vcs, parent=None):
22 """
23 Constructor
24
25 @param vcs reference to the Mercurial vcs object
26 @type Hg
27 @param parent reference to the parent widget
28 @type QWidget
29 """
30 super(HgFetchDialog, self).__init__(parent)
31 self.setupUi(self)
32
33 self.__vcs = vcs
34
35 commitMessages = self.__vcs.getPlugin().getPreferences('Commits')
36 self.recentComboBox.clear()
37 self.recentComboBox.addItem("")
38 for message in commitMessages:
39 abbrMsg = message[:60]
40 if len(message) > 60:
41 abbrMsg += "..."
42 self.recentComboBox.addItem(abbrMsg, message)
43
44 @pyqtSlot(str)
45 def on_recentComboBox_activated(self, txt):
46 """
47 Private slot to select a commit message from recent ones.
48
49 @param txt text of the selected entry (string)
50 """
51 if txt:
52 self.messageEdit.setPlainText(self.recentComboBox.currentData())
53
54 def getData(self):
55 """
56 Public method to get the data for the fetch operation.
57
58 @return tuple with the commit message and a flag indicating to switch
59 the merge order (string, boolean)
60 """
61 msg = self.messageEdit.toPlainText()
62 if msg:
63 commitMessages = self.__vcs.getPlugin().getPreferences('Commits')
64 if msg in commitMessages:
65 commitMessages.remove(msg)
66 commitMessages.insert(0, msg)
67 no = self.__vcs.getPlugin().getPreferences("CommitMessages")
68 del commitMessages[no:]
69 self.__vcs.getPlugin().setPreferences(
70 'Commits', commitMessages)
71
72 return msg, self.switchCheckBox.isChecked()

eric ide

mercurial