eric7/Plugins/VcsPlugins/vcsPySvn/subversion.py

branch
eric7
changeset 8354
12ebd3934fef
parent 8318
962bce857696
child 8356
68ec9c3d4de5
equal deleted inserted replaced
8353:799196d0b05d 8354:12ebd3934fef
18 from PyQt6.QtWidgets import QLineEdit, QDialog, QInputDialog, QApplication 18 from PyQt6.QtWidgets import QLineEdit, QDialog, QInputDialog, QApplication
19 19
20 from E5Gui.E5Application import e5App 20 from E5Gui.E5Application import e5App
21 from E5Gui import E5MessageBox 21 from E5Gui import E5MessageBox
22 22
23 from E5Utilities.E5MutexLocker import E5MutexLocker 23 from EricUtilities.EricMutexLocker import EricMutexLocker
24 24
25 from VCS.VersionControl import VersionControl 25 from VCS.VersionControl import VersionControl
26 26
27 import pysvn 27 import pysvn
28 28
314 "import{0} --message {1} .".format( 314 "import{0} --message {1} .".format(
315 (not recurse) and " --non-recursive" or "", msg), 315 (not recurse) and " --non-recursive" or "", msg),
316 client) 316 client)
317 QApplication.processEvents() 317 QApplication.processEvents()
318 try: 318 try:
319 with E5MutexLocker(self.vcsExecutionMutex): 319 with EricMutexLocker(self.vcsExecutionMutex):
320 rev = client.import_(".", url, msg, recurse, ignore=True) 320 rev = client.import_(".", url, msg, recurse, ignore=True)
321 status = True 321 status = True
322 except pysvn.ClientError as e: 322 except pysvn.ClientError as e:
323 status = False 323 status = False
324 rev = None 324 rev = None
390 (not recurse) and " --non-recursive" or "", 390 (not recurse) and " --non-recursive" or "",
391 url, projectDir), 391 url, projectDir),
392 client) 392 client)
393 QApplication.processEvents() 393 QApplication.processEvents()
394 try: 394 try:
395 with E5MutexLocker(self.vcsExecutionMutex): 395 with EricMutexLocker(self.vcsExecutionMutex):
396 client.checkout(url, projectDir, recurse) 396 client.checkout(url, projectDir, recurse)
397 status = True 397 status = True
398 except pysvn.ClientError as e: 398 except pysvn.ClientError as e:
399 status = False 399 status = False
400 if not noDialog: 400 if not noDialog:
455 (not recurse) and " --non-recursive" or "", 455 (not recurse) and " --non-recursive" or "",
456 url, projectDir), 456 url, projectDir),
457 client) 457 client)
458 QApplication.processEvents() 458 QApplication.processEvents()
459 try: 459 try:
460 with E5MutexLocker(self.vcsExecutionMutex): 460 with EricMutexLocker(self.vcsExecutionMutex):
461 client.export(url, projectDir, force=True, recurse=recurse) 461 client.export(url, projectDir, force=True, recurse=recurse)
462 status = True 462 status = True
463 except pysvn.ClientError as e: 463 except pysvn.ClientError as e:
464 status = False 464 status = False
465 dlg.showError(e.args[0]) 465 dlg.showError(e.args[0])
582 " --changelist ".join([""] + changelists) or "", 582 " --changelist ".join([""] + changelists) or "",
583 msg, " ".join(fnames)), 583 msg, " ".join(fnames)),
584 client) 584 client)
585 QApplication.processEvents() 585 QApplication.processEvents()
586 try: 586 try:
587 with E5MutexLocker(self.vcsExecutionMutex): 587 with EricMutexLocker(self.vcsExecutionMutex):
588 rev = ( 588 rev = (
589 client.checkin( 589 client.checkin(
590 fnames, msg, recurse=recurse, keep_locks=keeplocks, 590 fnames, msg, recurse=recurse, keep_locks=keeplocks,
591 keep_changelist=keepChangelists, 591 keep_changelist=keepChangelists,
592 changelists=changelists) 592 changelists=changelists)
636 (not recurse) and " --non-recursive" or "", 636 (not recurse) and " --non-recursive" or "",
637 " ".join(fnames)), 637 " ".join(fnames)),
638 client) 638 client)
639 QApplication.processEvents() 639 QApplication.processEvents()
640 try: 640 try:
641 with E5MutexLocker(self.vcsExecutionMutex): 641 with EricMutexLocker(self.vcsExecutionMutex):
642 client.update(fnames, recurse) 642 client.update(fnames, recurse)
643 except pysvn.ClientError as e: 643 except pysvn.ClientError as e:
644 dlg.showError(e.args[0]) 644 dlg.showError(e.args[0])
645 if not noDialog: 645 if not noDialog:
646 dlg.finish() 646 dlg.finish()
748 noignore and " --no-ignore" or "", 748 noignore and " --no-ignore" or "",
749 " ".join(names)), 749 " ".join(names)),
750 client) 750 client)
751 QApplication.processEvents() 751 QApplication.processEvents()
752 try: 752 try:
753 with E5MutexLocker(self.vcsExecutionMutex): 753 with EricMutexLocker(self.vcsExecutionMutex):
754 client.add(names, recurse=recurse, force=force, 754 client.add(names, recurse=recurse, force=force,
755 ignore=not noignore) 755 ignore=not noignore)
756 except pysvn.ClientError as e: 756 except pysvn.ClientError as e:
757 if not noDialog: 757 if not noDialog:
758 dlg.showError(e.args[0]) 758 dlg.showError(e.args[0])
856 ignore and " --ignore" or "", 856 ignore and " --ignore" or "",
857 " ".join(names)), 857 " ".join(names)),
858 client) 858 client)
859 QApplication.processEvents() 859 QApplication.processEvents()
860 try: 860 try:
861 with E5MutexLocker(self.vcsExecutionMutex): 861 with EricMutexLocker(self.vcsExecutionMutex):
862 client.add(names, recurse=recurse, force=force, ignore=ignore) 862 client.add(names, recurse=recurse, force=force, ignore=ignore)
863 except pysvn.ClientError as e: 863 except pysvn.ClientError as e:
864 dlg.showError(e.args[0]) 864 dlg.showError(e.args[0])
865 dlg.finish() 865 dlg.finish()
866 dlg.exec() 866 dlg.exec()
893 force and " --force" or "", 893 force and " --force" or "",
894 " ".join(name)), 894 " ".join(name)),
895 client) 895 client)
896 QApplication.processEvents() 896 QApplication.processEvents()
897 try: 897 try:
898 with E5MutexLocker(self.vcsExecutionMutex): 898 with EricMutexLocker(self.vcsExecutionMutex):
899 client.remove(name, force=force) 899 client.remove(name, force=force)
900 res = True 900 res = True
901 except pysvn.ClientError as e: 901 except pysvn.ClientError as e:
902 res = False 902 res = False
903 if not noDialog: 903 if not noDialog:
955 log and (" --message {0}".format(log)) or "", 955 log and (" --message {0}".format(log)) or "",
956 name, target), 956 name, target),
957 client, log=log) 957 client, log=log)
958 QApplication.processEvents() 958 QApplication.processEvents()
959 try: 959 try:
960 with E5MutexLocker(self.vcsExecutionMutex): 960 with EricMutexLocker(self.vcsExecutionMutex):
961 client.move(name, target, force=force) 961 client.move(name, target, force=force)
962 res = True 962 res = True
963 except pysvn.ClientError as e: 963 except pysvn.ClientError as e:
964 res = False 964 res = False
965 if not noDialog: 965 if not noDialog:
1094 .format(name), 1094 .format(name),
1095 "copy --message {0} {1} {2}".format(log, reposURL, url), 1095 "copy --message {0} {1} {2}".format(log, reposURL, url),
1096 client, log=log) 1096 client, log=log)
1097 QApplication.processEvents() 1097 QApplication.processEvents()
1098 try: 1098 try:
1099 with E5MutexLocker(self.vcsExecutionMutex): 1099 with EricMutexLocker(self.vcsExecutionMutex):
1100 rev = client.copy(reposURL, url) 1100 rev = client.copy(reposURL, url)
1101 except pysvn.ClientError as e: 1101 except pysvn.ClientError as e:
1102 dlg.showError(e.args[0]) 1102 dlg.showError(e.args[0])
1103 else: 1103 else:
1104 log = 'Deleted tag <{0}>'.format(self.tagName) 1104 log = 'Deleted tag <{0}>'.format(self.tagName)
1107 .format(name), 1107 .format(name),
1108 "remove --message {0} {1}".format(log, url), 1108 "remove --message {0} {1}".format(log, url),
1109 client, log=log) 1109 client, log=log)
1110 QApplication.processEvents() 1110 QApplication.processEvents()
1111 try: 1111 try:
1112 with E5MutexLocker(self.vcsExecutionMutex): 1112 with EricMutexLocker(self.vcsExecutionMutex):
1113 rev = client.remove(url) 1113 rev = client.remove(url)
1114 except pysvn.ClientError as e: 1114 except pysvn.ClientError as e:
1115 dlg.showError(e.args[0]) 1115 dlg.showError(e.args[0])
1116 rev and dlg.showMessage( 1116 rev and dlg.showMessage(
1117 self.tr("Revision {0}.\n").format(rev.number)) 1117 self.tr("Revision {0}.\n").format(rev.number))
1158 (not recurse) and " --non-recursive" or "", 1158 (not recurse) and " --non-recursive" or "",
1159 " ".join(name)), 1159 " ".join(name)),
1160 client) 1160 client)
1161 QApplication.processEvents() 1161 QApplication.processEvents()
1162 try: 1162 try:
1163 with E5MutexLocker(self.vcsExecutionMutex): 1163 with EricMutexLocker(self.vcsExecutionMutex):
1164 client.revert(name, recurse) 1164 client.revert(name, recurse)
1165 except pysvn.ClientError as e: 1165 except pysvn.ClientError as e:
1166 dlg.showError(e.args[0]) 1166 dlg.showError(e.args[0])
1167 dlg.finish() 1167 dlg.finish()
1168 dlg.exec() 1168 dlg.exec()
1235 dlg = SvnDialog(self.tr('Switching to {0}').format(tn), 1235 dlg = SvnDialog(self.tr('Switching to {0}').format(tn),
1236 "switch {0} {1}".format(url, name), 1236 "switch {0} {1}".format(url, name),
1237 client) 1237 client)
1238 QApplication.processEvents() 1238 QApplication.processEvents()
1239 try: 1239 try:
1240 with E5MutexLocker(self.vcsExecutionMutex): 1240 with EricMutexLocker(self.vcsExecutionMutex):
1241 rev = client.switch(name, url) 1241 rev = client.switch(name, url)
1242 dlg.showMessage(self.tr("Revision {0}.\n").format(rev.number)) 1242 dlg.showMessage(self.tr("Revision {0}.\n").format(rev.number))
1243 except pysvn.ClientError as e: 1243 except pysvn.ClientError as e:
1244 dlg.showError(e.args[0]) 1244 dlg.showError(e.args[0])
1245 dlg.finish() 1245 dlg.finish()
1341 "{0}{1}".format(url2, rev2 and ("@" + rev2) or ""), 1341 "{0}{1}".format(url2, rev2 and ("@" + rev2) or ""),
1342 fname), 1342 fname),
1343 client) 1343 client)
1344 QApplication.processEvents() 1344 QApplication.processEvents()
1345 try: 1345 try:
1346 with E5MutexLocker(self.vcsExecutionMutex): 1346 with EricMutexLocker(self.vcsExecutionMutex):
1347 client.merge(url1, revision1, url2, revision2, fname, 1347 client.merge(url1, revision1, url2, revision2, fname,
1348 recurse=recurse, force=force) 1348 recurse=recurse, force=force)
1349 except pysvn.ClientError as e: 1349 except pysvn.ClientError as e:
1350 dlg.showError(e.args[0]) 1350 dlg.showError(e.args[0])
1351 dlg.finish() 1351 dlg.finish()
1482 client.callback_ssl_server_trust_prompt = ( 1482 client.callback_ssl_server_trust_prompt = (
1483 mixin._clientSslServerTrustPromptCallback 1483 mixin._clientSslServerTrustPromptCallback
1484 ) 1484 )
1485 1485
1486 with contextlib.suppress(pysvn.ClientError): 1486 with contextlib.suppress(pysvn.ClientError):
1487 with E5MutexLocker(self.vcsExecutionMutex): 1487 with EricMutexLocker(self.vcsExecutionMutex):
1488 allFiles = client.status(dname, recurse=True, get_all=True, 1488 allFiles = client.status(dname, recurse=True, get_all=True,
1489 ignore=True, update=False) 1489 ignore=True, update=False)
1490 dirs = [x for x in names.keys() if os.path.isdir(x)] 1490 dirs = [x for x in names.keys() if os.path.isdir(x)]
1491 for file in allFiles: 1491 for file in allFiles:
1492 name = os.path.normcase(file.path) 1492 name = os.path.normcase(file.path)
1559 client.callback_ssl_server_trust_prompt = ( 1559 client.callback_ssl_server_trust_prompt = (
1560 mixin._clientSslServerTrustPromptCallback 1560 mixin._clientSslServerTrustPromptCallback
1561 ) 1561 )
1562 1562
1563 with contextlib.suppress(pysvn.ClientError): 1563 with contextlib.suppress(pysvn.ClientError):
1564 with E5MutexLocker(self.vcsExecutionMutex): 1564 with EricMutexLocker(self.vcsExecutionMutex):
1565 allFiles = client.status(dname, recurse=True, get_all=True, 1565 allFiles = client.status(dname, recurse=True, get_all=True,
1566 ignore=True, update=False) 1566 ignore=True, update=False)
1567 for file in allFiles: 1567 for file in allFiles:
1568 name = os.path.normcase(file.path) 1568 name = os.path.normcase(file.path)
1569 if self.__isVersioned(file): 1569 if self.__isVersioned(file):
1633 dlg = SvnDialog(self.tr('Cleaning up {0}').format(name), 1633 dlg = SvnDialog(self.tr('Cleaning up {0}').format(name),
1634 "cleanup {0}".format(name), 1634 "cleanup {0}".format(name),
1635 client) 1635 client)
1636 QApplication.processEvents() 1636 QApplication.processEvents()
1637 try: 1637 try:
1638 with E5MutexLocker(self.vcsExecutionMutex): 1638 with EricMutexLocker(self.vcsExecutionMutex):
1639 client.cleanup(name) 1639 client.cleanup(name)
1640 except pysvn.ClientError as e: 1640 except pysvn.ClientError as e:
1641 dlg.showError(e.args[0]) 1641 dlg.showError(e.args[0])
1642 dlg.finish() 1642 dlg.finish()
1643 dlg.exec() 1643 dlg.exec()
1760 @param path local path to get the svn repository path for (string) 1760 @param path local path to get the svn repository path for (string)
1761 @return string with the repository path URL 1761 @return string with the repository path URL
1762 """ 1762 """
1763 client = pysvn.Client() 1763 client = pysvn.Client()
1764 try: 1764 try:
1765 with E5MutexLocker(self.vcsExecutionMutex): 1765 with EricMutexLocker(self.vcsExecutionMutex):
1766 entry = client.info(path) 1766 entry = client.info(path)
1767 url = entry.url 1767 url = entry.url
1768 except pysvn.ClientError: 1768 except pysvn.ClientError:
1769 url = "" 1769 url = ""
1770 return url 1770 return url
1791 (not recurse) and " --non-recursive" or "", 1791 (not recurse) and " --non-recursive" or "",
1792 " ".join(fnames)), 1792 " ".join(fnames)),
1793 client) 1793 client)
1794 QApplication.processEvents() 1794 QApplication.processEvents()
1795 try: 1795 try:
1796 with E5MutexLocker(self.vcsExecutionMutex): 1796 with EricMutexLocker(self.vcsExecutionMutex):
1797 for name in fnames: 1797 for name in fnames:
1798 client.resolved(name, recurse=recurse) 1798 client.resolved(name, recurse=recurse)
1799 except pysvn.ClientError as e: 1799 except pysvn.ClientError as e:
1800 dlg.showError(e.args[0]) 1800 dlg.showError(e.args[0])
1801 dlg.finish() 1801 dlg.finish()
1831 log and (" --message {0}".format(log)) or "", 1831 log and (" --message {0}".format(log)) or "",
1832 name, target), 1832 name, target),
1833 client, log=log) 1833 client, log=log)
1834 QApplication.processEvents() 1834 QApplication.processEvents()
1835 try: 1835 try:
1836 with E5MutexLocker(self.vcsExecutionMutex): 1836 with EricMutexLocker(self.vcsExecutionMutex):
1837 client.copy(name, target) 1837 client.copy(name, target)
1838 res = True 1838 res = True
1839 except pysvn.ClientError as e: 1839 except pysvn.ClientError as e:
1840 res = False 1840 res = False
1841 dlg.showError(e.args[0]) 1841 dlg.showError(e.args[0])
1905 propName, propValue, 1905 propName, propValue,
1906 " ".join(fnames)), 1906 " ".join(fnames)),
1907 client) 1907 client)
1908 QApplication.processEvents() 1908 QApplication.processEvents()
1909 try: 1909 try:
1910 with E5MutexLocker(self.vcsExecutionMutex): 1910 with EricMutexLocker(self.vcsExecutionMutex):
1911 for name in fnames: 1911 for name in fnames:
1912 client.propset(propName, propValue, name, 1912 client.propset(propName, propValue, name,
1913 recurse=recurse, skip_checks=skipchecks) 1913 recurse=recurse, skip_checks=skipchecks)
1914 except pysvn.ClientError as e: 1914 except pysvn.ClientError as e:
1915 dlg.showError(e.args[0]) 1915 dlg.showError(e.args[0])
1956 skipchecks and " --skip-checks" or "", 1956 skipchecks and " --skip-checks" or "",
1957 propName, " ".join(fnames)), 1957 propName, " ".join(fnames)),
1958 client) 1958 client)
1959 QApplication.processEvents() 1959 QApplication.processEvents()
1960 try: 1960 try:
1961 with E5MutexLocker(self.vcsExecutionMutex): 1961 with EricMutexLocker(self.vcsExecutionMutex):
1962 for name in fnames: 1962 for name in fnames:
1963 client.propdel(propName, name, 1963 client.propdel(propName, name,
1964 recurse=recurse, skip_checks=skipchecks) 1964 recurse=recurse, skip_checks=skipchecks)
1965 except pysvn.ClientError as e: 1965 except pysvn.ClientError as e:
1966 dlg.showError(e.args[0]) 1966 dlg.showError(e.args[0])
2255 comment and (" --message {0}".format(comment)) or "", 2255 comment and (" --message {0}".format(comment)) or "",
2256 " ".join(fnames)), 2256 " ".join(fnames)),
2257 client, parent=parent) 2257 client, parent=parent)
2258 QApplication.processEvents() 2258 QApplication.processEvents()
2259 try: 2259 try:
2260 with E5MutexLocker(self.vcsExecutionMutex): 2260 with EricMutexLocker(self.vcsExecutionMutex):
2261 client.lock(fnames, comment, force=stealIt) 2261 client.lock(fnames, comment, force=stealIt)
2262 except pysvn.ClientError as e: 2262 except pysvn.ClientError as e:
2263 dlg.showError(e.args[0]) 2263 dlg.showError(e.args[0])
2264 except AttributeError as e: 2264 except AttributeError as e:
2265 dlg.showError(str(e)) 2265 dlg.showError(str(e))
2291 "unlock{0} {1}".format(breakIt and " --force" or "", 2291 "unlock{0} {1}".format(breakIt and " --force" or "",
2292 " ".join(fnames)), 2292 " ".join(fnames)),
2293 client, parent=parent) 2293 client, parent=parent)
2294 QApplication.processEvents() 2294 QApplication.processEvents()
2295 try: 2295 try:
2296 with E5MutexLocker(self.vcsExecutionMutex): 2296 with EricMutexLocker(self.vcsExecutionMutex):
2297 client.unlock(fnames, force=breakIt) 2297 client.unlock(fnames, force=breakIt)
2298 except pysvn.ClientError as e: 2298 except pysvn.ClientError as e:
2299 dlg.showError(e.args[0]) 2299 dlg.showError(e.args[0])
2300 except AttributeError as e: 2300 except AttributeError as e:
2301 dlg.showError(str(e)) 2301 dlg.showError(str(e))
2333 projectPath) 2333 projectPath)
2334 client = self.getClient() 2334 client = self.getClient()
2335 dlg = SvnDialog(self.tr('Relocating'), msg, client) 2335 dlg = SvnDialog(self.tr('Relocating'), msg, client)
2336 QApplication.processEvents() 2336 QApplication.processEvents()
2337 try: 2337 try:
2338 with E5MutexLocker(self.vcsExecutionMutex): 2338 with EricMutexLocker(self.vcsExecutionMutex):
2339 if inside: 2339 if inside:
2340 client.switch(projectPath, newUrl) 2340 client.switch(projectPath, newUrl)
2341 else: 2341 else:
2342 client.relocate(currUrl, newUrl, projectPath, 2342 client.relocate(currUrl, newUrl, projectPath,
2343 recurse=True) 2343 recurse=True)
2385 self.tr('Remove from changelist'), 2385 self.tr('Remove from changelist'),
2386 "changelist --remove {0}".format(" ".join(names)), 2386 "changelist --remove {0}".format(" ".join(names)),
2387 client) 2387 client)
2388 QApplication.processEvents() 2388 QApplication.processEvents()
2389 try: 2389 try:
2390 with E5MutexLocker(self.vcsExecutionMutex): 2390 with EricMutexLocker(self.vcsExecutionMutex):
2391 for name in names: 2391 for name in names:
2392 client.remove_from_changelists(name) 2392 client.remove_from_changelists(name)
2393 except pysvn.ClientError as e: 2393 except pysvn.ClientError as e:
2394 dlg.showError(e.args[0]) 2394 dlg.showError(e.args[0])
2395 dlg.finish() 2395 dlg.finish()
2421 self.tr('Add to changelist'), 2421 self.tr('Add to changelist'),
2422 "changelist {0}".format(" ".join(names)), 2422 "changelist {0}".format(" ".join(names)),
2423 client) 2423 client)
2424 QApplication.processEvents() 2424 QApplication.processEvents()
2425 try: 2425 try:
2426 with E5MutexLocker(self.vcsExecutionMutex): 2426 with EricMutexLocker(self.vcsExecutionMutex):
2427 for name in names: 2427 for name in names:
2428 client.add_to_changelist( 2428 client.add_to_changelist(
2429 name, clname, depth=pysvn.depth.infinity) 2429 name, clname, depth=pysvn.depth.infinity)
2430 except pysvn.ClientError as e: 2430 except pysvn.ClientError as e:
2431 dlg.showError(e.args[0]) 2431 dlg.showError(e.args[0])
2453 changelists = [] 2453 changelists = []
2454 client = self.getClient() 2454 client = self.getClient()
2455 if hasattr(client, 'get_changelist'): 2455 if hasattr(client, 'get_changelist'):
2456 ppath = e5App().getObject("Project").getProjectPath() 2456 ppath = e5App().getObject("Project").getProjectPath()
2457 with contextlib.suppress(pysvn.ClientError): 2457 with contextlib.suppress(pysvn.ClientError):
2458 with E5MutexLocker(self.vcsExecutionMutex): 2458 with EricMutexLocker(self.vcsExecutionMutex):
2459 entries = client.get_changelist( 2459 entries = client.get_changelist(
2460 ppath, depth=pysvn.depth.infinity) 2460 ppath, depth=pysvn.depth.infinity)
2461 for entry in entries: 2461 for entry in entries:
2462 changelist = entry[1] 2462 changelist = entry[1]
2463 if changelist not in changelists: 2463 if changelist not in changelists:
2476 self.tr('Upgrade'), 2476 self.tr('Upgrade'),
2477 "upgrade {0}".format(path), 2477 "upgrade {0}".format(path),
2478 client) 2478 client)
2479 QApplication.processEvents() 2479 QApplication.processEvents()
2480 try: 2480 try:
2481 with E5MutexLocker(self.vcsExecutionMutex): 2481 with EricMutexLocker(self.vcsExecutionMutex):
2482 client.upgrade(path) 2482 client.upgrade(path)
2483 except pysvn.ClientError as e: 2483 except pysvn.ClientError as e:
2484 dlg.showError(e.args[0]) 2484 dlg.showError(e.args[0])
2485 dlg.finish() 2485 dlg.finish()
2486 dlg.exec() 2486 dlg.exec()

eric ide

mercurial