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