Plugins/VcsPlugins/vcsSubversion/subversion.py

branch
Py2 comp.
changeset 3058
0a02c433f52d
parent 3057
10516539f238
parent 3025
67064c71df21
child 3060
5883ce99ee12
equal deleted inserted replaced
3057:10516539f238 3058:0a02c433f52d
209 @param vcsDataDict dictionary of data required for the conversion 209 @param vcsDataDict dictionary of data required for the conversion
210 @param project reference to the project object 210 @param project reference to the project object
211 """ 211 """
212 success = self.vcsImport(vcsDataDict, project.ppath)[0] 212 success = self.vcsImport(vcsDataDict, project.ppath)[0]
213 if not success: 213 if not success:
214 E5MessageBox.critical(self.__ui, 214 E5MessageBox.critical(
215 self.__ui,
215 self.trUtf8("Create project in repository"), 216 self.trUtf8("Create project in repository"),
216 self.trUtf8( 217 self.trUtf8(
217 """The project could not be created in the repository.""" 218 """The project could not be created in the repository."""
218 """ Maybe the given repository doesn't exist or the""" 219 """ Maybe the given repository doesn't exist or the"""
219 """ repository server is down.""")) 220 """ repository server is down."""))
232 self.vcsCommit(project.ppath, vcsDataDict["message"], True) 233 self.vcsCommit(project.ppath, vcsDataDict["message"], True)
233 pfn = project.pfile 234 pfn = project.pfile
234 if not os.path.isfile(pfn): 235 if not os.path.isfile(pfn):
235 pfn += "z" 236 pfn += "z"
236 if not os.path.isfile(pfn): 237 if not os.path.isfile(pfn):
237 E5MessageBox.critical(self.__ui, 238 E5MessageBox.critical(
239 self.__ui,
238 self.trUtf8("New project"), 240 self.trUtf8("New project"),
239 self.trUtf8( 241 self.trUtf8(
240 """The project could not be checked out of the""" 242 """The project could not be checked out of the"""
241 """ repository.<br />""" 243 """ repository.<br />"""
242 """Restoring the original contents.""")) 244 """Restoring the original contents."""))
304 args.append('-m') 306 args.append('-m')
305 args.append(msg) 307 args.append(msg)
306 args.append(self.__svnURL(vcsDir)) 308 args.append(self.__svnURL(vcsDir))
307 309
308 if noDialog: 310 if noDialog:
309 status = self.startSynchronizedProcess(QProcess(), "svn", args, 311 status = self.startSynchronizedProcess(
310 os.path.join(tmpDir, project)) 312 QProcess(), "svn", args, os.path.join(tmpDir, project))
311 else: 313 else:
312 dia = SvnDialog( 314 dia = SvnDialog(
313 self.trUtf8('Importing project into Subversion repository')) 315 self.trUtf8('Importing project into Subversion repository'))
314 res = dia.startProcess(args, os.path.join(tmpDir, project)) 316 res = dia.startProcess(args, os.path.join(tmpDir, project))
315 if res: 317 if res:
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:
402 if not tag.startswith('tags') and \ 405 if not tag.startswith('tags') and \
403 not tag.startswith('branches'): 406 not tag.startswith('branches'):
404 type, ok = QInputDialog.getItem( 407 type, ok = QInputDialog.getItem(
405 None, 408 None,
406 self.trUtf8("Subversion Export"), 409 self.trUtf8("Subversion Export"),
407 self.trUtf8("The tag must be a normal tag (tags) or" 410 self.trUtf8(
411 "The tag must be a normal tag (tags) or"
408 " a branch tag (branches)." 412 " a branch tag (branches)."
409 " Please select from the list."), 413 " Please select from the list."),
410 self.tagTypeList, 414 self.tagTypeList,
411 0, False) 415 0, False)
412 if not ok: 416 if not ok:
490 ok &= editor.checkDirty() 494 ok &= editor.checkDirty()
491 if not ok: 495 if not ok:
492 break 496 break
493 497
494 if not ok: 498 if not ok:
495 res = E5MessageBox.yesNo(self.__ui, 499 res = E5MessageBox.yesNo(
500 self.__ui,
496 self.trUtf8("Commit Changes"), 501 self.trUtf8("Commit Changes"),
497 self.trUtf8( 502 self.trUtf8(
498 """The commit affects files, that have unsaved""" 503 """The commit affects files, that have unsaved"""
499 """ changes. Shall the commit be continued?"""), 504 """ changes. Shall the commit be continued?"""),
500 icon=E5MessageBox.Warning) 505 icon=E5MessageBox.Warning)
653 return # oops, project is not version controlled 658 return # oops, project is not version controlled
654 while os.path.normcase(d) != \ 659 while os.path.normcase(d) != \
655 os.path.normcase(repodir) and \ 660 os.path.normcase(repodir) and \
656 (d not in tree2 + tree) and \ 661 (d not in tree2 + tree) and \
657 (os.path.normcase(d) not in self.statusCache or \ 662 (os.path.normcase(d) not in self.statusCache or \
658 self.statusCache[os.path.normcase(d)] == \ 663 self.statusCache[os.path.normcase(d)] == \
659 self.canBeAdded): 664 self.canBeAdded):
660 tree2.append(d) 665 tree2.append(d)
661 d = os.path.dirname(d) 666 d = os.path.dirname(d)
662 else: 667 else:
663 while not os.path.exists(os.path.join(d, self.adminDir)): 668 while not os.path.exists(os.path.join(d, self.adminDir)):
858 863
859 if noDialog: 864 if noDialog:
860 res = self.startSynchronizedProcess(QProcess(), "svn", args) 865 res = self.startSynchronizedProcess(QProcess(), "svn", args)
861 else: 866 else:
862 dia = SvnDialog(self.trUtf8('Moving {0}') 867 dia = SvnDialog(self.trUtf8('Moving {0}')
863 .format(name)) 868 .format(name))
864 res = dia.startProcess(args) 869 res = dia.startProcess(args)
865 if res: 870 if res:
866 dia.exec_() 871 dia.exec_()
867 res = dia.normalExit() 872 res = dia.normalExit()
868 if res and not rx_prot.exactMatch(target): 873 if res and not rx_prot.exactMatch(target):
950 """ 955 """
951 dname, fname = self.splitPath(name) 956 dname, fname = self.splitPath(name)
952 957
953 reposURL = self.svnGetReposName(dname) 958 reposURL = self.svnGetReposName(dname)
954 if reposURL is None: 959 if reposURL is None:
955 E5MessageBox.critical(self.__ui, 960 E5MessageBox.critical(
961 self.__ui,
956 self.trUtf8("Subversion Error"), 962 self.trUtf8("Subversion Error"),
957 self.trUtf8( 963 self.trUtf8(
958 """The URL of the project repository could not be""" 964 """The URL of the project repository could not be"""
959 """ retrieved from the working copy. The tag operation""" 965 """ retrieved from the working copy. The tag operation"""
960 """ will be aborted""")) 966 """ will be aborted"""))
976 return 982 return
977 983
978 if self.otherData["standardLayout"]: 984 if self.otherData["standardLayout"]:
979 rx_base = QRegExp('(.+)/(trunk|tags|branches).*') 985 rx_base = QRegExp('(.+)/(trunk|tags|branches).*')
980 if not rx_base.exactMatch(reposURL): 986 if not rx_base.exactMatch(reposURL):
981 E5MessageBox.critical(self.__ui, 987 E5MessageBox.critical(
988 self.__ui,
982 self.trUtf8("Subversion Error"), 989 self.trUtf8("Subversion Error"),
983 self.trUtf8("""The URL of the project repository has an""" 990 self.trUtf8(
991 """The URL of the project repository has an"""
984 """ invalid format. The tag operation will""" 992 """ invalid format. The tag operation will"""
985 """ be aborted""")) 993 """ be aborted"""))
986 return 994 return
987 995
988 reposRoot = rx_base.cap(1) 996 reposRoot = rx_base.cap(1)
1010 args.append('--message') 1018 args.append('--message')
1011 args.append('Deleted tag <{0}>'.format(tag)) 1019 args.append('Deleted tag <{0}>'.format(tag))
1012 args.append(url) 1020 args.append(url)
1013 1021
1014 dia = SvnDialog(self.trUtf8('Tagging {0} in the Subversion repository') 1022 dia = SvnDialog(self.trUtf8('Tagging {0} in the Subversion repository')
1015 .format(name)) 1023 .format(name))
1016 res = dia.startProcess(args) 1024 res = dia.startProcess(args)
1017 if res: 1025 if res:
1018 dia.exec_() 1026 dia.exec_()
1019 1027
1020 def vcsRevert(self, name): 1028 def vcsRevert(self, name):
1038 project = e5App().getObject("Project") 1046 project = e5App().getObject("Project")
1039 names = [project.getRelativePath(nam) for nam in names] 1047 names = [project.getRelativePath(nam) for nam in names]
1040 if names[0]: 1048 if names[0]:
1041 from UI.DeleteFilesConfirmationDialog import \ 1049 from UI.DeleteFilesConfirmationDialog import \
1042 DeleteFilesConfirmationDialog 1050 DeleteFilesConfirmationDialog
1043 dlg = DeleteFilesConfirmationDialog(self.parent(), 1051 dlg = DeleteFilesConfirmationDialog(
1052 self.parent(),
1044 self.trUtf8("Revert changes"), 1053 self.trUtf8("Revert changes"),
1045 self.trUtf8("Do you really want to revert all changes to" 1054 self.trUtf8("Do you really want to revert all changes to"
1046 " these files or directories?"), 1055 " these files or directories?"),
1047 names) 1056 names)
1048 yes = dlg.exec_() == QDialog.Accepted 1057 yes = dlg.exec_() == QDialog.Accepted
1049 else: 1058 else:
1050 yes = E5MessageBox.yesNo(None, 1059 yes = E5MessageBox.yesNo(
1060 None,
1051 self.trUtf8("Revert changes"), 1061 self.trUtf8("Revert changes"),
1052 self.trUtf8("""Do you really want to revert all changes of""" 1062 self.trUtf8("""Do you really want to revert all changes of"""
1053 """ the project?""")) 1063 """ the project?"""))
1054 if yes: 1064 if yes:
1055 dia = SvnDialog(self.trUtf8('Reverting changes')) 1065 dia = SvnDialog(self.trUtf8('Reverting changes'))
1067 """ 1077 """
1068 dname, fname = self.splitPath(name) 1078 dname, fname = self.splitPath(name)
1069 1079
1070 reposURL = self.svnGetReposName(dname) 1080 reposURL = self.svnGetReposName(dname)
1071 if reposURL is None: 1081 if reposURL is None:
1072 E5MessageBox.critical(self.__ui, 1082 E5MessageBox.critical(
1083 self.__ui,
1073 self.trUtf8("Subversion Error"), 1084 self.trUtf8("Subversion Error"),
1074 self.trUtf8( 1085 self.trUtf8(
1075 """The URL of the project repository could not be""" 1086 """The URL of the project repository could not be"""
1076 """ retrieved from the working copy. The switch""" 1087 """ retrieved from the working copy. The switch"""
1077 """ operation will be aborted""")) 1088 """ operation will be aborted"""))
1093 return False 1104 return False
1094 1105
1095 if self.otherData["standardLayout"]: 1106 if self.otherData["standardLayout"]:
1096 rx_base = QRegExp('(.+)/(trunk|tags|branches).*') 1107 rx_base = QRegExp('(.+)/(trunk|tags|branches).*')
1097 if not rx_base.exactMatch(reposURL): 1108 if not rx_base.exactMatch(reposURL):
1098 E5MessageBox.critical(self.__ui, 1109 E5MessageBox.critical(
1110 self.__ui,
1099 self.trUtf8("Subversion Error"), 1111 self.trUtf8("Subversion Error"),
1100 self.trUtf8("""The URL of the project repository has an""" 1112 self.trUtf8(
1113 """The URL of the project repository has an"""
1101 """ invalid format. The switch operation will""" 1114 """ invalid format. The switch operation will"""
1102 """ be aborted""")) 1115 """ be aborted"""))
1103 return False 1116 return False
1104 1117
1105 reposRoot = rx_base.cap(1) 1118 reposRoot = rx_base.cap(1)
1123 args.append('postpone') 1136 args.append('postpone')
1124 args.append(url) 1137 args.append(url)
1125 args.append(name) 1138 args.append(name)
1126 1139
1127 dia = SvnDialog(self.trUtf8('Switching to {0}') 1140 dia = SvnDialog(self.trUtf8('Switching to {0}')
1128 .format(tn)) 1141 .format(tn))
1129 res = dia.startProcess(args, setLanguage=True) 1142 res = dia.startProcess(args, setLanguage=True)
1130 if res: 1143 if res:
1131 dia.exec_() 1144 dia.exec_()
1132 res = dia.hasAddOrDelete() 1145 res = dia.hasAddOrDelete()
1133 self.checkVCSStatus() 1146 self.checkVCSStatus()
1454 args.append('cleanup') 1467 args.append('cleanup')
1455 self.addArguments(args, self.options['global']) 1468 self.addArguments(args, self.options['global'])
1456 args.append(name) 1469 args.append(name)
1457 1470
1458 dia = SvnDialog(self.trUtf8('Cleaning up {0}') 1471 dia = SvnDialog(self.trUtf8('Cleaning up {0}')
1459 .format(name)) 1472 .format(name))
1460 res = dia.startProcess(args) 1473 res = dia.startProcess(args)
1461 if res: 1474 if res:
1462 dia.exec_() 1475 dia.exec_()
1463 1476
1464 def vcsCommandLine(self, name): 1477 def vcsCommandLine(self, name):
1576 date, time = value.split('T') 1589 date, time = value.split('T')
1577 info['committed-date'] = date 1590 info['committed-date'] = date
1578 info['committed-time'] = "{0}{1}".format( 1591 info['committed-time'] = "{0}{1}".format(
1579 time.split('.')[0], time[-1]) 1592 time.split('.')[0], time[-1])
1580 1593
1581 return QApplication.translate('subversion', 1594 return QApplication.translate(
1595 'subversion',
1582 """<h3>Repository information</h3>""" 1596 """<h3>Repository information</h3>"""
1583 """<table>""" 1597 """<table>"""
1584 """<tr><td><b>Subversion V.</b></td><td>{0}</td></tr>""" 1598 """<tr><td><b>Subversion V.</b></td><td>{0}</td></tr>"""
1585 """<tr><td><b>URL</b></td><td>{1}</td></tr>""" 1599 """<tr><td><b>URL</b></td><td>{1}</td></tr>"""
1586 """<tr><td><b>Current revision</b></td><td>{2}</td></tr>""" 1600 """<tr><td><b>Current revision</b></td><td>{2}</td></tr>"""
1685 target = self.__svnURL(target) 1699 target = self.__svnURL(target)
1686 args.append(name) 1700 args.append(name)
1687 args.append(target) 1701 args.append(target)
1688 1702
1689 dia = SvnDialog(self.trUtf8('Copying {0}') 1703 dia = SvnDialog(self.trUtf8('Copying {0}')
1690 .format(name)) 1704 .format(name))
1691 res = dia.startProcess(args) 1705 res = dia.startProcess(args)
1692 if res: 1706 if res:
1693 dia.exec_() 1707 dia.exec_()
1694 res = dia.normalExit() 1708 res = dia.normalExit()
1695 if res and \ 1709 if res and \
1723 from .SvnPropSetDialog import SvnPropSetDialog 1737 from .SvnPropSetDialog import SvnPropSetDialog
1724 dlg = SvnPropSetDialog() 1738 dlg = SvnPropSetDialog()
1725 if dlg.exec_() == QDialog.Accepted: 1739 if dlg.exec_() == QDialog.Accepted:
1726 propName, fileFlag, propValue = dlg.getData() 1740 propName, fileFlag, propValue = dlg.getData()
1727 if not propName: 1741 if not propName:
1728 E5MessageBox.critical(self.__ui, 1742 E5MessageBox.critical(
1743 self.__ui,
1729 self.trUtf8("Subversion Set Property"), 1744 self.trUtf8("Subversion Set Property"),
1730 self.trUtf8("""You have to supply a property name.""" 1745 self.trUtf8("""You have to supply a property name."""
1731 """ Aborting.""")) 1746 """ Aborting."""))
1732 return 1747 return
1733 1748
1767 1782
1768 if not ok: 1783 if not ok:
1769 return 1784 return
1770 1785
1771 if not propName: 1786 if not propName:
1772 E5MessageBox.critical(self.__ui, 1787 E5MessageBox.critical(
1788 self.__ui,
1773 self.trUtf8("Subversion Delete Property"), 1789 self.trUtf8("Subversion Delete Property"),
1774 self.trUtf8("""You have to supply a property name.""" 1790 self.trUtf8("""You have to supply a property name."""
1775 """ Aborting.""")) 1791 """ Aborting."""))
1776 return 1792 return
1777 1793
1900 1916
1901 dname = self.splitPath(names[0])[0] 1917 dname = self.splitPath(names[0])[0]
1902 1918
1903 from .SvnUrlSelectionDialog import SvnUrlSelectionDialog 1919 from .SvnUrlSelectionDialog import SvnUrlSelectionDialog
1904 dlg = SvnUrlSelectionDialog(self, self.tagsList, self.branchesList, 1920 dlg = SvnUrlSelectionDialog(self, self.tagsList, self.branchesList,
1905 dname) 1921 dname)
1906 if dlg.exec_() == QDialog.Accepted: 1922 if dlg.exec_() == QDialog.Accepted:
1907 urls, summary = dlg.getURLs() 1923 urls, summary = dlg.getURLs()
1908 from .SvnDiffDialog import SvnDiffDialog 1924 from .SvnDiffDialog import SvnDiffDialog
1909 self.diff = SvnDiffDialog(self) 1925 self.diff = SvnDiffDialog(self)
1910 self.diff.show() 1926 self.diff.show()
1935 procStarted = process.waitForStarted(5000) 1951 procStarted = process.waitForStarted(5000)
1936 if procStarted: 1952 if procStarted:
1937 finished = process.waitForFinished(30000) 1953 finished = process.waitForFinished(30000)
1938 if finished: 1954 if finished:
1939 if process.exitCode() == 0: 1955 if process.exitCode() == 0:
1940 output = str(process.readAllStandardOutput(), 1956 output = str(
1957 process.readAllStandardOutput(),
1941 Preferences.getSystem("IOEncoding"), 'replace') 1958 Preferences.getSystem("IOEncoding"), 'replace')
1942 else: 1959 else:
1943 error = str(process.readAllStandardError(), 1960 error = str(
1961 process.readAllStandardError(),
1944 Preferences.getSystem("IOEncoding"), 'replace') 1962 Preferences.getSystem("IOEncoding"), 'replace')
1945 else: 1963 else:
1946 error = self.trUtf8( 1964 error = self.trUtf8(
1947 "The svn process did not finish within 30s.") 1965 "The svn process did not finish within 30s.")
1948 else: 1966 else:
1949 error = self.trUtf8('The process {0} could not be started. ' 1967 error = self.trUtf8(
1950 'Ensure, that it is in the search path.').format('svn') 1968 'The process {0} could not be started. '
1969 'Ensure, that it is in the search path.').format('svn')
1951 1970
1952 return output, error 1971 return output, error
1953 1972
1954 def svnSbsDiff(self, name, extended=False, revisions=None): 1973 def svnSbsDiff(self, name, extended=False, revisions=None):
1955 """ 1974 """
1978 else: 1997 else:
1979 rev1, rev2 = "", "" 1998 rev1, rev2 = "", ""
1980 1999
1981 output1, error = self.__svnGetFileForRevision(name, rev=rev1) 2000 output1, error = self.__svnGetFileForRevision(name, rev=rev1)
1982 if error: 2001 if error:
1983 E5MessageBox.critical(self.__ui, 2002 E5MessageBox.critical(
2003 self.__ui,
1984 self.trUtf8("Subversion Side-by-Side Difference"), 2004 self.trUtf8("Subversion Side-by-Side Difference"),
1985 error) 2005 error)
1986 return 2006 return
1987 name1 = "{0} (rev. {1})".format(name, rev1 and rev1 or ".") 2007 name1 = "{0} (rev. {1})".format(name, rev1 and rev1 or ".")
1988 2008
1989 if rev2: 2009 if rev2:
1990 output2, error = self.__svnGetFileForRevision(name, rev=rev2) 2010 output2, error = self.__svnGetFileForRevision(name, rev=rev2)
1991 if error: 2011 if error:
1992 E5MessageBox.critical(self.__ui, 2012 E5MessageBox.critical(
2013 self.__ui,
1993 self.trUtf8("Subversion Side-by-Side Difference"), 2014 self.trUtf8("Subversion Side-by-Side Difference"),
1994 error) 2015 error)
1995 return 2016 return
1996 name2 = "{0} (rev. {1})".format(name, rev2) 2017 name2 = "{0} (rev. {1})".format(name, rev2)
1997 else: 2018 else:
1999 f1 = open(name, "r", encoding="utf-8") 2020 f1 = open(name, "r", encoding="utf-8")
2000 output2 = f1.read() 2021 output2 = f1.read()
2001 f1.close() 2022 f1.close()
2002 name2 = name 2023 name2 = name
2003 except IOError: 2024 except IOError:
2004 E5MessageBox.critical(self.__ui, 2025 E5MessageBox.critical(
2026 self.__ui,
2005 self.trUtf8("Subversion Side-by-Side Difference"), 2027 self.trUtf8("Subversion Side-by-Side Difference"),
2006 self.trUtf8( 2028 self.trUtf8(
2007 """<p>The file <b>{0}</b> could not be read.</p>""") 2029 """<p>The file <b>{0}</b> could not be read.</p>""")
2008 .format(name)) 2030 .format(name))
2009 return 2031 return

eric ide

mercurial