Plugins/VcsPlugins/vcsMercurial/HgAddSubrepositoryDialog.py

Sat, 14 Dec 2013 23:44:25 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sat, 14 Dec 2013 23:44:25 +0100
branch
Py2 comp.
changeset 3145
a9de05d4a22f
parent 3058
0a02c433f52d
child 3161
06f57a834adf
permissions
-rw-r--r--

# __IGNORE_WARNING__ added/ removed.

1905
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
2302
f29e9405c851 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1910
diff changeset
3 # Copyright (c) 2012 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
1905
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
1906
8487f9c2533b Continued implementing support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1905
diff changeset
7 Module implementing a dialog to add a sub-repository.
1905
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3058
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
11
1905
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import os
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from PyQt4.QtCore import pyqtSlot
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from PyQt4.QtGui import QDialog, QDialogButtonBox
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from E5Gui import E5FileDialog, E5MessageBox
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 import Utilities
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 from .Ui_HgAddSubrepositoryDialog import Ui_HgAddSubrepositoryDialog
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 class HgAddSubrepositoryDialog(QDialog, Ui_HgAddSubrepositoryDialog):
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
1906
8487f9c2533b Continued implementing support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1905
diff changeset
26 Class implementing a dialog to add a sub-repository.
1905
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 def __init__(self, projectPath, parent=None):
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
2962
d6c9d1ca2da4 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
32 @param projectPath project directory name (string)
1905
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param parent reference to the parent widget (QWidget)
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
35 super(HgAddSubrepositoryDialog, self).__init__(parent)
1905
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.setupUi(self)
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.__ok = self.buttonBox.button(QDialogButtonBox.Ok)
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.__ok.setEnabled(False)
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__projectPath = projectPath
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.typeCombo.addItem("Mercurial", "hg")
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.typeCombo.addItem("GIT", "git")
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.typeCombo.addItem("Subversion", "svn")
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def __updateOk(self):
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Private slot to update the state of the OK button.
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 path = self.pathEdit.text()
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 url = self.urlEdit.text()
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__ok.setEnabled(
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 path != "" and
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 not os.path.isabs(path) and
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 url != ""
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 )
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 @pyqtSlot(str)
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 def on_pathEdit_textChanged(self, p0):
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 Private slot to handle the update of the path.
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @param p0 text of the path edit (string)
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 """
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.__updateOk()
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 @pyqtSlot(str)
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 def on_urlEdit_textChanged(self, p0):
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 """
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 Private slot to handle the update of the URL.
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 @param p0 text of the URL edit (string)
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__updateOk()
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 @pyqtSlot()
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 def on_pathButton_clicked(self):
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
81 Private slot to handle the path selection via a directory selection
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
82 dialog.
1905
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 """
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 path = E5FileDialog.getExistingDirectory(
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self,
1906
8487f9c2533b Continued implementing support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1905
diff changeset
86 self.trUtf8("Add Sub-repository"),
1905
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 os.path.join(self.__projectPath, self.pathEdit.text()),
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 E5FileDialog.Options(E5FileDialog.Option(0)))
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 if path:
1910
96641d9a10a2 Fixed an issue adding a sub-repository on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1906
diff changeset
91 path = Utilities.toNativeSeparators(path)
1905
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 if path.startswith(self.__projectPath):
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 path = path.replace(self.__projectPath, "")[1:]
1910
96641d9a10a2 Fixed an issue adding a sub-repository on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1906
diff changeset
94 self.pathEdit.setText(path)
1905
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3008
diff changeset
96 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3008
diff changeset
97 self,
1906
8487f9c2533b Continued implementing support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1905
diff changeset
98 self.trUtf8("Add Sub-repository"),
8487f9c2533b Continued implementing support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1905
diff changeset
99 self.trUtf8("""The sub-repository path must be inside"""
8487f9c2533b Continued implementing support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1905
diff changeset
100 """ the project."""))
1905
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 return
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 def getData(self):
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 """
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 Public method to get the data.
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106
3008
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
107 @return tuple containing the relative path within the project, the
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
108 sub-repository type and the sub-repository URL (string, string,
7848489bcb92 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
109 string)
1905
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 return (
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.pathEdit.text(),
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.typeCombo.itemData(self.typeCombo.currentIndex()),
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.urlEdit.text()
7ad9161c5293 Started adding support for Mercurial sub-repositories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 )

eric ide

mercurial