Plugins/VcsPlugins/vcsPySvn/subversion.py

branch
Py2 comp.
changeset 3141
72f3bde98c58
parent 3060
5883ce99ee12
child 3142
55030c09e142
equal deleted inserted replaced
3127:e47a9d5954e8 3141:72f3bde98c58
8 """ 8 """
9 9
10 from __future__ import unicode_literals # __IGNORE_WARNING__ 10 from __future__ import unicode_literals # __IGNORE_WARNING__
11 11
12 import os 12 import os
13 import sys
13 import shutil 14 import shutil
14 import urllib.parse
15 import time 15 import time
16 16
17 from PyQt4.QtCore import Qt, QMutexLocker, pyqtSignal, QRegExp, QDateTime 17 from PyQt4.QtCore import Qt, QMutexLocker, pyqtSignal, QRegExp, QDateTime
18 from PyQt4.QtGui import QLineEdit, QDialog, QInputDialog, QApplication 18 from PyQt4.QtGui import QLineEdit, QDialog, QInputDialog, QApplication
19 19
1076 """ be aborted""")) 1076 """ be aborted"""))
1077 return 1077 return
1078 1078
1079 reposRoot = rx_base.cap(1) 1079 reposRoot = rx_base.cap(1)
1080 if tagOp in [1, 4]: 1080 if tagOp in [1, 4]:
1081 url = '{0}/tags/{1}'.format(reposRoot, urllib.parse.quote(tag)) 1081 url = '{0}/tags/{1}'.format(reposRoot, Utilities.quote(tag))
1082 elif tagOp in [2, 8]: 1082 elif tagOp in [2, 8]:
1083 url = '{0}/branches/{1}'.format( 1083 url = '{0}/branches/{1}'.format(
1084 reposRoot, urllib.parse.quote(tag)) 1084 reposRoot, Utilities.quote(tag))
1085 else: 1085 else:
1086 url = self.__svnURL(tag) 1086 url = self.__svnURL(tag)
1087 1087
1088 self.tagName = tag 1088 self.tagName = tag
1089 client = self.getClient() 1089 client = self.getClient()
1220 return False 1220 return False
1221 1221
1222 reposRoot = rx_base.cap(1) 1222 reposRoot = rx_base.cap(1)
1223 tn = tag 1223 tn = tag
1224 if tagType == 1: 1224 if tagType == 1:
1225 url = '{0}/tags/{1}'.format(reposRoot, urllib.parse.quote(tag)) 1225 url = '{0}/tags/{1}'.format(reposRoot, Utilities.quote(tag))
1226 elif tagType == 2: 1226 elif tagType == 2:
1227 url = '{0}/branches/{1}'.format( 1227 url = '{0}/branches/{1}'.format(
1228 reposRoot, urllib.parse.quote(tag)) 1228 reposRoot, Utilities.quote(tag))
1229 elif tagType == 4: 1229 elif tagType == 4:
1230 url = '{0}/trunk'.format(reposRoot) 1230 url = '{0}/trunk'.format(reposRoot)
1231 tn = 'HEAD' 1231 tn = 'HEAD'
1232 else: 1232 else:
1233 url = self.__svnURL(tag) 1233 url = self.__svnURL(tag)
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 # file.path is always unicode in Python 2
1498 name = os.path.normcase(file.path) 1499 name = os.path.normcase(file.path)
1499 if file.is_versioned: 1500 if file.is_versioned:
1500 if name in names: 1501 if name in names:
1501 names[name] = self.canBeCommitted 1502 names[name] = self.canBeCommitted
1502 dn = name 1503 dn = name
1567 locker = QMutexLocker(self.vcsExecutionMutex) 1568 locker = QMutexLocker(self.vcsExecutionMutex)
1568 allFiles = client.status(dname, recurse=True, get_all=True, 1569 allFiles = client.status(dname, recurse=True, get_all=True,
1569 ignore=True, update=False) 1570 ignore=True, update=False)
1570 locker.unlock() 1571 locker.unlock()
1571 for file in allFiles: 1572 for file in allFiles:
1573 # file.path is always unicode in Python 2
1572 name = os.path.normcase(file.path) 1574 name = os.path.normcase(file.path)
1573 if file.is_versioned: 1575 if file.is_versioned:
1574 if name in names: 1576 if name in names:
1575 names[name] = self.canBeCommitted 1577 names[name] = self.canBeCommitted
1576 self.statusCache[name] = self.canBeCommitted 1578 self.statusCache[name] = self.canBeCommitted
1703 apiVersion = "{0} {1}".format( 1705 apiVersion = "{0} {1}".format(
1704 ".".join([str(v) for v in pysvn.svn_api_version[:3]]), 1706 ".".join([str(v) for v in pysvn.svn_api_version[:3]]),
1705 pysvn.svn_api_version[3]) 1707 pysvn.svn_api_version[3])
1706 else: 1708 else:
1707 apiVersion = QApplication.translate('subversion', "unknown") 1709 apiVersion = QApplication.translate('subversion', "unknown")
1710
1711 hmsz = time.strftime("%H:%M:%S %Z", time.localtime(entry.commit_time))
1712 if sys.version_info[0] == 2:
1713 hmsz = hmsz.decode(sys.getfilesystemencoding())
1708 return QApplication.translate( 1714 return QApplication.translate(
1709 'subversion', 1715 'subversion',
1710 """<h3>Repository information</h3>""" 1716 """<h3>Repository information</h3>"""
1711 """<table>""" 1717 """<table>"""
1712 """<tr><td><b>PySvn V.</b></td><td>{0}</td></tr>""" 1718 """<tr><td><b>PySvn V.</b></td><td>{0}</td></tr>"""
1726 entry.url, 1732 entry.url,
1727 entry.revision.number, 1733 entry.revision.number,
1728 entry.commit_revision.number, 1734 entry.commit_revision.number,
1729 time.strftime( 1735 time.strftime(
1730 "%Y-%m-%d", time.localtime(entry.commit_time)), 1736 "%Y-%m-%d", time.localtime(entry.commit_time)),
1731 time.strftime( 1737 hmsz,
1732 "%H:%M:%S %Z", time.localtime(entry.commit_time)),
1733 entry.commit_author 1738 entry.commit_author
1734 ) 1739 )
1735 1740
1736 ########################################################################### 1741 ###########################################################################
1737 ## Public Subversion specific methods are below. 1742 ## Public Subversion specific methods are below.
2110 else: 2115 else:
2111 rev = pysvn.Revision(pysvn.opt_revision_kind.unspecified) 2116 rev = pysvn.Revision(pysvn.opt_revision_kind.unspecified)
2112 output = client.cat(name, revision=rev) 2117 output = client.cat(name, revision=rev)
2113 else: 2118 else:
2114 output = client.cat(name) 2119 output = client.cat(name)
2115 output = output.decode() 2120 output = output.decode('utf-8')
2116 except pysvn.ClientError as e: 2121 except pysvn.ClientError as e:
2117 error = str(e) 2122 error = str(e)
2118 2123
2119 return output, error 2124 return output, error
2120 2125
2445 try: 2450 try:
2446 entries = client.get_changelist(ppath, 2451 entries = client.get_changelist(ppath,
2447 depth=pysvn.depth.infinity) 2452 depth=pysvn.depth.infinity)
2448 for entry in entries: 2453 for entry in entries:
2449 changelist = entry[1] 2454 changelist = entry[1]
2455 if sys.version_info[0] == 2:
2456 changelist = changelist.decode('utf-8')
2450 if changelist not in changelists: 2457 if changelist not in changelists:
2451 changelists.append(changelist) 2458 changelists.append(changelist)
2452 except pysvn.ClientError: 2459 except pysvn.ClientError:
2453 pass 2460 pass
2454 locker.unlock() 2461 locker.unlock()
2471 if len(url) == 3: 2478 if len(url) == 3:
2472 scheme = url[0] 2479 scheme = url[0]
2473 host = url[1] 2480 host = url[1]
2474 port, path = url[2].split("/", 1) 2481 port, path = url[2].split("/", 1)
2475 return "{0}:{1}:{2}/{3}".format(scheme, host, port, 2482 return "{0}:{1}:{2}/{3}".format(scheme, host, port,
2476 urllib.parse.quote(path)) 2483 Utilities.quote(path))
2477 else: 2484 else:
2478 scheme = url[0] 2485 scheme = url[0]
2479 if scheme == "file": 2486 if scheme == "file":
2480 return "{0}:{1}".format(scheme, urllib.parse.quote(url[1])) 2487 return "{0}:{1}".format(scheme, Utilities.quote(url[1]))
2481 else: 2488 else:
2482 try: 2489 try:
2483 host, path = url[1][2:].split("/", 1) 2490 host, path = url[1][2:].split("/", 1)
2484 except ValueError: 2491 except ValueError:
2485 host = url[1][2:] 2492 host = url[1][2:]
2486 path = "" 2493 path = ""
2487 return "{0}://{1}/{2}".format(scheme, host, 2494 return "{0}://{1}/{2}".format(scheme, host,
2488 urllib.parse.quote(path)) 2495 Utilities.quote(path))
2489 2496
2490 def svnNormalizeURL(self, url): 2497 def svnNormalizeURL(self, url):
2491 """ 2498 """
2492 Public method to normalize a url for subversion. 2499 Public method to normalize a url for subversion.
2493 2500

eric ide

mercurial