Plugins/VcsPlugins/vcsPySvn/subversion.py

branch
Py2 comp.
changeset 3060
5883ce99ee12
parent 3058
0a02c433f52d
parent 3051
f08c20c91de7
child 3141
72f3bde98c58
equal deleted inserted replaced
3058:0a02c433f52d 3060:5883ce99ee12
310 rev = None 310 rev = None
311 if not noDialog: 311 if not noDialog:
312 dlg.showError(e.args[0]) 312 dlg.showError(e.args[0])
313 locker.unlock() 313 locker.unlock()
314 if not noDialog: 314 if not noDialog:
315 rev and dlg.showMessage(self.trUtf8("Imported revision {0}.\n")\ 315 rev and dlg.showMessage(self.trUtf8("Imported revision {0}.\n")
316 .format(rev.number)) 316 .format(rev.number))
317 dlg.finish() 317 dlg.finish()
318 dlg.exec_() 318 dlg.exec_()
319 os.chdir(cwd) 319 os.chdir(cwd)
320 320
321 shutil.rmtree(tmpDir, True) 321 shutil.rmtree(tmpDir, True)
371 if not noDialog: 371 if not noDialog:
372 dlg = SvnDialog( 372 dlg = SvnDialog(
373 self.trUtf8('Checking project out of Subversion repository'), 373 self.trUtf8('Checking project out of Subversion repository'),
374 "checkout{0} {1} {2}".format( 374 "checkout{0} {1} {2}".format(
375 (not recurse) and " --non-recursive" or "", 375 (not recurse) and " --non-recursive" or "",
376 url, projectDir), 376 url, projectDir),
377 client) 377 client)
378 QApplication.processEvents() 378 QApplication.processEvents()
379 locker = QMutexLocker(self.vcsExecutionMutex) 379 locker = QMutexLocker(self.vcsExecutionMutex)
380 try: 380 try:
381 client.checkout(url, projectDir, recurse) 381 client.checkout(url, projectDir, recurse)
435 client = self.getClient() 435 client = self.getClient()
436 dlg = SvnDialog( 436 dlg = SvnDialog(
437 self.trUtf8('Exporting project from Subversion repository'), 437 self.trUtf8('Exporting project from Subversion repository'),
438 "export --force{0} {1} {2}".format( 438 "export --force{0} {1} {2}".format(
439 (not recurse) and " --non-recursive" or "", 439 (not recurse) and " --non-recursive" or "",
440 url, projectDir), 440 url, projectDir),
441 client) 441 client)
442 QApplication.processEvents() 442 QApplication.processEvents()
443 locker = QMutexLocker(self.vcsExecutionMutex) 443 locker = QMutexLocker(self.vcsExecutionMutex)
444 try: 444 try:
445 client.export(url, projectDir, force=True, recurse=recurse) 445 client.export(url, projectDir, force=True, recurse=recurse)
499 # check for commit of the project 499 # check for commit of the project
500 if os.path.isdir(nam): 500 if os.path.isdir(nam):
501 project = e5App().getObject("Project") 501 project = e5App().getObject("Project")
502 if nam == project.getProjectPath(): 502 if nam == project.getProjectPath():
503 ok &= project.checkAllScriptsDirty( 503 ok &= project.checkAllScriptsDirty(
504 reportSyntaxErrors=True) and \ 504 reportSyntaxErrors=True) and \
505 project.checkDirty() 505 project.checkDirty()
506 continue 506 continue
507 elif os.path.isfile(nam): 507 elif os.path.isfile(nam):
508 editor = e5App().getObject("ViewManager")\ 508 editor = e5App().getObject("ViewManager")\
509 .getOpenEditor(nam) 509 .getOpenEditor(nam)
510 if editor: 510 if editor:
560 self.trUtf8('Commiting changes to Subversion repository'), 560 self.trUtf8('Commiting changes to Subversion repository'),
561 "commit{0}{1}{2}{3} --message {4} {5}".format( 561 "commit{0}{1}{2}{3} --message {4} {5}".format(
562 (not recurse) and " --non-recursive" or "", 562 (not recurse) and " --non-recursive" or "",
563 keeplocks and " --keep-locks" or "", 563 keeplocks and " --keep-locks" or "",
564 keepChangelists and " --keep-changelists" or "", 564 keepChangelists and " --keep-changelists" or "",
565 changelists and \ 565 changelists and
566 " --changelist ".join([""] + changelists) or "", 566 " --changelist ".join([""] + changelists) or "",
567 msg, " ".join(fnames)), 567 msg, " ".join(fnames)),
568 client) 568 client)
569 QApplication.processEvents() 569 QApplication.processEvents()
570 try: 570 try:
571 if changelists: 571 if changelists:
663 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 663 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
664 repodir = os.path.dirname(repodir) 664 repodir = os.path.dirname(repodir)
665 if os.path.splitdrive(repodir)[1] == os.sep: 665 if os.path.splitdrive(repodir)[1] == os.sep:
666 return # oops, project is not version controlled 666 return # oops, project is not version controlled
667 while os.path.normcase(dname) != os.path.normcase(repodir) and \ 667 while os.path.normcase(dname) != os.path.normcase(repodir) and \
668 (os.path.normcase(dname) not in self.statusCache or \ 668 (os.path.normcase(dname) not in self.statusCache or
669 self.statusCache[os.path.normcase(dname)] == 669 self.statusCache[os.path.normcase(dname)] ==
670 self.canBeAdded): 670 self.canBeAdded):
671 # add directories recursively, if they aren't in the 671 # add directories recursively, if they aren't in the
672 # repository already 672 # repository already
673 tree.insert(-1, dname) 673 tree.insert(-1, dname)
674 dname = os.path.dirname(dname) 674 dname = os.path.dirname(dname)
693 repodir = os.path.dirname(repodir) 693 repodir = os.path.dirname(repodir)
694 if os.path.splitdrive(repodir)[1] == os.sep: 694 if os.path.splitdrive(repodir)[1] == os.sep:
695 return # oops, project is not version controlled 695 return # oops, project is not version controlled
696 while os.path.normcase(d) != \ 696 while os.path.normcase(d) != \
697 os.path.normcase(repodir) and \ 697 os.path.normcase(repodir) and \
698 (d not in tree2 + tree) and \ 698 (d not in tree2 + tree) and \
699 (os.path.normcase(d) not in self.statusCache or \ 699 (os.path.normcase(d) not in self.statusCache or
700 self.statusCache[os.path.normcase(d)] == 700 self.statusCache[os.path.normcase(d)] ==
701 self.canBeAdded): 701 self.canBeAdded):
702 tree2.append(d) 702 tree2.append(d)
703 d = os.path.dirname(d) 703 d = os.path.dirname(d)
704 else: 704 else:
705 while not os.path.exists(os.path.join(d, self.adminDir)): 705 while not os.path.exists(os.path.join(d, self.adminDir)):
773 repodir = os.path.dirname(repodir) 773 repodir = os.path.dirname(repodir)
774 if os.path.splitdrive(repodir)[1] == os.sep: 774 if os.path.splitdrive(repodir)[1] == os.sep:
775 return # oops, project is not version controlled 775 return # oops, project is not version controlled
776 while os.path.normcase(d) != \ 776 while os.path.normcase(d) != \
777 os.path.normcase(repodir) and \ 777 os.path.normcase(repodir) and \
778 (d not in tree) and \ 778 (d not in tree) and \
779 (os.path.normcase(d) not in self.statusCache or \ 779 (os.path.normcase(d) not in self.statusCache or
780 self.statusCache[os.path.normcase(d)] == 780 self.statusCache[os.path.normcase(d)] ==
781 self.canBeAdded): 781 self.canBeAdded):
782 tree.append(d) 782 tree.append(d)
783 d = os.path.dirname(d) 783 d = os.path.dirname(d)
784 else: 784 else:
785 while not os.path.exists(os.path.join(d, self.adminDir)): 785 while not os.path.exists(os.path.join(d, self.adminDir)):
798 repodir = os.path.dirname(repodir) 798 repodir = os.path.dirname(repodir)
799 if os.path.splitdrive(repodir)[1] == os.sep: 799 if os.path.splitdrive(repodir)[1] == os.sep:
800 return # oops, project is not version controlled 800 return # oops, project is not version controlled
801 while os.path.normcase(dname) != \ 801 while os.path.normcase(dname) != \
802 os.path.normcase(repodir) and \ 802 os.path.normcase(repodir) and \
803 (os.path.normcase(dname) not in self.statusCache or \ 803 (os.path.normcase(dname) not in self.statusCache or
804 self.statusCache[os.path.normcase(dname)] == 804 self.statusCache[os.path.normcase(dname)] ==
805 self.canBeAdded): 805 self.canBeAdded):
806 # add directories recursively, if they aren't in the 806 # add directories recursively, if they aren't in the
807 # repository already 807 # repository already
808 tree.insert(-1, dname) 808 tree.insert(-1, dname)
809 dname = os.path.dirname(dname) 809 dname = os.path.dirname(dname)
931 target = target 931 target = target
932 if not noDialog: 932 if not noDialog:
933 dlg = \ 933 dlg = \
934 SvnDialog( 934 SvnDialog(
935 self.trUtf8('Moving {0}').format(name), 935 self.trUtf8('Moving {0}').format(name),
936 "move{0}{1} {2} {3}".format( 936 "move{0}{1} {2} {3}".format(
937 force and " --force" or "", 937 force and " --force" or "",
938 log and (" --message {0}".format(log)) or "", 938 log and (" --message {0}".format(log)) or "",
939 name, target), 939 name, target),
940 client, log=log) 940 client, log=log)
941 QApplication.processEvents() 941 QApplication.processEvents()
942 locker = QMutexLocker(self.vcsExecutionMutex) 942 locker = QMutexLocker(self.vcsExecutionMutex)
943 try: 943 try:
944 client.move(name, target, force=force) 944 client.move(name, target, force=force)
988 """ 988 """
989 Public method used to view the difference of a file/directory to the 989 Public method used to view the difference of a file/directory to the
990 Subversion repository. 990 Subversion repository.
991 991
992 If name is a directory and is the project directory, all project files 992 If name is a directory and is the project directory, all project files
993 are saved first. If name is a file (or list of files), which is/are 993 are saved first. If name is a file (or list of files), which is/are
994 being edited and has unsaved modification, they can be saved or the 994 being edited and has unsaved modification, they can be saved or the
995 operation may be aborted. 995 operation may be aborted.
996 996
997 @param name file/directory name to be diffed (string) 997 @param name file/directory name to be diffed (string)
998 """ 998 """
1337 rev2 = "" 1337 rev2 = ""
1338 client = self.getClient() 1338 client = self.getClient()
1339 dlg = \ 1339 dlg = \
1340 SvnDialog( 1340 SvnDialog(
1341 self.trUtf8('Merging {0}').format(name), 1341 self.trUtf8('Merging {0}').format(name),
1342 "merge{0}{1} {2} {3} {4}".format( 1342 "merge{0}{1} {2} {3} {4}".format(
1343 (not recurse) and " --non-recursive" or "", 1343 (not recurse) and " --non-recursive" or "",
1344 force and " --force" or "", 1344 force and " --force" or "",
1345 "{0}{1}".format(url1, rev1 and ("@" + rev1) or ""), 1345 "{0}{1}".format(url1, rev1 and ("@" + rev1) or ""),
1346 "{0}{1}".format(url2, rev2 and ("@" + rev2) or ""), 1346 "{0}{1}".format(url2, rev2 and ("@" + rev2) or ""),
1347 fname), 1347 fname),
1348 client) 1348 client)
1349 QApplication.processEvents() 1349 QApplication.processEvents()
1350 try: 1350 try:
1351 client.merge(url1, revision1, url2, revision2, fname, 1351 client.merge(url1, revision1, url2, revision2, fname,
1352 recurse=recurse, force=force) 1352 recurse=recurse, force=force)
1489 mixin._clientSslServerTrustPromptCallback 1489 mixin._clientSslServerTrustPromptCallback
1490 1490
1491 try: 1491 try:
1492 locker = QMutexLocker(self.vcsExecutionMutex) 1492 locker = QMutexLocker(self.vcsExecutionMutex)
1493 allFiles = client.status(dname, recurse=True, get_all=True, 1493 allFiles = client.status(dname, recurse=True, get_all=True,
1494 ignore=True, update=False) 1494 ignore=True, update=False)
1495 locker.unlock() 1495 locker.unlock()
1496 dirs = [x for x in names.keys() if os.path.isdir(x)] 1496 dirs = [x for x in names.keys() if os.path.isdir(x)]
1497 for file in allFiles: 1497 for file in allFiles:
1498 name = os.path.normcase(file.path) 1498 name = os.path.normcase(file.path)
1499 if file.is_versioned: 1499 if file.is_versioned:
1500 if name in names: 1500 if name in names:
1501 names[name] = self.canBeCommitted 1501 names[name] = self.canBeCommitted
1502 dn = name 1502 dn = name
1503 while os.path.splitdrive(dn)[1] != os.sep and \ 1503 while os.path.splitdrive(dn)[1] != os.sep and \
1504 dn != repodir: 1504 dn != repodir:
1505 dn = os.path.dirname(dn) 1505 dn = os.path.dirname(dn)
1506 if dn in self.statusCache and \ 1506 if dn in self.statusCache and \
1507 self.statusCache[dn] == self.canBeCommitted: 1507 self.statusCache[dn] == self.canBeCommitted:
1508 break 1508 break
1509 self.statusCache[dn] = self.canBeCommitted 1509 self.statusCache[dn] = self.canBeCommitted
1564 mixin._clientSslServerTrustPromptCallback 1564 mixin._clientSslServerTrustPromptCallback
1565 1565
1566 try: 1566 try:
1567 locker = QMutexLocker(self.vcsExecutionMutex) 1567 locker = QMutexLocker(self.vcsExecutionMutex)
1568 allFiles = client.status(dname, recurse=True, get_all=True, 1568 allFiles = client.status(dname, recurse=True, get_all=True,
1569 ignore=True, update=False) 1569 ignore=True, update=False)
1570 locker.unlock() 1570 locker.unlock()
1571 for file in allFiles: 1571 for file in allFiles:
1572 name = os.path.normcase(file.path) 1572 name = os.path.normcase(file.path)
1573 if file.is_versioned: 1573 if file.is_versioned:
1574 if name in names: 1574 if name in names:
1717 """<tr><td><b>Committed revision</b></td><td>{5}</td></tr>""" 1717 """<tr><td><b>Committed revision</b></td><td>{5}</td></tr>"""
1718 """<tr><td><b>Committed date</b></td><td>{6}</td></tr>""" 1718 """<tr><td><b>Committed date</b></td><td>{6}</td></tr>"""
1719 """<tr><td><b>Comitted time</b></td><td>{7}</td></tr>""" 1719 """<tr><td><b>Comitted time</b></td><td>{7}</td></tr>"""
1720 """<tr><td><b>Last author</b></td><td>{8}</td></tr>""" 1720 """<tr><td><b>Last author</b></td><td>{8}</td></tr>"""
1721 """</table>""" 1721 """</table>"""
1722 )\ 1722 )\
1723 .format(".".join([str(v) for v in pysvn.version]), 1723 .format(".".join([str(v) for v in pysvn.version]),
1724 ".".join([str(v) for v in pysvn.svn_version[:3]]), 1724 ".".join([str(v) for v in pysvn.svn_version[:3]]),
1725 apiVersion, 1725 apiVersion,
1726 entry.url, 1726 entry.url,
1727 entry.revision.number, 1727 entry.revision.number,
1729 time.strftime( 1729 time.strftime(
1730 "%Y-%m-%d", time.localtime(entry.commit_time)), 1730 "%Y-%m-%d", time.localtime(entry.commit_time)),
1731 time.strftime( 1731 time.strftime(
1732 "%H:%M:%S %Z", time.localtime(entry.commit_time)), 1732 "%H:%M:%S %Z", time.localtime(entry.commit_time)),
1733 entry.commit_author 1733 entry.commit_author
1734 ) 1734 )
1735 1735
1736 ########################################################################### 1736 ###########################################################################
1737 ## Public Subversion specific methods are below. 1737 ## Public Subversion specific methods are below.
1738 ########################################################################### 1738 ###########################################################################
1739 1739
1813 log = "" 1813 log = ""
1814 target = target 1814 target = target
1815 dlg = \ 1815 dlg = \
1816 SvnDialog( 1816 SvnDialog(
1817 self.trUtf8('Copying {0}').format(name), 1817 self.trUtf8('Copying {0}').format(name),
1818 "copy{0} {1} {2}".format( 1818 "copy{0} {1} {2}".format(
1819 log and (" --message {0}".format(log)) or "", 1819 log and (" --message {0}".format(log)) or "",
1820 name, target), 1820 name, target),
1821 client, log=log) 1821 client, log=log)
1822 QApplication.processEvents() 1822 QApplication.processEvents()
1823 locker = QMutexLocker(self.vcsExecutionMutex) 1823 locker = QMutexLocker(self.vcsExecutionMutex)
1824 try: 1824 try:
1825 client.copy(name, target) 1825 client.copy(name, target)
1884 skipchecks = "--skip-checks" in opts 1884 skipchecks = "--skip-checks" in opts
1885 client = self.getClient() 1885 client = self.getClient()
1886 dlg = \ 1886 dlg = \
1887 SvnDialog( 1887 SvnDialog(
1888 self.trUtf8('Subversion Set Property'), 1888 self.trUtf8('Subversion Set Property'),
1889 "propset{0}{1} {2} {3} {4}".format( 1889 "propset{0}{1} {2} {3} {4}".format(
1890 recurse and " --recurse" or "", 1890 recurse and " --recurse" or "",
1891 skipchecks and " --skip-checks" or "", 1891 skipchecks and " --skip-checks" or "",
1892 propName, propValue, 1892 propName, propValue,
1893 " ".join(fnames)), 1893 " ".join(fnames)),
1894 client) 1894 client)
1895 QApplication.processEvents() 1895 QApplication.processEvents()
1896 try: 1896 try:
1897 for name in fnames: 1897 for name in fnames:
1898 client.propset(propName, propValue, name, 1898 client.propset(propName, propValue, name,
1938 skipchecks = "--skip-checks" in opts 1938 skipchecks = "--skip-checks" in opts
1939 client = self.getClient() 1939 client = self.getClient()
1940 dlg = \ 1940 dlg = \
1941 SvnDialog( 1941 SvnDialog(
1942 self.trUtf8('Subversion Delete Property'), 1942 self.trUtf8('Subversion Delete Property'),
1943 "propdel{0}{1} {2} {3}".format( 1943 "propdel{0}{1} {2} {3}".format(
1944 recurse and " --recurse" or "", 1944 recurse and " --recurse" or "",
1945 skipchecks and " --skip-checks" or "", 1945 skipchecks and " --skip-checks" or "",
1946 propName, " ".join(fnames)), 1946 propName, " ".join(fnames)),
1947 client) 1947 client)
1948 QApplication.processEvents() 1948 QApplication.processEvents()
1949 try: 1949 try:
1950 for name in fnames: 1950 for name in fnames:
1951 client.propdel(propName, name, 1951 client.propdel(propName, name,
2173 E5MessageBox.critical( 2173 E5MessageBox.critical(
2174 self.__ui, 2174 self.__ui,
2175 self.trUtf8("Subversion Side-by-Side Difference"), 2175 self.trUtf8("Subversion Side-by-Side Difference"),
2176 self.trUtf8( 2176 self.trUtf8(
2177 """<p>The file <b>{0}</b> could not be read.</p>""") 2177 """<p>The file <b>{0}</b> could not be read.</p>""")
2178 .format(name)) 2178 .format(name))
2179 return 2179 return
2180 2180
2181 if self.sbsDiff is None: 2181 if self.sbsDiff is None:
2182 from UI.CompareDialog import CompareDialog 2182 from UI.CompareDialog import CompareDialog
2183 self.sbsDiff = CompareDialog() 2183 self.sbsDiff = CompareDialog()
2228 os.chdir(dname) 2228 os.chdir(dname)
2229 client = self.getClient() 2229 client = self.getClient()
2230 dlg = \ 2230 dlg = \
2231 SvnDialog( 2231 SvnDialog(
2232 self.trUtf8('Locking in the Subversion repository'), 2232 self.trUtf8('Locking in the Subversion repository'),
2233 "lock{0}{1} {2}".format( 2233 "lock{0}{1} {2}".format(
2234 stealIt and " --force" or "", 2234 stealIt and " --force" or "",
2235 comment and (" --message {0}".format(comment)) or "", 2235 comment and (" --message {0}".format(comment)) or "",
2236 " ".join(fnames)), 2236 " ".join(fnames)),
2237 client, parent=parent) 2237 client, parent=parent)
2238 QApplication.processEvents() 2238 QApplication.processEvents()
2239 try: 2239 try:
2240 client.lock(fnames, comment, force=stealIt) 2240 client.lock(fnames, comment, force=stealIt)
2241 except pysvn.ClientError as e: 2241 except pysvn.ClientError as e:
2268 os.chdir(dname) 2268 os.chdir(dname)
2269 client = self.getClient() 2269 client = self.getClient()
2270 dlg = \ 2270 dlg = \
2271 SvnDialog( 2271 SvnDialog(
2272 self.trUtf8('Unlocking in the Subversion repository'), 2272 self.trUtf8('Unlocking in the Subversion repository'),
2273 "unlock{0} {1}".format( 2273 "unlock{0} {1}".format(
2274 breakIt and " --force" or "", 2274 breakIt and " --force" or "",
2275 " ".join(fnames)), 2275 " ".join(fnames)),
2276 client, parent=parent) 2276 client, parent=parent)
2277 QApplication.processEvents() 2277 QApplication.processEvents()
2278 try: 2278 try:
2279 client.unlock(fnames, force=breakIt) 2279 client.unlock(fnames, force=breakIt)
2280 except pysvn.ClientError as e: 2280 except pysvn.ClientError as e:
2539 helper.setObjects(self, project) 2539 helper.setObjects(self, project)
2540 self.__wcng = \ 2540 self.__wcng = \
2541 os.path.exists( 2541 os.path.exists(
2542 os.path.join(project.getProjectPath(), ".svn", "format")) or \ 2542 os.path.join(project.getProjectPath(), ".svn", "format")) or \
2543 os.path.exists( 2543 os.path.exists(
2544 os.path.join(project.getProjectPath(), "_svn", "format")) 2544 os.path.join(project.getProjectPath(), "_svn", "format")) or \
2545 os.path.exists(
2546 os.path.join(project.getProjectPath(), ".svn", "wc.db")) or \
2547 os.path.exists(
2548 os.path.join(project.getProjectPath(), "_svn", "wc.db"))
2545 return helper 2549 return helper
2546 2550
2547 ########################################################################### 2551 ###########################################################################
2548 ## Status Monitor Thread methods 2552 ## Status Monitor Thread methods
2549 ########################################################################### 2553 ###########################################################################

eric ide

mercurial