eric6/Plugins/VcsPlugins/vcsPySvn/SvnUrlSelectionDialog.py

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

eric ide

mercurial