Fri, 13 Dec 2013 22:45:47 +0100
SVN/ PySVN plugins fixed. urllib.quote wrapper for unicode characters added. SBS diff fixed.
--- a/APIs/Python3/eric5.api Wed Dec 04 22:08:03 2013 +0100 +++ b/APIs/Python3/eric5.api Fri Dec 13 22:45:47 2013 +0100 @@ -8539,6 +8539,7 @@ eric5.Utilities.py3flakes.messages.UnusedImport?1(filename, lineno, name) eric5.Utilities.py3flakes.messages.UnusedVariable.message?7 eric5.Utilities.py3flakes.messages.UnusedVariable?1(filename, lineno, name) +eric5.Utilities.quote?4(url) eric5.Utilities.readEncodedFileWithHash?4(filename) eric5.Utilities.readStringFromStream?4(stream) eric5.Utilities.relpath?4(path, start=os.path.curdir)
--- a/Documentation/Help/source.qhp Wed Dec 04 22:08:03 2013 +0100 +++ b/Documentation/Help/source.qhp Fri Dec 13 22:45:47 2013 +0100 @@ -13243,6 +13243,7 @@ <keyword name="qtHandler" id="qtHandler" ref="eric5.E5Gui.E5ErrorMessage.html#qtHandler" /> <keyword name="question" id="question" ref="eric5.E5Gui.E5MessageBox.html#question" /> <keyword name="queues (Module)" id="queues (Module)" ref="eric5.Plugins.VcsPlugins.vcsMercurial.QueuesExtension.queues.html" /> + <keyword name="quote" id="quote" ref="eric5.Utilities.__init__.html#quote" /> <keyword name="rbclbr (Module)" id="rbclbr (Module)" ref="eric5.Utilities.ClassBrowsers.rbclbr.html" /> <keyword name="read" id="read" ref="eric5.DebugClients.Ruby.AsyncFile.html#read" /> <keyword name="readEncodedFile" id="readEncodedFile" ref="eric5.Utilities.SyntaxCheck.html#readEncodedFile" />
--- a/Documentation/Source/eric5.Utilities.__init__.html Wed Dec 04 22:08:03 2013 +0100 +++ b/Documentation/Source/eric5.Utilities.__init__.html Fri Dec 13 22:45:47 2013 +0100 @@ -193,6 +193,9 @@ <td><a href="#prepareQtMacBundle">prepareQtMacBundle</a></td> <td>Module function for starting Qt tools that are Mac OS X bundles.</td> </tr><tr> +<td><a href="#quote">quote</a></td> +<td>Replacement for the urllib.quote function because of unicode problems.</td> +</tr><tr> <td><a href="#readEncodedFileWithHash">readEncodedFileWithHash</a></td> <td>Function to read a file, calculate a hash value and decode its contents into proper text.</td> </tr><tr> @@ -1331,6 +1334,24 @@ </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> +<a NAME="quote" ID="quote"></a> +<h2>quote</h2> +<b>quote</b>(<i>url</i>) +<p> + Replacement for the urllib.quote function because of unicode problems. +</p><dl> +<dt><i>url</i></dt> +<dd> +text to quote +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +quoted url +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> <a NAME="readEncodedFileWithHash" ID="readEncodedFileWithHash"></a> <h2>readEncodedFileWithHash</h2> <b>readEncodedFileWithHash</b>(<i>filename</i>)
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Plugins/VcsPlugins/vcsMercurial/hg.py Fri Dec 13 22:45:47 2013 +0100 @@ -10,9 +10,8 @@ from __future__ import unicode_literals # __IGNORE_WARNING__ try: str = unicode - import urllib as parse except (NameError): - import urllib.parse as parse # __IGNORE_WARNING__ + pass import os import shutil @@ -1445,21 +1444,21 @@ host = url[2] port, path = url[3].split("/", 1) return "{0}:{1}:{2}:{3}/{4}".format( - scheme, user, host, port, parse.quote(path)) + scheme, user, host, port, Utilities.quote(path)) elif len(url) == 3: scheme = url[0] host = url[1] port, path = url[2].split("/", 1) return "{0}:{1}:{2}/{3}".format( - scheme, host, port, parse.quote(path)) + scheme, host, port, Utilities.quote(path)) else: scheme = url[0] if scheme == "file": - return "{0}:{1}".format(scheme, parse.quote(url[1])) + return "{0}:{1}".format(scheme, Utilities.quote(url[1])) else: host, path = url[1][2:].split("/", 1) return "{0}://{1}/{2}".format( - scheme, host, parse.quote(path)) + scheme, host, Utilities.quote(path)) def hgNormalizeURL(self, url): """
--- a/Plugins/VcsPlugins/vcsPySvn/SvnBlameDialog.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Plugins/VcsPlugins/vcsPySvn/SvnBlameDialog.py Fri Dec 13 22:45:47 2013 +0100 @@ -10,6 +10,7 @@ from __future__ import unicode_literals # __IGNORE_WARNING__ import os +import sys import pysvn @@ -77,9 +78,14 @@ annotations = self.client.annotate(fname) locker.unlock() for annotation in annotations: + author = annotation["author"] + line = annotation["line"] + if sys.version_info[0] == 2: + author = author.decode('utf-8') + line = line.decode('utf-8') self.__generateItem( - annotation["revision"].number, annotation["author"], - annotation["number"] + 1, annotation["line"]) + annotation["revision"].number, author, + annotation["number"] + 1, line) except pysvn.ClientError as e: locker.unlock() self.__showError(e.args[0] + '\n')
--- a/Plugins/VcsPlugins/vcsPySvn/SvnChangeListsDialog.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Plugins/VcsPlugins/vcsPySvn/SvnChangeListsDialog.py Fri Dec 13 22:45:47 2013 +0100 @@ -10,6 +10,7 @@ from __future__ import unicode_literals # __IGNORE_WARNING__ import os +import sys import pysvn @@ -87,6 +88,9 @@ for entry in entries: file = entry[0] changelist = entry[1] + if sys.version_info[0] == 2: + file = file.decode('utf-8') + changelist = changelist.decode('utf-8') if changelist not in self.changeListsDict: self.changeListsDict[changelist] = [] filename = file.replace(path + os.sep, "")
--- a/Plugins/VcsPlugins/vcsPySvn/SvnDiffDialog.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Plugins/VcsPlugins/vcsPySvn/SvnDiffDialog.py Fri Dec 13 22:45:47 2013 +0100 @@ -11,6 +11,7 @@ from __future__ import unicode_literals # __IGNORE_WARNING__ import os +import sys import pysvn @@ -215,10 +216,13 @@ recurse=recurse) diff_list = [] for diff_sum in diff_summary: + path = diff_sum['path'] + if sys.version_info[0] == 2: + path = path.decode('utf-8') diff_list.append("{0} {1}".format( self.__getDiffSummaryKind( diff_sum['summarize_kind']), - diff_sum['path'])) + path)) diffText = os.linesep.join(diff_list) else: diffText = self.client.diff( @@ -226,6 +230,8 @@ url1, revision1=rev1, url_or_path2=url2, revision2=rev2, recurse=recurse) + if sys.version_info[0] == 2: + diffText = diffText.decode('utf-8') else: if pegRev is not None: diffText = self.client.diff_peg( @@ -237,6 +243,8 @@ diffText = self.client.diff( tmpdir, name, revision1=rev1, revision2=rev2, recurse=recurse) + if sys.version_info[0] == 2: + diffText = diffText.decode('utf-8') counter = 0 for line in diffText.splitlines(): if line.startswith("--- ") or \
--- a/Plugins/VcsPlugins/vcsPySvn/SvnInfoDialog.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Plugins/VcsPlugins/vcsPySvn/SvnInfoDialog.py Fri Dec 13 22:45:47 2013 +0100 @@ -11,6 +11,7 @@ from __future__ import unicode_literals # __IGNORE_WARNING__ import os +import sys import pysvn @@ -65,6 +66,8 @@ entries = self.client.info2(fn, recurse=False) infoStr = "<table>" for path, info in entries: + if sys.version_info[0] == 2: + path = path.decode('utf-8') infoStr += self.trUtf8( "<tr><td><b>Path (relative to project):</b></td>" "<td>{0}</td></tr>").format(path)
--- a/Plugins/VcsPlugins/vcsPySvn/SvnLogBrowserDialog.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Plugins/VcsPlugins/vcsPySvn/SvnLogBrowserDialog.py Fri Dec 13 22:45:47 2013 +0100 @@ -10,6 +10,7 @@ from __future__ import unicode_literals # __IGNORE_WARNING__ import os +import sys import pysvn @@ -260,8 +261,13 @@ locker.unlock() for log in logs: + author = log["author"] + message = log["message"] + if sys.version_info[0] == 2: + author = author.decode('utf-8') + message = message.decode('utf-8') self.__generateLogItem( - log["author"], log["date"], log["message"], + author, log["date"], message, log["revision"], log['changed_paths']) dt = dateFromTime_t(log["date"]) if not self.__maxDate.isValid() and \
--- a/Plugins/VcsPlugins/vcsPySvn/SvnLogDialog.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Plugins/VcsPlugins/vcsPySvn/SvnLogDialog.py Fri Dec 13 22:45:47 2013 +0100 @@ -10,6 +10,7 @@ from __future__ import unicode_literals # __IGNORE_WARNING__ import os +import sys import pysvn @@ -151,8 +152,13 @@ dstr += '<br />\n' self.contents.insertHtml(dstr) + author = log["author"] + message = log["message"] + if sys.version_info[0] == 2: + author = author.decode('utf-8') + message = message.decode('utf-8') dstr = self.trUtf8('<i>author: {0}</i><br />\n')\ - .format(log["author"]) + .format(author) self.contents.insertHtml(dstr) dstr = self.trUtf8('<i>date: {0}</i><br />\n')\ @@ -161,20 +167,26 @@ self.contents.insertHtml('<br />\n') - for line in log["message"].splitlines(): + for line in message.splitlines(): self.contents.insertHtml(Utilities.html_encode(line)) self.contents.insertHtml('<br />\n') if len(log['changed_paths']) > 0: self.contents.insertHtml('<br />\n') for changeInfo in log['changed_paths']: - dstr = '{0} {1}'\ - .format(self.flags[changeInfo["action"]], - changeInfo["path"]) + action = changeInfo["action"] + path = changeInfo["path"] + if sys.version_info[0] == 2: + action = action.decode('utf-8') + path = path.decode('utf-8') + dstr = '{0} {1}'.format(self.flags[action], path) if changeInfo["copyfrom_path"] is not None: + copyfrom_path = changeInfo["copyfrom_path"] + if sys.version_info[0] == 2: + copyfrom_path = copyfrom_path.decode('utf-8') dstr += self.trUtf8( " (copied from {0}, revision {1})")\ - .format(changeInfo["copyfrom_path"], + .format(copyfrom_path, changeInfo["copyfrom_revision"].number) dstr += '<br />\n' self.contents.insertHtml(dstr)
--- a/Plugins/VcsPlugins/vcsPySvn/SvnPropListDialog.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Plugins/VcsPlugins/vcsPySvn/SvnPropListDialog.py Fri Dec 13 22:45:47 2013 +0100 @@ -11,6 +11,7 @@ from __future__ import unicode_literals # __IGNORE_WARNING__ import os +import sys import pysvn @@ -104,7 +105,12 @@ proplist = self.client.proplist(name, recurse=recursive) counter = 0 for path, prop in proplist: + if sys.version_info[0] == 2: + path = path.decode('utf-8') for propName, propVal in list(prop.items()): + if sys.version_info[0] == 2: + propName = propName.decode('utf-8') + propVal = propVal.decode('utf-8') self.__generateItem(path, propName, propVal) self.propsFound = True counter += 1
--- a/Plugins/VcsPlugins/vcsPySvn/SvnRepoBrowserDialog.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Plugins/VcsPlugins/vcsPySvn/SvnRepoBrowserDialog.py Fri Dec 13 22:45:47 2013 +0100 @@ -161,6 +161,7 @@ try: entries = self.client.list(url, recurse=False) firstTime = parent == self.repoTree + # dirent elements are all unicode in Python 2 for dirent, lock in entries: if (firstTime and dirent["path"] != url) or \ (parent != self.repoTree and dirent["path"] == url):
--- a/Plugins/VcsPlugins/vcsPySvn/SvnStatusDialog.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Plugins/VcsPlugins/vcsPySvn/SvnStatusDialog.py Fri Dec 13 22:45:47 2013 +0100 @@ -11,6 +11,7 @@ from __future__ import unicode_literals # __IGNORE_WARNING__ import os +import sys import pysvn @@ -317,6 +318,9 @@ depth = pysvn.depth.immediate changelists = self.client.get_changelist(name, depth=depth) for fpath, changelist in changelists: + if sys.version_info[0] == 2: + fpath = fpath.decode('utf-8') + changelist = changelist.decode('utf-8') fpath = Utilities.normcasepath(fpath) changelistsDict[fpath] = changelist hideChangelistColumn = hideChangelistColumn and \
--- a/Plugins/VcsPlugins/vcsPySvn/SvnTagBranchListDialog.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Plugins/VcsPlugins/vcsPySvn/SvnTagBranchListDialog.py Fri Dec 13 22:45:47 2013 +0100 @@ -133,6 +133,7 @@ os.chdir(dname) try: entries = self.client.list(path, recurse=False) + # dirent, lock already unicode in Python 2 for dirent, lock in entries: if dirent["path"] != path: name = dirent["path"].replace(path + '/', "")
--- a/Plugins/VcsPlugins/vcsPySvn/subversion.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Plugins/VcsPlugins/vcsPySvn/subversion.py Fri Dec 13 22:45:47 2013 +0100 @@ -10,8 +10,8 @@ from __future__ import unicode_literals # __IGNORE_WARNING__ import os +import sys import shutil -import urllib.parse import time from PyQt4.QtCore import Qt, QMutexLocker, pyqtSignal, QRegExp, QDateTime @@ -1078,10 +1078,10 @@ reposRoot = rx_base.cap(1) if tagOp in [1, 4]: - url = '{0}/tags/{1}'.format(reposRoot, urllib.parse.quote(tag)) + url = '{0}/tags/{1}'.format(reposRoot, Utilities.quote(tag)) elif tagOp in [2, 8]: url = '{0}/branches/{1}'.format( - reposRoot, urllib.parse.quote(tag)) + reposRoot, Utilities.quote(tag)) else: url = self.__svnURL(tag) @@ -1222,10 +1222,10 @@ reposRoot = rx_base.cap(1) tn = tag if tagType == 1: - url = '{0}/tags/{1}'.format(reposRoot, urllib.parse.quote(tag)) + url = '{0}/tags/{1}'.format(reposRoot, Utilities.quote(tag)) elif tagType == 2: url = '{0}/branches/{1}'.format( - reposRoot, urllib.parse.quote(tag)) + reposRoot, Utilities.quote(tag)) elif tagType == 4: url = '{0}/trunk'.format(reposRoot) tn = 'HEAD' @@ -1495,6 +1495,7 @@ locker.unlock() dirs = [x for x in names.keys() if os.path.isdir(x)] for file in allFiles: + # file.path is always unicode in Python 2 name = os.path.normcase(file.path) if file.is_versioned: if name in names: @@ -1569,6 +1570,7 @@ ignore=True, update=False) locker.unlock() for file in allFiles: + # file.path is always unicode in Python 2 name = os.path.normcase(file.path) if file.is_versioned: if name in names: @@ -1705,6 +1707,10 @@ pysvn.svn_api_version[3]) else: apiVersion = QApplication.translate('subversion', "unknown") + + hmsz = time.strftime("%H:%M:%S %Z", time.localtime(entry.commit_time)) + if sys.version_info[0] == 2: + hmsz = hmsz.decode(sys.getfilesystemencoding()) return QApplication.translate( 'subversion', """<h3>Repository information</h3>""" @@ -1728,8 +1734,7 @@ entry.commit_revision.number, time.strftime( "%Y-%m-%d", time.localtime(entry.commit_time)), - time.strftime( - "%H:%M:%S %Z", time.localtime(entry.commit_time)), + hmsz, entry.commit_author ) @@ -2112,7 +2117,7 @@ output = client.cat(name, revision=rev) else: output = client.cat(name) - output = output.decode() + output = output.decode('utf-8') except pysvn.ClientError as e: error = str(e) @@ -2447,6 +2452,8 @@ depth=pysvn.depth.infinity) for entry in entries: changelist = entry[1] + if sys.version_info[0] == 2: + changelist = changelist.decode('utf-8') if changelist not in changelists: changelists.append(changelist) except pysvn.ClientError: @@ -2473,11 +2480,11 @@ host = url[1] port, path = url[2].split("/", 1) return "{0}:{1}:{2}/{3}".format(scheme, host, port, - urllib.parse.quote(path)) + Utilities.quote(path)) else: scheme = url[0] if scheme == "file": - return "{0}:{1}".format(scheme, urllib.parse.quote(url[1])) + return "{0}:{1}".format(scheme, Utilities.quote(url[1])) else: try: host, path = url[1][2:].split("/", 1) @@ -2485,7 +2492,7 @@ host = url[1][2:] path = "" return "{0}://{1}/{2}".format(scheme, host, - urllib.parse.quote(path)) + Utilities.quote(path)) def svnNormalizeURL(self, url): """
--- a/Plugins/VcsPlugins/vcsSubversion/subversion.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Plugins/VcsPlugins/vcsSubversion/subversion.py Fri Dec 13 22:45:47 2013 +0100 @@ -16,7 +16,6 @@ import os import re import shutil -import urllib.parse from PyQt4.QtCore import pyqtSignal, QProcess, QRegExp from PyQt4.QtGui import QLineEdit, QDialog, QInputDialog, QApplication @@ -995,10 +994,10 @@ reposRoot = rx_base.cap(1) if tagOp in [1, 4]: - url = '{0}/tags/{1}'.format(reposRoot, urllib.parse.quote(tag)) + url = '{0}/tags/{1}'.format(reposRoot, Utilities.quote(tag)) elif tagOp in [2, 8]: url = '{0}/branches/{1}'.format( - reposRoot, urllib.parse.quote(tag)) + reposRoot, Utilities.quote(tag)) else: url = self.__svnURL(tag) @@ -1118,10 +1117,10 @@ reposRoot = rx_base.cap(1) tn = tag if tagType == 1: - url = '{0}/tags/{1}'.format(reposRoot, urllib.parse.quote(tag)) + url = '{0}/tags/{1}'.format(reposRoot, Utilities.quote(tag)) elif tagType == 2: url = '{0}/branches/{1}'.format( - reposRoot, urllib.parse.quote(tag)) + reposRoot, Utilities.quote(tag)) elif tagType == 4: url = '{0}/trunk'.format(reposRoot) tn = 'HEAD' @@ -2282,11 +2281,11 @@ host = url[1] port, path = url[2].split("/", 1) return "{0}:{1}:{2}/{3}".format( - scheme, host, port, urllib.parse.quote(path)) + scheme, host, port, Utilities.quote(path)) else: scheme = url[0] if scheme == "file": - return "{0}:{1}".format(scheme, urllib.parse.quote(url[1])) + return "{0}:{1}".format(scheme, Utilities.quote(url[1])) else: try: host, path = url[1][2:].split("/", 1) @@ -2294,7 +2293,7 @@ host = url[1][2:] path = "" return "{0}://{1}/{2}".format( - scheme, host, urllib.parse.quote(path)) + scheme, host, Utilities.quote(path)) def svnNormalizeURL(self, url): """
--- a/UI/CompareDialog.py Wed Dec 04 22:08:03 2013 +0100 +++ b/UI/CompareDialog.py Fri Dec 13 22:45:47 2013 +0100 @@ -9,6 +9,10 @@ """ from __future__ import unicode_literals # __IGNORE_WARNING__ +try: + basestring # __IGNORE_WARNING__ +except NameError: + basestring = str import re from difflib import _mdiff, IS_CHARACTER_JUNK @@ -276,9 +280,9 @@ self.diffButton.setEnabled(False) self.diffButton.hide() - if isinstance(lines1, str): + if isinstance(lines1, basestring): lines1 = lines1.splitlines(True) - if isinstance(lines2, str): + if isinstance(lines2, basestring): lines2 = lines2.splitlines(True) self.__compare(lines1, lines2)
--- a/Utilities/__init__.py Wed Dec 04 22:08:03 2013 +0100 +++ b/Utilities/__init__.py Fri Dec 13 22:45:47 2013 +0100 @@ -10,8 +10,19 @@ from __future__ import unicode_literals # __IGNORE_WARNING__ try: str = unicode # __IGNORE_WARNING__ + import urllib + + def quote(url): + """ + Replacement for the urllib.quote function because of unicode problems. + + @param url text to quote + @return quoted url + """ + return urllib.quote(url.encode('utf-8')) except (NameError): basestring = str + from urllib.parse import quote # __IGNORE_WARNING__ import os import sys