Plugins/VcsPlugins/vcsPySvn/subversion.py

branch
Py2 comp.
changeset 3058
0a02c433f52d
parent 3057
10516539f238
parent 3024
17c01303a239
child 3060
5883ce99ee12
equal deleted inserted replaced
3057:10516539f238 3058:0a02c433f52d
197 @param vcsDataDict dictionary of data required for the conversion 197 @param vcsDataDict dictionary of data required for the conversion
198 @param project reference to the project object 198 @param project reference to the project object
199 """ 199 """
200 success = self.vcsImport(vcsDataDict, project.ppath)[0] 200 success = self.vcsImport(vcsDataDict, project.ppath)[0]
201 if not success: 201 if not success:
202 E5MessageBox.critical(self.__ui, 202 E5MessageBox.critical(
203 self.__ui,
203 self.trUtf8("Create project in repository"), 204 self.trUtf8("Create project in repository"),
204 self.trUtf8( 205 self.trUtf8(
205 """The project could not be created in the repository.""" 206 """The project could not be created in the repository."""
206 """ Maybe the given repository doesn't exist or the""" 207 """ Maybe the given repository doesn't exist or the"""
207 """ repository server is down.""")) 208 """ repository server is down."""))
220 self.vcsCommit(project.ppath, vcsDataDict["message"], True) 221 self.vcsCommit(project.ppath, vcsDataDict["message"], True)
221 pfn = project.pfile 222 pfn = project.pfile
222 if not os.path.isfile(pfn): 223 if not os.path.isfile(pfn):
223 pfn += "z" 224 pfn += "z"
224 if not os.path.isfile(pfn): 225 if not os.path.isfile(pfn):
225 E5MessageBox.critical(self.__ui, 226 E5MessageBox.critical(
227 self.__ui,
226 self.trUtf8("New project"), 228 self.trUtf8("New project"),
227 self.trUtf8( 229 self.trUtf8(
228 """The project could not be checked out of the""" 230 """The project could not be checked out of the"""
229 """ repository.<br />""" 231 """ repository.<br />"""
230 """Restoring the original contents.""")) 232 """Restoring the original contents."""))
347 if not tag.startswith('tags') and \ 349 if not tag.startswith('tags') and \
348 not tag.startswith('branches'): 350 not tag.startswith('branches'):
349 type_, ok = QInputDialog.getItem( 351 type_, ok = QInputDialog.getItem(
350 None, 352 None,
351 self.trUtf8("Subversion Checkout"), 353 self.trUtf8("Subversion Checkout"),
352 self.trUtf8("The tag must be a normal tag (tags) or" 354 self.trUtf8(
355 "The tag must be a normal tag (tags) or"
353 " a branch tag (branches)." 356 " a branch tag (branches)."
354 " Please select from the list."), 357 " Please select from the list."),
355 self.tagTypeList, 358 self.tagTypeList,
356 0, False) 359 0, False)
357 if not ok: 360 if not ok:
411 if not tag.startswith('tags') and \ 414 if not tag.startswith('tags') and \
412 not tag.startswith('branches'): 415 not tag.startswith('branches'):
413 type_, ok = QInputDialog.getItem( 416 type_, ok = QInputDialog.getItem(
414 None, 417 None,
415 self.trUtf8("Subversion Export"), 418 self.trUtf8("Subversion Export"),
416 self.trUtf8("The tag must be a normal tag (tags) or" 419 self.trUtf8(
420 "The tag must be a normal tag (tags) or"
417 " a branch tag (branches)." 421 " a branch tag (branches)."
418 " Please select from the list."), 422 " Please select from the list."),
419 self.tagTypeList, 423 self.tagTypeList,
420 0, False) 424 0, False)
421 if not ok: 425 if not ok:
507 ok &= editor.checkDirty() 511 ok &= editor.checkDirty()
508 if not ok: 512 if not ok:
509 break 513 break
510 514
511 if not ok: 515 if not ok:
512 res = E5MessageBox.yesNo(self.__ui, 516 res = E5MessageBox.yesNo(
517 self.__ui,
513 self.trUtf8("Commit Changes"), 518 self.trUtf8("Commit Changes"),
514 self.trUtf8( 519 self.trUtf8(
515 """The commit affects files, that have unsaved""" 520 """The commit affects files, that have unsaved"""
516 """ changes. Shall the commit be continued?"""), 521 """ changes. Shall the commit be continued?"""),
517 icon=E5MessageBox.Warning) 522 icon=E5MessageBox.Warning)
575 rev = None 580 rev = None
576 if not noDialog: 581 if not noDialog:
577 dlg.showError(e.args[0]) 582 dlg.showError(e.args[0])
578 locker.unlock() 583 locker.unlock()
579 if not noDialog: 584 if not noDialog:
580 rev and dlg.showMessage(self.trUtf8("Committed revision {0}.")\ 585 rev and dlg.showMessage(self.trUtf8("Committed revision {0}.")
581 .format(rev.number)) 586 .format(rev.number))
582 dlg.finish() 587 dlg.finish()
583 dlg.exec_() 588 dlg.exec_()
584 os.chdir(cwd) 589 os.chdir(cwd)
585 self.committed.emit() 590 self.committed.emit()
586 self.checkVCSStatus() 591 self.checkVCSStatus()
1033 """ 1038 """
1034 dname, fname = self.splitPath(name) 1039 dname, fname = self.splitPath(name)
1035 1040
1036 reposURL = self.svnGetReposName(dname) 1041 reposURL = self.svnGetReposName(dname)
1037 if reposURL is None: 1042 if reposURL is None:
1038 E5MessageBox.critical(self.__ui, 1043 E5MessageBox.critical(
1044 self.__ui,
1039 self.trUtf8("Subversion Error"), 1045 self.trUtf8("Subversion Error"),
1040 self.trUtf8( 1046 self.trUtf8(
1041 """The URL of the project repository could not be""" 1047 """The URL of the project repository could not be"""
1042 """ retrieved from the working copy. The tag operation""" 1048 """ retrieved from the working copy. The tag operation"""
1043 """ will be aborted""")) 1049 """ will be aborted"""))
1059 return 1065 return
1060 1066
1061 if self.otherData["standardLayout"]: 1067 if self.otherData["standardLayout"]:
1062 rx_base = QRegExp('(.+)/(trunk|tags|branches).*') 1068 rx_base = QRegExp('(.+)/(trunk|tags|branches).*')
1063 if not rx_base.exactMatch(reposURL): 1069 if not rx_base.exactMatch(reposURL):
1064 E5MessageBox.critical(self.__ui, 1070 E5MessageBox.critical(
1071 self.__ui,
1065 self.trUtf8("Subversion Error"), 1072 self.trUtf8("Subversion Error"),
1066 self.trUtf8("""The URL of the project repository has an""" 1073 self.trUtf8(
1074 """The URL of the project repository has an"""
1067 """ invalid format. The tag operation will""" 1075 """ invalid format. The tag operation will"""
1068 """ be aborted""")) 1076 """ be aborted"""))
1069 return 1077 return
1070 1078
1071 reposRoot = rx_base.cap(1) 1079 reposRoot = rx_base.cap(1)
1128 project = e5App().getObject("Project") 1136 project = e5App().getObject("Project")
1129 names = [project.getRelativePath(nam) for nam in name] 1137 names = [project.getRelativePath(nam) for nam in name]
1130 if names[0]: 1138 if names[0]:
1131 from UI.DeleteFilesConfirmationDialog import \ 1139 from UI.DeleteFilesConfirmationDialog import \
1132 DeleteFilesConfirmationDialog 1140 DeleteFilesConfirmationDialog
1133 dia = DeleteFilesConfirmationDialog(self.parent(), 1141 dia = DeleteFilesConfirmationDialog(
1142 self.parent(),
1134 self.trUtf8("Revert changes"), 1143 self.trUtf8("Revert changes"),
1135 self.trUtf8( 1144 self.trUtf8(
1136 "Do you really want to revert all changes to these files" 1145 "Do you really want to revert all changes to these files"
1137 " or directories?"), 1146 " or directories?"),
1138 name) 1147 name)
1139 yes = dia.exec_() == QDialog.Accepted 1148 yes = dia.exec_() == QDialog.Accepted
1140 else: 1149 else:
1141 yes = E5MessageBox.yesNo(None, 1150 yes = E5MessageBox.yesNo(
1151 None,
1142 self.trUtf8("Revert changes"), 1152 self.trUtf8("Revert changes"),
1143 self.trUtf8("""Do you really want to revert all changes of""" 1153 self.trUtf8("""Do you really want to revert all changes of"""
1144 """ the project?""")) 1154 """ the project?"""))
1145 if yes: 1155 if yes:
1146 client = self.getClient() 1156 client = self.getClient()
1171 """ 1181 """
1172 dname, fname = self.splitPath(name) 1182 dname, fname = self.splitPath(name)
1173 1183
1174 reposURL = self.svnGetReposName(dname) 1184 reposURL = self.svnGetReposName(dname)
1175 if reposURL is None: 1185 if reposURL is None:
1176 E5MessageBox.critical(self.__ui, 1186 E5MessageBox.critical(
1187 self.__ui,
1177 self.trUtf8("Subversion Error"), 1188 self.trUtf8("Subversion Error"),
1178 self.trUtf8( 1189 self.trUtf8(
1179 """The URL of the project repository could not be""" 1190 """The URL of the project repository could not be"""
1180 """ retrieved from the working copy. The switch""" 1191 """ retrieved from the working copy. The switch"""
1181 """ operation will be aborted""")) 1192 """ operation will be aborted"""))
1197 return False 1208 return False
1198 1209
1199 if self.otherData["standardLayout"]: 1210 if self.otherData["standardLayout"]:
1200 rx_base = QRegExp('(.+)/(trunk|tags|branches).*') 1211 rx_base = QRegExp('(.+)/(trunk|tags|branches).*')
1201 if not rx_base.exactMatch(reposURL): 1212 if not rx_base.exactMatch(reposURL):
1202 E5MessageBox.critical(self.__ui, 1213 E5MessageBox.critical(
1214 self.__ui,
1203 self.trUtf8("Subversion Error"), 1215 self.trUtf8("Subversion Error"),
1204 self.trUtf8("""The URL of the project repository has an""" 1216 self.trUtf8(
1217 """The URL of the project repository has an"""
1205 """ invalid format. The switch operation will""" 1218 """ invalid format. The switch operation will"""
1206 """ be aborted""")) 1219 """ be aborted"""))
1207 return False 1220 return False
1208 1221
1209 reposRoot = rx_base.cap(1) 1222 reposRoot = rx_base.cap(1)
1219 else: 1232 else:
1220 url = self.__svnURL(tag) 1233 url = self.__svnURL(tag)
1221 tn = url 1234 tn = url
1222 1235
1223 client = self.getClient() 1236 client = self.getClient()
1224 dlg = \ 1237 dlg = SvnDialog(self.trUtf8('Switching to {0}').format(tn),
1225 SvnDialog(self.trUtf8('Switching to {0}').format(tn), 1238 "switch {0} {1}".format(url, name),
1226 "switch {0} {1}".format(url, name), 1239 client)
1227 client)
1228 QApplication.processEvents() 1240 QApplication.processEvents()
1229 locker = QMutexLocker(self.vcsExecutionMutex) 1241 locker = QMutexLocker(self.vcsExecutionMutex)
1230 try: 1242 try:
1231 rev = client.switch(name, url) 1243 rev = client.switch(name, url)
1232 dlg.showMessage(self.trUtf8("Revision {0}.\n").format(rev.number)) 1244 dlg.showMessage(self.trUtf8("Revision {0}.\n").format(rev.number))
1603 Public method used to cleanup the working copy. 1615 Public method used to cleanup the working copy.
1604 1616
1605 @param name directory name to be cleaned up (string) 1617 @param name directory name to be cleaned up (string)
1606 """ 1618 """
1607 client = self.getClient() 1619 client = self.getClient()
1608 dlg = \ 1620 dlg = SvnDialog(self.trUtf8('Cleaning up {0}').format(name),
1609 SvnDialog(self.trUtf8('Cleaning up {0}').format(name), 1621 "cleanup {0}".format(name),
1610 "cleanup {0}".format(name), 1622 client)
1611 client)
1612 QApplication.processEvents() 1623 QApplication.processEvents()
1613 locker = QMutexLocker(self.vcsExecutionMutex) 1624 locker = QMutexLocker(self.vcsExecutionMutex)
1614 try: 1625 try:
1615 client.cleanup(name) 1626 client.cleanup(name)
1616 except pysvn.ClientError as e: 1627 except pysvn.ClientError as e:
1692 apiVersion = "{0} {1}".format( 1703 apiVersion = "{0} {1}".format(
1693 ".".join([str(v) for v in pysvn.svn_api_version[:3]]), 1704 ".".join([str(v) for v in pysvn.svn_api_version[:3]]),
1694 pysvn.svn_api_version[3]) 1705 pysvn.svn_api_version[3])
1695 else: 1706 else:
1696 apiVersion = QApplication.translate('subversion', "unknown") 1707 apiVersion = QApplication.translate('subversion', "unknown")
1697 return QApplication.translate('subversion', 1708 return QApplication.translate(
1709 'subversion',
1698 """<h3>Repository information</h3>""" 1710 """<h3>Repository information</h3>"""
1699 """<table>""" 1711 """<table>"""
1700 """<tr><td><b>PySvn V.</b></td><td>{0}</td></tr>""" 1712 """<tr><td><b>PySvn V.</b></td><td>{0}</td></tr>"""
1701 """<tr><td><b>Subversion V.</b></td><td>{1}</td></tr>""" 1713 """<tr><td><b>Subversion V.</b></td><td>{1}</td></tr>"""
1702 """<tr><td><b>Subversion API V.</b></td><td>{2}</td></tr>""" 1714 """<tr><td><b>Subversion API V.</b></td><td>{2}</td></tr>"""
1759 cwd = os.getcwd() 1771 cwd = os.getcwd()
1760 os.chdir(dname) 1772 os.chdir(dname)
1761 opts = self.options['global'] 1773 opts = self.options['global']
1762 recurse = "--non-recursive" not in opts 1774 recurse = "--non-recursive" not in opts
1763 client = self.getClient() 1775 client = self.getClient()
1764 dlg = \ 1776 dlg = SvnDialog(self.trUtf8('Resolving conficts'),
1765 SvnDialog(self.trUtf8('Resolving conficts'), 1777 "resolved{0} {1}".format(
1766 "resolved{0} {1}".format( 1778 (not recurse) and " --non-recursive" or "",
1767 (not recurse) and " --non-recursive" or "", 1779 " ".join(fnames)),
1768 " ".join(fnames)), 1780 client)
1769 client)
1770 QApplication.processEvents() 1781 QApplication.processEvents()
1771 try: 1782 try:
1772 for name in fnames: 1783 for name in fnames:
1773 client.resolved(name, recurse=recurse) 1784 client.resolved(name, recurse=recurse)
1774 except pysvn.ClientError as e: 1785 except pysvn.ClientError as e:
1851 from .SvnPropSetDialog import SvnPropSetDialog 1862 from .SvnPropSetDialog import SvnPropSetDialog
1852 dlg = SvnPropSetDialog(recursive) 1863 dlg = SvnPropSetDialog(recursive)
1853 if dlg.exec_() == QDialog.Accepted: 1864 if dlg.exec_() == QDialog.Accepted:
1854 propName, propValue, recurse = dlg.getData() 1865 propName, propValue, recurse = dlg.getData()
1855 if not propName: 1866 if not propName:
1856 E5MessageBox.critical(self.__ui, 1867 E5MessageBox.critical(
1868 self.__ui,
1857 self.trUtf8("Subversion Set Property"), 1869 self.trUtf8("Subversion Set Property"),
1858 self.trUtf8( 1870 self.trUtf8(
1859 """You have to supply a property name. Aborting.""")) 1871 """You have to supply a property name. Aborting."""))
1860 return 1872 return
1861 1873
1904 dlg = SvnPropDelDialog(recursive) 1916 dlg = SvnPropDelDialog(recursive)
1905 if dlg.exec_() == QDialog.Accepted: 1917 if dlg.exec_() == QDialog.Accepted:
1906 propName, recurse = dlg.getData() 1918 propName, recurse = dlg.getData()
1907 1919
1908 if not propName: 1920 if not propName:
1909 E5MessageBox.critical(self.__ui, 1921 E5MessageBox.critical(
1922 self.__ui,
1910 self.trUtf8("Subversion Delete Property"), 1923 self.trUtf8("Subversion Delete Property"),
1911 self.trUtf8( 1924 self.trUtf8(
1912 """You have to supply a property name. Aborting.""")) 1925 """You have to supply a property name. Aborting."""))
1913 return 1926 return
1914 1927
2132 else: 2145 else:
2133 rev1, rev2 = "", "" 2146 rev1, rev2 = "", ""
2134 2147
2135 output1, error = self.__svnGetFileForRevision(name, rev=rev1) 2148 output1, error = self.__svnGetFileForRevision(name, rev=rev1)
2136 if error: 2149 if error:
2137 E5MessageBox.critical(self.__ui, 2150 E5MessageBox.critical(
2151 self.__ui,
2138 self.trUtf8("Subversion Side-by-Side Difference"), 2152 self.trUtf8("Subversion Side-by-Side Difference"),
2139 error) 2153 error)
2140 return 2154 return
2141 name1 = "{0} (rev. {1})".format(name, rev1 and rev1 or ".") 2155 name1 = "{0} (rev. {1})".format(name, rev1 and rev1 or ".")
2142 2156
2143 if rev2: 2157 if rev2:
2144 output2, error = self.__svnGetFileForRevision(name, rev=rev2) 2158 output2, error = self.__svnGetFileForRevision(name, rev=rev2)
2145 if error: 2159 if error:
2146 E5MessageBox.critical(self.__ui, 2160 E5MessageBox.critical(
2161 self.__ui,
2147 self.trUtf8("Subversion Side-by-Side Difference"), 2162 self.trUtf8("Subversion Side-by-Side Difference"),
2148 error) 2163 error)
2149 return 2164 return
2150 name2 = "{0} (rev. {1})".format(name, rev2) 2165 name2 = "{0} (rev. {1})".format(name, rev2)
2151 else: 2166 else:
2153 f1 = open(name, "r", encoding="utf-8") 2168 f1 = open(name, "r", encoding="utf-8")
2154 output2 = f1.read() 2169 output2 = f1.read()
2155 f1.close() 2170 f1.close()
2156 name2 = name 2171 name2 = name
2157 except IOError: 2172 except IOError:
2158 E5MessageBox.critical(self.__ui, 2173 E5MessageBox.critical(
2174 self.__ui,
2159 self.trUtf8("Subversion Side-by-Side Difference"), 2175 self.trUtf8("Subversion Side-by-Side Difference"),
2160 self.trUtf8( 2176 self.trUtf8(
2161 """<p>The file <b>{0}</b> could not be read.</p>""") 2177 """<p>The file <b>{0}</b> could not be read.</p>""")
2162 .format(name)) 2178 .format(name))
2163 return 2179 return

eric ide

mercurial