eric7/Plugins/VcsPlugins/vcsSubversion/SvnUrlSelectionDialog.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) 2007 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the URLs for the svn diff command.
8 """
9
10 import re
11
12 from PyQt5.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QDialog
14
15 from E5Gui.E5Application import e5App
16 from E5Gui import E5MessageBox
17
18 from .Ui_SvnUrlSelectionDialog import Ui_SvnUrlSelectionDialog
19
20 import Utilities
21
22
23 class SvnUrlSelectionDialog(QDialog, Ui_SvnUrlSelectionDialog):
24 """
25 Class implementing a dialog to enter the URLs for the svn diff command.
26 """
27 def __init__(self, vcs, tagsList, branchesList, path, parent=None):
28 """
29 Constructor
30
31 @param vcs reference to the vcs object
32 @param tagsList list of tags (list of strings)
33 @param branchesList list of branches (list of strings)
34 @param path pathname to determine the repository URL from (string)
35 @param parent parent widget of the dialog (QWidget)
36 """
37 super().__init__(parent)
38 self.setupUi(self)
39
40 if vcs.version < (1, 4, 0):
41 self.summaryCheckBox.setEnabled(False)
42 self.summaryCheckBox.setChecked(False)
43
44 self.vcs = vcs
45 self.tagsList = tagsList
46 self.branchesList = branchesList
47
48 self.typeCombo1.addItems(["trunk/", "tags/", "branches/"])
49 self.typeCombo2.addItems(["trunk/", "tags/", "branches/"])
50
51 reposURL = self.vcs.svnGetReposName(path)
52 if reposURL is None:
53 E5MessageBox.critical(
54 self,
55 self.tr("Subversion Error"),
56 self.tr(
57 """The URL of the project repository could not be"""
58 """ retrieved from the working copy. The operation will"""
59 """ be aborted"""))
60 self.reject()
61 return
62
63 if self.vcs.otherData["standardLayout"]:
64 # determine the base path of the project in the repository
65 rx_base = re.compile('(.+/)(trunk|tags|branches).*')
66 match = rx_base.fullmatch(reposURL)
67 if match is None:
68 E5MessageBox.critical(
69 self,
70 self.tr("Subversion Error"),
71 self.tr(
72 """The URL of the project repository has an"""
73 """ invalid format. The list operation will"""
74 """ be aborted"""))
75 self.reject()
76 return
77
78 reposRoot = match.group(1)
79 self.repoRootLabel1.setText(reposRoot)
80 self.repoRootLabel2.setText(reposRoot)
81 else:
82 project = e5App().getObject('Project')
83 if (
84 Utilities.normcasepath(path) !=
85 Utilities.normcasepath(project.getProjectPath())
86 ):
87 path = project.getRelativePath(path)
88 reposURL = reposURL.replace(path, '')
89 self.repoRootLabel1.hide()
90 self.typeCombo1.hide()
91 self.labelCombo1.addItems([reposURL] + sorted(self.vcs.tagsList))
92 self.labelCombo1.setEnabled(True)
93 self.repoRootLabel2.hide()
94 self.typeCombo2.hide()
95 self.labelCombo2.addItems([reposURL] + sorted(self.vcs.tagsList))
96 self.labelCombo2.setEnabled(True)
97
98 msh = self.minimumSizeHint()
99 self.resize(max(self.width(), msh.width()), msh.height())
100
101 def __changeLabelCombo(self, labelCombo, type_):
102 """
103 Private method used to change the label combo depending on the
104 selected type.
105
106 @param labelCombo reference to the labelCombo object (QComboBox)
107 @param type_ type string (string)
108 """
109 if type_ == "trunk/":
110 labelCombo.clear()
111 labelCombo.setEditText("")
112 labelCombo.setEnabled(False)
113 elif type_ == "tags/":
114 labelCombo.clear()
115 labelCombo.clearEditText()
116 labelCombo.addItems(sorted(self.tagsList))
117 labelCombo.setEnabled(True)
118 elif type_ == "branches/":
119 labelCombo.clear()
120 labelCombo.clearEditText()
121 labelCombo.addItems(sorted(self.branchesList))
122 labelCombo.setEnabled(True)
123
124 @pyqtSlot(int)
125 def on_typeCombo1_currentIndexChanged(self, index):
126 """
127 Private slot called when the selected type was changed.
128
129 @param index index of the current item
130 @type int
131 """
132 type_ = self.typeCombo1.itemText(index)
133 self.__changeLabelCombo(self.labelCombo1, type_)
134
135 @pyqtSlot(int)
136 def on_typeCombo2_currentIndexChanged(self, index):
137 """
138 Private slot called when the selected type was changed.
139
140 @param index index of the current item
141 @type int
142 """
143 type_ = self.typeCombo2.itemText(index)
144 self.__changeLabelCombo(self.labelCombo2, type_)
145
146 def getURLs(self):
147 """
148 Public method to get the entered URLs.
149
150 @return tuple of list of two URL strings (list of strings) and
151 a flag indicating a diff summary (boolean)
152 """
153 if self.vcs.otherData["standardLayout"]:
154 url1 = (
155 self.repoRootLabel1.text() +
156 self.typeCombo1.currentText() +
157 self.labelCombo1.currentText()
158 )
159 url2 = (
160 self.repoRootLabel2.text() +
161 self.typeCombo2.currentText() +
162 self.labelCombo2.currentText()
163 )
164 else:
165 url1 = self.labelCombo1.currentText()
166 url2 = self.labelCombo2.currentText()
167
168 return [url1, url2], self.summaryCheckBox.isChecked()

eric ide

mercurial