diff options
author | Philip Thiem <ptthiem@gmail.com> | 2013-07-04 11:06:35 -0500 |
---|---|---|
committer | Philip Thiem <ptthiem@gmail.com> | 2013-07-04 11:06:35 -0500 |
commit | 6937c39c7f21cd6cda8271092b7672712e012674 (patch) | |
tree | 85bdce1002bc95aeae547702f7ebd4d48737b6f6 /setuptools/svn_utils.py | |
parent | 59532e4f0735aaf782119b5e9f353ab17a2b06ad (diff) | |
download | external_python_setuptools-6937c39c7f21cd6cda8271092b7672712e012674.tar.gz external_python_setuptools-6937c39c7f21cd6cda8271092b7672712e012674.tar.bz2 external_python_setuptools-6937c39c7f21cd6cda8271092b7672712e012674.zip |
get_url now uses pulldom
--HG--
extra : rebase_source : 233926ea03e438c2e86546c62e555a007654cacd
Diffstat (limited to 'setuptools/svn_utils.py')
-rw-r--r-- | setuptools/svn_utils.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/setuptools/svn_utils.py b/setuptools/svn_utils.py index e46e5ab6..57cf6849 100644 --- a/setuptools/svn_utils.py +++ b/setuptools/svn_utils.py @@ -4,12 +4,12 @@ import sys import codecs
from distutils import log
from xml.sax.saxutils import unescape
+import xml.dom.pulldom
#requires python >= 2.4
from subprocess import Popen as _Popen, PIPE as _PIPE
-
#It would seem that svn info --xml and svn list --xml were fully
#supported by 1.3.x the special casing of the entry files seem to start at
#1.4.x, so if we check for xml in entries and then fall back to the command
@@ -180,6 +180,7 @@ class SVNEntriesText(SVNEntries): return rev_numbers
def get_undeleted_records(self):
+ #Note for self this skip and only returns the children
undeleted = lambda s: s and s[0] and (len(s) < 6 or s[5] != 'delete')
result = [
section[0]
@@ -239,8 +240,6 @@ class SVNEntriesCMD(SVNEntries): #</info>
entrypathre = re.compile(r'<entry\s+[^>]*path="(\.+)">', re.I)
entryre = re.compile(r'<entry.*?</entry>', re.DOTALL or re.I)
- urlre = re.compile(r'<url>(.*?)</url>', re.I)
- revre = re.compile(r'<commit\s+[^>]*revision="(\d+)"', re.I)
namere = re.compile(r'<name>(.*?)</name>', re.I)
#svnversion return values (previous implementations return max revision)
@@ -257,13 +256,22 @@ class SVNEntriesCMD(SVNEntries): return self.entries
def is_valid(self):
- return bool(self.get_dir_data())
+ return self.get_dir_data() is not None
def get_dir_data(self):
- #regarding the shell argument, see: http://bugs.python.org/issue8557
+ #This returns the info entry for the directory ONLY
_, data = _run_command(['svn', 'info', '--xml', self.path])
- self.dir_data = self.entryre.findall(data)
- self.get_dir_data = self.__get_cached_dir_data
+
+ doc = xml.dom.pulldom.parseString(data)
+ self.dir_data = None
+ for event, node in doc:
+ if event=='START_ELEMENT' and node.nodeName=='entry':
+ doc.expandNode(node)
+ self.dir_data = node
+ break
+
+ if self.dir_data:
+ self.get_dir_data = self.__get_cached_dir_data
return self.dir_data
def get_entries(self):
@@ -273,9 +281,14 @@ class SVNEntriesCMD(SVNEntries): self.get_entries = self.__get_cached_entries
return self.entries
+
+
def get_url(self):
"Get repository URL"
- return self.urlre.search(self.get_dir_data()[0]).group(1)
+ url_element = self.get_dir_data().getElementsByTagName("url")[0]
+ url_text = [t.nodeValue for t in url_element.childNodes
+ if t.nodeType == t.TEXT_NODE]
+ return "".join(url_text)
def __get_cached_revision(self):
return self.revision
|