eric7/Plugins/VcsPlugins/vcsSubversion/SvnMergeDialog.py

branch
eric7
changeset 8312
800c432b34c8
parent 8218
7c09585bd960
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2003 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the data for a merge operation.
8 """
9
10 import re
11
12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
13
14 from .Ui_SvnMergeDialog import Ui_SvnMergeDialog
15
16
17 class SvnMergeDialog(QDialog, Ui_SvnMergeDialog):
18 """
19 Class implementing a dialog to enter the data for a merge operation.
20 """
21 def __init__(self, mergelist1, mergelist2, targetlist, force=False,
22 parent=None):
23 """
24 Constructor
25
26 @param mergelist1 list of previously entered URLs/revisions
27 (list of strings)
28 @param mergelist2 list of previously entered URLs/revisions
29 (list of strings)
30 @param targetlist list of previously entered targets (list of strings)
31 @param force flag indicating a forced merge (boolean)
32 @param parent parent widget (QWidget)
33 """
34 super().__init__(parent)
35 self.setupUi(self)
36
37 self.forceCheckBox.setChecked(force)
38
39 self.rx_url = re.compile('(?:file:|svn:|svn+ssh:|http:|https:)//.+')
40 self.rx_rev = re.compile('\\d+')
41
42 self.tag1Combo.clear()
43 self.tag1Combo.addItems(mergelist1)
44 self.tag2Combo.clear()
45 self.tag2Combo.addItems(mergelist2)
46 self.targetCombo.clear()
47 self.targetCombo.addItems(targetlist)
48
49 self.okButton = self.buttonBox.button(
50 QDialogButtonBox.StandardButton.Ok)
51 self.okButton.setEnabled(False)
52
53 msh = self.minimumSizeHint()
54 self.resize(max(self.width(), msh.width()), msh.height())
55
56 def __enableOkButton(self):
57 """
58 Private method used to enable/disable the OK-button.
59 """
60 self.okButton.setDisabled(
61 self.tag1Combo.currentText() != "" or
62 self.tag2Combo.currentText() != "" or
63 not (
64 (bool(self.rx_url.fullmatch(self.tag1Combo.currentText())) and
65 bool(self.rx_url.fullmatch(self.tag2Combo.currentText()))) or
66 (bool(self.rx_rev.fullmatch(self.tag1Combo.currentText())) and
67 bool(self.rx_rev.fullmatch(self.tag2Combo.currentText())))
68 )
69 )
70
71 def on_tag1Combo_editTextChanged(self, text):
72 """
73 Private slot to handle the tag1Combo editTextChanged signal.
74
75 @param text text of the combo (string)
76 """
77 self.__enableOkButton()
78
79 def on_tag2Combo_editTextChanged(self, text):
80 """
81 Private slot to handle the tag2Combo editTextChanged signal.
82
83 @param text text of the combo (string)
84 """
85 self.__enableOkButton()
86
87 def getParameters(self):
88 """
89 Public method to retrieve the merge data.
90
91 @return tuple naming two tag names or two revisions, a target and
92 a flag indicating a forced merge (string, string, string, boolean)
93 """
94 return (self.tag1Combo.currentText(),
95 self.tag2Combo.currentText(),
96 self.targetCombo.currentText(),
97 self.forceCheckBox.isChecked())

eric ide

mercurial