Plugins/VcsPlugins/vcsPySvn/subversion.py

changeset 3037
a417a0670a36
parent 3034
7ce719013078
child 3051
f08c20c91de7
equal deleted inserted replaced
3036:30c81c9e88b8 3037:a417a0670a36
309 if not noDialog: 309 if not noDialog:
310 dlg.showError(e.args[0]) 310 dlg.showError(e.args[0])
311 locker.unlock() 311 locker.unlock()
312 if not noDialog: 312 if not noDialog:
313 rev and dlg.showMessage(self.trUtf8("Imported revision {0}.\n") 313 rev and dlg.showMessage(self.trUtf8("Imported revision {0}.\n")
314 .format(rev.number)) 314 .format(rev.number))
315 dlg.finish() 315 dlg.finish()
316 dlg.exec_() 316 dlg.exec_()
317 os.chdir(cwd) 317 os.chdir(cwd)
318 318
319 shutil.rmtree(tmpDir, True) 319 shutil.rmtree(tmpDir, True)
369 if not noDialog: 369 if not noDialog:
370 dlg = SvnDialog( 370 dlg = SvnDialog(
371 self.trUtf8('Checking project out of Subversion repository'), 371 self.trUtf8('Checking project out of Subversion repository'),
372 "checkout{0} {1} {2}".format( 372 "checkout{0} {1} {2}".format(
373 (not recurse) and " --non-recursive" or "", 373 (not recurse) and " --non-recursive" or "",
374 url, projectDir), 374 url, projectDir),
375 client) 375 client)
376 QApplication.processEvents() 376 QApplication.processEvents()
377 locker = QMutexLocker(self.vcsExecutionMutex) 377 locker = QMutexLocker(self.vcsExecutionMutex)
378 try: 378 try:
379 client.checkout(url, projectDir, recurse) 379 client.checkout(url, projectDir, recurse)
433 client = self.getClient() 433 client = self.getClient()
434 dlg = SvnDialog( 434 dlg = SvnDialog(
435 self.trUtf8('Exporting project from Subversion repository'), 435 self.trUtf8('Exporting project from Subversion repository'),
436 "export --force{0} {1} {2}".format( 436 "export --force{0} {1} {2}".format(
437 (not recurse) and " --non-recursive" or "", 437 (not recurse) and " --non-recursive" or "",
438 url, projectDir), 438 url, projectDir),
439 client) 439 client)
440 QApplication.processEvents() 440 QApplication.processEvents()
441 locker = QMutexLocker(self.vcsExecutionMutex) 441 locker = QMutexLocker(self.vcsExecutionMutex)
442 try: 442 try:
443 client.export(url, projectDir, force=True, recurse=recurse) 443 client.export(url, projectDir, force=True, recurse=recurse)
497 # check for commit of the project 497 # check for commit of the project
498 if os.path.isdir(nam): 498 if os.path.isdir(nam):
499 project = e5App().getObject("Project") 499 project = e5App().getObject("Project")
500 if nam == project.getProjectPath(): 500 if nam == project.getProjectPath():
501 ok &= project.checkAllScriptsDirty( 501 ok &= project.checkAllScriptsDirty(
502 reportSyntaxErrors=True) and \ 502 reportSyntaxErrors=True) and \
503 project.checkDirty() 503 project.checkDirty()
504 continue 504 continue
505 elif os.path.isfile(nam): 505 elif os.path.isfile(nam):
506 editor = e5App().getObject("ViewManager")\ 506 editor = e5App().getObject("ViewManager")\
507 .getOpenEditor(nam) 507 .getOpenEditor(nam)
508 if editor: 508 if editor:
559 "commit{0}{1}{2}{3} --message {4} {5}".format( 559 "commit{0}{1}{2}{3} --message {4} {5}".format(
560 (not recurse) and " --non-recursive" or "", 560 (not recurse) and " --non-recursive" or "",
561 keeplocks and " --keep-locks" or "", 561 keeplocks and " --keep-locks" or "",
562 keepChangelists and " --keep-changelists" or "", 562 keepChangelists and " --keep-changelists" or "",
563 changelists and 563 changelists and
564 " --changelist ".join([""] + changelists) or "", 564 " --changelist ".join([""] + changelists) or "",
565 msg, " ".join(fnames)), 565 msg, " ".join(fnames)),
566 client) 566 client)
567 QApplication.processEvents() 567 QApplication.processEvents()
568 try: 568 try:
569 if changelists: 569 if changelists:
661 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 661 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
662 repodir = os.path.dirname(repodir) 662 repodir = os.path.dirname(repodir)
663 if os.path.splitdrive(repodir)[1] == os.sep: 663 if os.path.splitdrive(repodir)[1] == os.sep:
664 return # oops, project is not version controlled 664 return # oops, project is not version controlled
665 while os.path.normcase(dname) != os.path.normcase(repodir) and \ 665 while os.path.normcase(dname) != os.path.normcase(repodir) and \
666 (os.path.normcase(dname) not in self.statusCache or 666 (os.path.normcase(dname) not in self.statusCache or
667 self.statusCache[os.path.normcase(dname)] == 667 self.statusCache[os.path.normcase(dname)] ==
668 self.canBeAdded): 668 self.canBeAdded):
669 # add directories recursively, if they aren't in the 669 # add directories recursively, if they aren't in the
670 # repository already 670 # repository already
671 tree.insert(-1, dname) 671 tree.insert(-1, dname)
672 dname = os.path.dirname(dname) 672 dname = os.path.dirname(dname)
691 repodir = os.path.dirname(repodir) 691 repodir = os.path.dirname(repodir)
692 if os.path.splitdrive(repodir)[1] == os.sep: 692 if os.path.splitdrive(repodir)[1] == os.sep:
693 return # oops, project is not version controlled 693 return # oops, project is not version controlled
694 while os.path.normcase(d) != \ 694 while os.path.normcase(d) != \
695 os.path.normcase(repodir) and \ 695 os.path.normcase(repodir) and \
696 (d not in tree2 + tree) and \ 696 (d not in tree2 + tree) and \
697 (os.path.normcase(d) not in self.statusCache or 697 (os.path.normcase(d) not in self.statusCache or
698 self.statusCache[os.path.normcase(d)] == 698 self.statusCache[os.path.normcase(d)] ==
699 self.canBeAdded): 699 self.canBeAdded):
700 tree2.append(d) 700 tree2.append(d)
701 d = os.path.dirname(d) 701 d = os.path.dirname(d)
702 else: 702 else:
703 while not os.path.exists(os.path.join(d, self.adminDir)): 703 while not os.path.exists(os.path.join(d, self.adminDir)):
771 repodir = os.path.dirname(repodir) 771 repodir = os.path.dirname(repodir)
772 if os.path.splitdrive(repodir)[1] == os.sep: 772 if os.path.splitdrive(repodir)[1] == os.sep:
773 return # oops, project is not version controlled 773 return # oops, project is not version controlled
774 while os.path.normcase(d) != \ 774 while os.path.normcase(d) != \
775 os.path.normcase(repodir) and \ 775 os.path.normcase(repodir) and \
776 (d not in tree) and \ 776 (d not in tree) and \
777 (os.path.normcase(d) not in self.statusCache or 777 (os.path.normcase(d) not in self.statusCache or
778 self.statusCache[os.path.normcase(d)] == 778 self.statusCache[os.path.normcase(d)] ==
779 self.canBeAdded): 779 self.canBeAdded):
780 tree.append(d) 780 tree.append(d)
781 d = os.path.dirname(d) 781 d = os.path.dirname(d)
782 else: 782 else:
783 while not os.path.exists(os.path.join(d, self.adminDir)): 783 while not os.path.exists(os.path.join(d, self.adminDir)):
796 repodir = os.path.dirname(repodir) 796 repodir = os.path.dirname(repodir)
797 if os.path.splitdrive(repodir)[1] == os.sep: 797 if os.path.splitdrive(repodir)[1] == os.sep:
798 return # oops, project is not version controlled 798 return # oops, project is not version controlled
799 while os.path.normcase(dname) != \ 799 while os.path.normcase(dname) != \
800 os.path.normcase(repodir) and \ 800 os.path.normcase(repodir) and \
801 (os.path.normcase(dname) not in self.statusCache or 801 (os.path.normcase(dname) not in self.statusCache or
802 self.statusCache[os.path.normcase(dname)] == 802 self.statusCache[os.path.normcase(dname)] ==
803 self.canBeAdded): 803 self.canBeAdded):
804 # add directories recursively, if they aren't in the 804 # add directories recursively, if they aren't in the
805 # repository already 805 # repository already
806 tree.insert(-1, dname) 806 tree.insert(-1, dname)
807 dname = os.path.dirname(dname) 807 dname = os.path.dirname(dname)
929 target = target 929 target = target
930 if not noDialog: 930 if not noDialog:
931 dlg = \ 931 dlg = \
932 SvnDialog( 932 SvnDialog(
933 self.trUtf8('Moving {0}').format(name), 933 self.trUtf8('Moving {0}').format(name),
934 "move{0}{1} {2} {3}".format( 934 "move{0}{1} {2} {3}".format(
935 force and " --force" or "", 935 force and " --force" or "",
936 log and (" --message {0}".format(log)) or "", 936 log and (" --message {0}".format(log)) or "",
937 name, target), 937 name, target),
938 client, log=log) 938 client, log=log)
939 QApplication.processEvents() 939 QApplication.processEvents()
940 locker = QMutexLocker(self.vcsExecutionMutex) 940 locker = QMutexLocker(self.vcsExecutionMutex)
941 try: 941 try:
942 client.move(name, target, force=force) 942 client.move(name, target, force=force)
1335 rev2 = "" 1335 rev2 = ""
1336 client = self.getClient() 1336 client = self.getClient()
1337 dlg = \ 1337 dlg = \
1338 SvnDialog( 1338 SvnDialog(
1339 self.trUtf8('Merging {0}').format(name), 1339 self.trUtf8('Merging {0}').format(name),
1340 "merge{0}{1} {2} {3} {4}".format( 1340 "merge{0}{1} {2} {3} {4}".format(
1341 (not recurse) and " --non-recursive" or "", 1341 (not recurse) and " --non-recursive" or "",
1342 force and " --force" or "", 1342 force and " --force" or "",
1343 "{0}{1}".format(url1, rev1 and ("@" + rev1) or ""), 1343 "{0}{1}".format(url1, rev1 and ("@" + rev1) or ""),
1344 "{0}{1}".format(url2, rev2 and ("@" + rev2) or ""), 1344 "{0}{1}".format(url2, rev2 and ("@" + rev2) or ""),
1345 fname), 1345 fname),
1346 client) 1346 client)
1347 QApplication.processEvents() 1347 QApplication.processEvents()
1348 try: 1348 try:
1349 client.merge(url1, revision1, url2, revision2, fname, 1349 client.merge(url1, revision1, url2, revision2, fname,
1350 recurse=recurse, force=force) 1350 recurse=recurse, force=force)
1487 mixin._clientSslServerTrustPromptCallback 1487 mixin._clientSslServerTrustPromptCallback
1488 1488
1489 try: 1489 try:
1490 locker = QMutexLocker(self.vcsExecutionMutex) 1490 locker = QMutexLocker(self.vcsExecutionMutex)
1491 allFiles = client.status(dname, recurse=True, get_all=True, 1491 allFiles = client.status(dname, recurse=True, get_all=True,
1492 ignore=True, update=False) 1492 ignore=True, update=False)
1493 locker.unlock() 1493 locker.unlock()
1494 dirs = [x for x in names.keys() if os.path.isdir(x)] 1494 dirs = [x for x in names.keys() if os.path.isdir(x)]
1495 for file in allFiles: 1495 for file in allFiles:
1496 name = os.path.normcase(file.path) 1496 name = os.path.normcase(file.path)
1497 if file.is_versioned: 1497 if file.is_versioned:
1498 if name in names: 1498 if name in names:
1499 names[name] = self.canBeCommitted 1499 names[name] = self.canBeCommitted
1500 dn = name 1500 dn = name
1501 while os.path.splitdrive(dn)[1] != os.sep and \ 1501 while os.path.splitdrive(dn)[1] != os.sep and \
1502 dn != repodir: 1502 dn != repodir:
1503 dn = os.path.dirname(dn) 1503 dn = os.path.dirname(dn)
1504 if dn in self.statusCache and \ 1504 if dn in self.statusCache and \
1505 self.statusCache[dn] == self.canBeCommitted: 1505 self.statusCache[dn] == self.canBeCommitted:
1506 break 1506 break
1507 self.statusCache[dn] = self.canBeCommitted 1507 self.statusCache[dn] = self.canBeCommitted
1562 mixin._clientSslServerTrustPromptCallback 1562 mixin._clientSslServerTrustPromptCallback
1563 1563
1564 try: 1564 try:
1565 locker = QMutexLocker(self.vcsExecutionMutex) 1565 locker = QMutexLocker(self.vcsExecutionMutex)
1566 allFiles = client.status(dname, recurse=True, get_all=True, 1566 allFiles = client.status(dname, recurse=True, get_all=True,
1567 ignore=True, update=False) 1567 ignore=True, update=False)
1568 locker.unlock() 1568 locker.unlock()
1569 for file in allFiles: 1569 for file in allFiles:
1570 name = os.path.normcase(file.path) 1570 name = os.path.normcase(file.path)
1571 if file.is_versioned: 1571 if file.is_versioned:
1572 if name in names: 1572 if name in names:
1715 """<tr><td><b>Committed revision</b></td><td>{5}</td></tr>""" 1715 """<tr><td><b>Committed revision</b></td><td>{5}</td></tr>"""
1716 """<tr><td><b>Committed date</b></td><td>{6}</td></tr>""" 1716 """<tr><td><b>Committed date</b></td><td>{6}</td></tr>"""
1717 """<tr><td><b>Comitted time</b></td><td>{7}</td></tr>""" 1717 """<tr><td><b>Comitted time</b></td><td>{7}</td></tr>"""
1718 """<tr><td><b>Last author</b></td><td>{8}</td></tr>""" 1718 """<tr><td><b>Last author</b></td><td>{8}</td></tr>"""
1719 """</table>""" 1719 """</table>"""
1720 )\ 1720 )\
1721 .format(".".join([str(v) for v in pysvn.version]), 1721 .format(".".join([str(v) for v in pysvn.version]),
1722 ".".join([str(v) for v in pysvn.svn_version[:3]]), 1722 ".".join([str(v) for v in pysvn.svn_version[:3]]),
1723 apiVersion, 1723 apiVersion,
1724 entry.url, 1724 entry.url,
1725 entry.revision.number, 1725 entry.revision.number,
1727 time.strftime( 1727 time.strftime(
1728 "%Y-%m-%d", time.localtime(entry.commit_time)), 1728 "%Y-%m-%d", time.localtime(entry.commit_time)),
1729 time.strftime( 1729 time.strftime(
1730 "%H:%M:%S %Z", time.localtime(entry.commit_time)), 1730 "%H:%M:%S %Z", time.localtime(entry.commit_time)),
1731 entry.commit_author 1731 entry.commit_author
1732 ) 1732 )
1733 1733
1734 ########################################################################### 1734 ###########################################################################
1735 ## Public Subversion specific methods are below. 1735 ## Public Subversion specific methods are below.
1736 ########################################################################### 1736 ###########################################################################
1737 1737
1811 log = "" 1811 log = ""
1812 target = target 1812 target = target
1813 dlg = \ 1813 dlg = \
1814 SvnDialog( 1814 SvnDialog(
1815 self.trUtf8('Copying {0}').format(name), 1815 self.trUtf8('Copying {0}').format(name),
1816 "copy{0} {1} {2}".format( 1816 "copy{0} {1} {2}".format(
1817 log and (" --message {0}".format(log)) or "", 1817 log and (" --message {0}".format(log)) or "",
1818 name, target), 1818 name, target),
1819 client, log=log) 1819 client, log=log)
1820 QApplication.processEvents() 1820 QApplication.processEvents()
1821 locker = QMutexLocker(self.vcsExecutionMutex) 1821 locker = QMutexLocker(self.vcsExecutionMutex)
1822 try: 1822 try:
1823 client.copy(name, target) 1823 client.copy(name, target)
1882 skipchecks = "--skip-checks" in opts 1882 skipchecks = "--skip-checks" in opts
1883 client = self.getClient() 1883 client = self.getClient()
1884 dlg = \ 1884 dlg = \
1885 SvnDialog( 1885 SvnDialog(
1886 self.trUtf8('Subversion Set Property'), 1886 self.trUtf8('Subversion Set Property'),
1887 "propset{0}{1} {2} {3} {4}".format( 1887 "propset{0}{1} {2} {3} {4}".format(
1888 recurse and " --recurse" or "", 1888 recurse and " --recurse" or "",
1889 skipchecks and " --skip-checks" or "", 1889 skipchecks and " --skip-checks" or "",
1890 propName, propValue, 1890 propName, propValue,
1891 " ".join(fnames)), 1891 " ".join(fnames)),
1892 client) 1892 client)
1893 QApplication.processEvents() 1893 QApplication.processEvents()
1894 try: 1894 try:
1895 for name in fnames: 1895 for name in fnames:
1896 client.propset(propName, propValue, name, 1896 client.propset(propName, propValue, name,
1936 skipchecks = "--skip-checks" in opts 1936 skipchecks = "--skip-checks" in opts
1937 client = self.getClient() 1937 client = self.getClient()
1938 dlg = \ 1938 dlg = \
1939 SvnDialog( 1939 SvnDialog(
1940 self.trUtf8('Subversion Delete Property'), 1940 self.trUtf8('Subversion Delete Property'),
1941 "propdel{0}{1} {2} {3}".format( 1941 "propdel{0}{1} {2} {3}".format(
1942 recurse and " --recurse" or "", 1942 recurse and " --recurse" or "",
1943 skipchecks and " --skip-checks" or "", 1943 skipchecks and " --skip-checks" or "",
1944 propName, " ".join(fnames)), 1944 propName, " ".join(fnames)),
1945 client) 1945 client)
1946 QApplication.processEvents() 1946 QApplication.processEvents()
1947 try: 1947 try:
1948 for name in fnames: 1948 for name in fnames:
1949 client.propdel(propName, name, 1949 client.propdel(propName, name,
2171 E5MessageBox.critical( 2171 E5MessageBox.critical(
2172 self.__ui, 2172 self.__ui,
2173 self.trUtf8("Subversion Side-by-Side Difference"), 2173 self.trUtf8("Subversion Side-by-Side Difference"),
2174 self.trUtf8( 2174 self.trUtf8(
2175 """<p>The file <b>{0}</b> could not be read.</p>""") 2175 """<p>The file <b>{0}</b> could not be read.</p>""")
2176 .format(name)) 2176 .format(name))
2177 return 2177 return
2178 2178
2179 if self.sbsDiff is None: 2179 if self.sbsDiff is None:
2180 from UI.CompareDialog import CompareDialog 2180 from UI.CompareDialog import CompareDialog
2181 self.sbsDiff = CompareDialog() 2181 self.sbsDiff = CompareDialog()
2226 os.chdir(dname) 2226 os.chdir(dname)
2227 client = self.getClient() 2227 client = self.getClient()
2228 dlg = \ 2228 dlg = \
2229 SvnDialog( 2229 SvnDialog(
2230 self.trUtf8('Locking in the Subversion repository'), 2230 self.trUtf8('Locking in the Subversion repository'),
2231 "lock{0}{1} {2}".format( 2231 "lock{0}{1} {2}".format(
2232 stealIt and " --force" or "", 2232 stealIt and " --force" or "",
2233 comment and (" --message {0}".format(comment)) or "", 2233 comment and (" --message {0}".format(comment)) or "",
2234 " ".join(fnames)), 2234 " ".join(fnames)),
2235 client, parent=parent) 2235 client, parent=parent)
2236 QApplication.processEvents() 2236 QApplication.processEvents()
2237 try: 2237 try:
2238 client.lock(fnames, comment, force=stealIt) 2238 client.lock(fnames, comment, force=stealIt)
2239 except pysvn.ClientError as e: 2239 except pysvn.ClientError as e:
2266 os.chdir(dname) 2266 os.chdir(dname)
2267 client = self.getClient() 2267 client = self.getClient()
2268 dlg = \ 2268 dlg = \
2269 SvnDialog( 2269 SvnDialog(
2270 self.trUtf8('Unlocking in the Subversion repository'), 2270 self.trUtf8('Unlocking in the Subversion repository'),
2271 "unlock{0} {1}".format( 2271 "unlock{0} {1}".format(
2272 breakIt and " --force" or "", 2272 breakIt and " --force" or "",
2273 " ".join(fnames)), 2273 " ".join(fnames)),
2274 client, parent=parent) 2274 client, parent=parent)
2275 QApplication.processEvents() 2275 QApplication.processEvents()
2276 try: 2276 try:
2277 client.unlock(fnames, force=breakIt) 2277 client.unlock(fnames, force=breakIt)
2278 except pysvn.ClientError as e: 2278 except pysvn.ClientError as e:

eric ide

mercurial