Commit b4ba3389 authored by Philip Thiem's avatar Philip Thiem

Additional Tests, Various fixes, and encoding dealings

--HG--
extra : rebase_source : 2734e79e08e194923eab8c70f92cb77bce7daccf
parent 411379b7
...@@ -217,7 +217,7 @@ class egg_info(Command): ...@@ -217,7 +217,7 @@ class egg_info(Command):
@staticmethod @staticmethod
def get_svn_revision(): def get_svn_revision():
return str(svn_utils.parse_revision(os.curdir)) return str(svn_utils.SvnInfo.load(os.curdir).get_revision())
......
...@@ -8,73 +8,58 @@ from setuptools import svn_utils ...@@ -8,73 +8,58 @@ from setuptools import svn_utils
READMES = ('README', 'README.rst', 'README.txt') READMES = ('README', 'README.rst', 'README.txt')
entities = [
("&lt;","<"), ("&gt;", ">"), ("&quot;", '"'), ("&apos;", "'"),
("&amp;", "&")
]
def unescape(data): def walk_revctrl(dirname=''):
for old,new in entities: """Find all files under revision control"""
data = data.replace(old,new) for ep in pkg_resources.iter_entry_points('setuptools.file_finders'):
return data for item in ep.load()(dirname):
yield item
#TODO will need test case
class re_finder(object):
def re_finder(pattern, postproc=None): def __init__(self, path, pattern, postproc=None):
def find(dirname, filename): self.pattern = pattern
self.postproc = postproc
self.path = convert_path(path)
def _finder(self, dirname, filename):
f = open(filename,'rU') f = open(filename,'rU')
try:
data = f.read() data = f.read()
finally:
f.close() f.close()
for match in pattern.finditer(data): for match in self.pattern.finditer(data):
path = match.group(1) path = match.group(1)
if postproc: if postproc:
#postproc used to be used when the svn finder
#was an re_finder for calling unescape
path = postproc(path) path = postproc(path)
yield joinpath(dirname,path) yield svn_utils.joinpath(dirname,path)
return find
def joinpath(prefix,suffix):
if not prefix:
return suffix
return os.path.join(prefix,suffix)
def __call__(self, dirname=''):
path = svn_utils.joinpath(dirname, self.path)
def walk_revctrl(dirname=''):
"""Find all files under revision control"""
for ep in pkg_resources.iter_entry_points('setuptools.file_finders'):
for item in ep.load()(dirname):
yield item
def _default_revctrl(dirname=''):
for path, finder in finders:
path = joinpath(dirname,path)
if os.path.isfile(path): if os.path.isfile(path):
for path in finder(dirname,path): for path in self._finder(dirname,path):
if os.path.isfile(path): if os.path.isfile(path):
yield path yield path
elif os.path.isdir(path): elif os.path.isdir(path):
for item in _default_revctrl(path): for item in self.find(path):
yield item yield item
def entries_externals_finder(dirname, filename): def _default_revctrl(dirname=''):
for record in svn_utils.parse_dir_entries(dirname): 'Primary svn_cvs entry point'
yield joinpath(dirname, record) for finder in finders:
for item in finder(dirname):
for name in svn_utils.parse_externals(dirname): yield item
yield joinpath(dirname, name)
finders = [ finders = [
(convert_path('CVS/Entries'), re_finder('CVS/Entries', re.compile(r"^\w?/([^/]+)/", re.M)),
re_finder(re.compile(r"^\w?/([^/]+)/", re.M))), svn_utils.svn_finder,
#combined externals due to common interface
#combined externals and enteries due to lack of dir_props in 1.7
(convert_path('.svn/entries'), entries_externals_finder),
] ]
...@@ -88,6 +73,7 @@ finders = [ ...@@ -88,6 +73,7 @@ finders = [
class sdist(_sdist): class sdist(_sdist):
"""Smart sdist that finds anything supported by revision control""" """Smart sdist that finds anything supported by revision control"""
......
...@@ -26,6 +26,7 @@ if sys.version_info[0] < 3: ...@@ -26,6 +26,7 @@ if sys.version_info[0] < 3:
reduce = reduce reduce = reduce
unichr = unichr unichr = unichr
unicode = unicode unicode = unicode
bytes = str
from urllib import url2pathname from urllib import url2pathname
import urllib2 import urllib2
from urllib2 import urlopen, HTTPError, URLError, unquote, splituser from urllib2 import urlopen, HTTPError, URLError, unquote, splituser
...@@ -69,6 +70,7 @@ else: ...@@ -69,6 +70,7 @@ else:
from functools import reduce from functools import reduce
unichr = chr unichr = chr
unicode = str unicode = str
bytes = bytes
from urllib.error import HTTPError, URLError from urllib.error import HTTPError, URLError
import urllib.request as urllib2 import urllib.request as urllib2
from urllib.request import urlopen, url2pathname from urllib.request import urlopen, url2pathname
......
This diff is collapsed.
import os
import zipfile
import sys
import tempfile
import unittest
import shutil
import stat
def _extract(self, member, path=None, pwd=None):
"""for zipfile py2.5 borrowed from cpython"""
if not isinstance(member, zipfile.ZipInfo):
member = self.getinfo(member)
if path is None:
path = os.getcwd()
return _extract_member(self, member, path, pwd)
def _extract_from_zip(self, name, dest_path):
dest_file = open(dest_path, 'wb')
try:
dest_file.write(self.read(name))
finally:
dest_file.close()
def _extract_member(self, member, targetpath, pwd):
"""for zipfile py2.5 borrowed from cpython"""
# build the destination pathname, replacing
# forward slashes to platform specific separators.
# Strip trailing path separator, unless it represents the root.
if (targetpath[-1:] in (os.path.sep, os.path.altsep)
and len(os.path.splitdrive(targetpath)[1]) > 1):
targetpath = targetpath[:-1]
# don't include leading "/" from file name if present
if member.filename[0] == '/':
targetpath = os.path.join(targetpath, member.filename[1:])
else:
targetpath = os.path.join(targetpath, member.filename)
targetpath = os.path.normpath(targetpath)
# Create all upper directories if necessary.
upperdirs = os.path.dirname(targetpath)
if upperdirs and not os.path.exists(upperdirs):
os.makedirs(upperdirs)
if member.filename[-1] == '/':
if not os.path.isdir(targetpath):
os.mkdir(targetpath)
return targetpath
_extract_from_zip(self, member.filename, targetpath)
return targetpath
def _remove_dir(target):
#on windows this seems to a problem
for dir_path, dirs, files in os.walk(target):
os.chmod(dir_path, stat.S_IWRITE)
for filename in files:
os.chmod(os.path.join(dir_path, filename), stat.S_IWRITE)
shutil.rmtree(target)
class ZippedEnvironment(unittest.TestCase):
datafile = None
dataname = None
old_cwd = None
def setUp(self):
if not os.path.isfile(self.datafile):
self.old_cwd = None
return
self.old_cwd = os.getcwd()
self.temp_dir = tempfile.mkdtemp()
zip_file, source, target = [None, None, None]
try:
zip_file = zipfile.ZipFile(self.datafile)
for files in zip_file.namelist():
_extract(zip_file, files, self.temp_dir)
finally:
if zip_file:
zip_file.close()
del zip_file
os.chdir(os.path.join(self.temp_dir, self.dataname))
def tearDown(self):
try:
if self.old_cwd:
os.chdir(self.old_cwd)
_remove_dir(self.temp_dir)
except OSError:
#sigh?
pass
third_party3 file:///C:/development/svn_example/repos/svn13/extra1
third_party2 -r3 file:///C:/development/svn_example/repos/svn13/extra1
third_party -r1 file:///C:/development/svn_example/repos/svn13/extra1
<?xml version="1.0" encoding="utf-8"?>
<info>
<entry
kind="dir"
path="svn13_example"
revision="6">
<url>file:///C:/development/svn_example/repos/svn13/main</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn13/main</root>
<uuid>d2996769-47b0-9946-b618-da1aa3eceda3</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<prop-updated>2013-07-13T15:33:23.187500Z</prop-updated>
</wc-info>
<commit
revision="6">
<author>ptt</author>
<date>2013-07-13T15:33:28.359375Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn13_example\a file"
revision="6">
<url>file:///C:/development/svn_example/repos/svn13/main/a%20file</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn13/main</root>
<uuid>d2996769-47b0-9946-b618-da1aa3eceda3</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<text-updated>2013-07-13T15:33:21.109375Z</text-updated>
<checksum>a6166e5e98a5a503089cde9bc8031293</checksum>
</wc-info>
<commit
revision="3">
<author>ptt</author>
<date>2013-07-13T15:33:21.312500Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn13_example\to_delete"
revision="6">
<url>file:///C:/development/svn_example/repos/svn13/main/to_delete</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn13/main</root>
<uuid>d2996769-47b0-9946-b618-da1aa3eceda3</uuid>
</repository>
<wc-info>
<schedule>delete</schedule>
<text-updated>2013-07-13T15:33:28.140625Z</text-updated>
<checksum>d41d8cd98f00b204e9800998ecf8427e</checksum>
</wc-info>
<commit
revision="6">
<author>ptt</author>
<date>2013-07-13T15:33:28.359375Z</date>
</commit>
</entry>
<entry
kind="dir"
path="svn13_example\folder"
revision="6">
<url>file:///C:/development/svn_example/repos/svn13/main/folder</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn13/main</root>
<uuid>d2996769-47b0-9946-b618-da1aa3eceda3</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<prop-updated>2013-07-13T15:33:26.187500Z</prop-updated>
</wc-info>
<commit
revision="5">
<author>ptt</author>
<date>2013-07-13T15:33:26.312500Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn13_example\folder\quest.txt"
revision="6">
<url>file:///C:/development/svn_example/repos/svn13/main/folder/quest.txt</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn13/main</root>
<uuid>d2996769-47b0-9946-b618-da1aa3eceda3</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<text-updated>2013-07-13T15:33:20.109375Z</text-updated>
<checksum>795240c6a830c14f83961e57e07dad12</checksum>
</wc-info>
<commit
revision="2">
<author>ptt</author>
<date>2013-07-13T15:33:20.312500Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn13_example\folder\lalala.txt"
revision="6">
<url>file:///C:/development/svn_example/repos/svn13/main/folder/lalala.txt</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn13/main</root>
<uuid>d2996769-47b0-9946-b618-da1aa3eceda3</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<text-updated>2013-07-13T15:33:19.375000Z</text-updated>
<checksum>d41d8cd98f00b204e9800998ecf8427e</checksum>
</wc-info>
<commit
revision="1">
<author>ptt</author>
<date>2013-07-13T15:33:19.609375Z</date>
</commit>
</entry>
</info>
third_party3 file:///C:/development/svn_example/repos/svn13/extra1
third_party2 -r3 file:///C:/development/svn_example/repos/svn13/extra1
third_party -r1 file:///C:/development/svn_example/repos/svn13/extra1
<?xml version="1.0"?>
<info>
<entry
kind="dir"
path="svn14_example"
revision="6">
<url>file:///C:/development/svn_example/repos/svn14/main</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn14/main</root>
<uuid>c75942e5-8b7a-354d-b1cf-73dee23fa94f</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
</wc-info>
<commit
revision="6">
<author>ptt</author>
<date>2013-07-13T15:34:14.406250Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn14_example\a file"
revision="6">
<url>file:///C:/development/svn_example/repos/svn14/main/a%20file</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn14/main</root>
<uuid>c75942e5-8b7a-354d-b1cf-73dee23fa94f</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<text-updated>2013-07-13T15:34:08.109375Z</text-updated>
<checksum>a6166e5e98a5a503089cde9bc8031293</checksum>
</wc-info>
<commit
revision="3">
<author>ptt</author>
<date>2013-07-13T15:34:08.390625Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn14_example\to_delete"
revision="6">
<url>file:///C:/development/svn_example/repos/svn14/main/to_delete</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn14/main</root>
<uuid>c75942e5-8b7a-354d-b1cf-73dee23fa94f</uuid>
</repository>
<wc-info>
<schedule>delete</schedule>
<text-updated>2013-07-13T15:34:14.125000Z</text-updated>
<checksum>d41d8cd98f00b204e9800998ecf8427e</checksum>
</wc-info>
<commit
revision="6">
<author>ptt</author>
<date>2013-07-13T15:34:14.406250Z</date>
</commit>
</entry>
<entry
kind="dir"
path="svn14_example\folder"
revision="6">
<url>file:///C:/development/svn_example/repos/svn14/main/folder</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn14/main</root>
<uuid>c75942e5-8b7a-354d-b1cf-73dee23fa94f</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
</wc-info>
<commit
revision="5">
<author>ptt</author>
<date>2013-07-13T15:34:12.390625Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn14_example\folder\quest.txt"
revision="6">
<url>file:///C:/development/svn_example/repos/svn14/main/folder/quest.txt</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn14/main</root>
<uuid>c75942e5-8b7a-354d-b1cf-73dee23fa94f</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<text-updated>2013-07-13T15:34:07.109375Z</text-updated>
<checksum>795240c6a830c14f83961e57e07dad12</checksum>
</wc-info>
<commit
revision="2">
<author>ptt</author>
<date>2013-07-13T15:34:07.390625Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn14_example\folder\lalala.txt"
revision="6">
<url>file:///C:/development/svn_example/repos/svn14/main/folder/lalala.txt</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn14/main</root>
<uuid>c75942e5-8b7a-354d-b1cf-73dee23fa94f</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<text-updated>2013-07-13T15:34:06.250000Z</text-updated>
<checksum>d41d8cd98f00b204e9800998ecf8427e</checksum>
</wc-info>
<commit
revision="1">
<author>ptt</author>
<date>2013-07-13T15:34:06.531250Z</date>
</commit>
</entry>
</info>
third_party3 file:///C:/development/svn_example/repos/svn15/extra1
-r3 file:///C:/development/svn_example/repos/svn15/extra1 third_party2
file:///C:/development/svn_example/repos/svn15/extra1@r1 third_party
<?xml version="1.0"?>
<properties>
<target
path="C:/development/svn_example/svn15_example/folder">
<property
name="svn:externals">third_party3 file:///C:/development/svn_example/repos/svn15/extra2
-r3 file:///C:/development/svn_example/repos/svn15/extra2 third_party2
file:///C:/development/svn_example/repos/svn15/extra2@r1 third_party大介
</property>
</target>
<target
path="C:/development/svn_example/svn15_example">
<property
name="svn:externals">third_party3 file:///C:/development/svn_example/repos/svn15/extra1
-r3 file:///C:/development/svn_example/repos/svn15/extra1 third_party2
file:///C:/development/svn_example/repos/svn15/extra1@r1 third_party大介
</property>
</target>
</properties>
<?xml version="1.0"?>
<info>
<entry
kind="dir"
path="svn15_example"
revision="6">
<url>file:///C:/development/svn_example/repos/svn15/main</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn15/main</root>
<uuid>4eab6983-54fe-384b-a282-9306f52d948f</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<depth>infinity</depth>
</wc-info>
<commit
revision="6">
<author>ptt</author>
<date>2013-07-13T15:34:49.562500Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn15_example\a file"
revision="6">
<url>file:///C:/development/svn_example/repos/svn15/main/a%20file</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn15/main</root>
<uuid>4eab6983-54fe-384b-a282-9306f52d948f</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:34:43.109375Z</text-updated>
<checksum>a6166e5e98a5a503089cde9bc8031293</checksum>
</wc-info>
<commit
revision="3">
<author>ptt</author>
<date>2013-07-13T15:34:43.484375Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn15_example\to_delete"
revision="6">
<url>file:///C:/development/svn_example/repos/svn15/main/to_delete</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn15/main</root>
<uuid>4eab6983-54fe-384b-a282-9306f52d948f</uuid>
</repository>
<wc-info>
<schedule>delete</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:34:49.125000Z</text-updated>
<checksum>d41d8cd98f00b204e9800998ecf8427e</checksum>
</wc-info>
<commit
revision="6">
<author>ptt</author>
<date>2013-07-13T15:34:49.562500Z</date>
</commit>
</entry>
<entry
kind="dir"
path="svn15_example\folder"
revision="6">
<url>file:///C:/development/svn_example/repos/svn15/main/folder</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn15/main</root>
<uuid>4eab6983-54fe-384b-a282-9306f52d948f</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<depth>infinity</depth>
</wc-info>
<commit
revision="5">
<author>ptt</author>
<date>2013-07-13T15:34:47.515625Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn15_example\folder\quest.txt"
revision="6">
<url>file:///C:/development/svn_example/repos/svn15/main/folder/quest.txt</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn15/main</root>
<uuid>4eab6983-54fe-384b-a282-9306f52d948f</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:34:42.109375Z</text-updated>
<checksum>795240c6a830c14f83961e57e07dad12</checksum>
</wc-info>
<commit
revision="2">
<author>ptt</author>
<date>2013-07-13T15:34:42.484375Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn15_example\folder\lalala.txt"
revision="6">
<url>file:///C:/development/svn_example/repos/svn15/main/folder/lalala.txt</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn15/main</root>
<uuid>4eab6983-54fe-384b-a282-9306f52d948f</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:34:41.375000Z</text-updated>
<checksum>d41d8cd98f00b204e9800998ecf8427e</checksum>
</wc-info>
<commit
revision="1">
<author>ptt</author>
<date>2013-07-13T15:34:41.734375Z</date>
</commit>
</entry>
</info>
"third party3" file:///C:/development/svn_example/repos/svn16/extra1
'third party3b' file:///C:/development/svn_example/repos/svn16/extra1
-r3 file:///C:/development/svn_example/repos/svn16/extra1 third\ party2
file:///C:/development/svn_example/repos/svn16/extra1@r1 third_party
<?xml version="1.0"?>
<properties>
<target
path="C:/development/svn_example/svn16_example/folder">
<property
name="svn:externals">"third party3" file:///C:/development/svn_example/repos/svn16/extra2
-r3 file:///C:/development/svn_example/repos/svn16/extra2 third\ party2
file:///C:/development/svn_example/repos/svn16/extra2@r1 third_party大介
</property>
</target>
<target
path="C:/development/svn_example/svn16_example">
<property
name="svn:externals">"third party3" file:///C:/development/svn_example/repos/svn16/extra1
-r3 file:///C:/development/svn_example/repos/svn16/extra1 third\ party2
file:///C:/development/svn_example/repos/svn16/extra1@r1 third_party大介
</property>
</target>
</properties>
<?xml version="1.0"?>
<info>
<entry
kind="dir"
path="svn16_example"
revision="6">
<url>file:///C:/development/svn_example/repos/svn16/main</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn16/main</root>
<uuid>bd8d2cfc-1a74-de45-b166-262010c17c0a</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<depth>infinity</depth>
</wc-info>
<commit
revision="6">
<author>ptt</author>
<date>2013-07-13T15:35:17.390625Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn16_example\a file"
revision="6">
<url>file:///C:/development/svn_example/repos/svn16/main/a%20file</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn16/main</root>
<uuid>bd8d2cfc-1a74-de45-b166-262010c17c0a</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:35:14.578125Z</text-updated>
<checksum>a6166e5e98a5a503089cde9bc8031293</checksum>
</wc-info>
<commit
revision="3">
<author>ptt</author>
<date>2013-07-13T15:35:14.906250Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn16_example\to_delete"
revision="6">
<url>file:///C:/development/svn_example/repos/svn16/main/to_delete</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn16/main</root>
<uuid>bd8d2cfc-1a74-de45-b166-262010c17c0a</uuid>
</repository>
<wc-info>
<schedule>delete</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:35:17.046875Z</text-updated>
<checksum>d41d8cd98f00b204e9800998ecf8427e</checksum>
</wc-info>
<commit
revision="6">
<author>ptt</author>
<date>2013-07-13T15:35:17.390625Z</date>
</commit>
</entry>
<entry
kind="dir"
path="svn16_example\folder"
revision="6">
<url>file:///C:/development/svn_example/repos/svn16/main/folder</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn16/main</root>
<uuid>bd8d2cfc-1a74-de45-b166-262010c17c0a</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<depth>infinity</depth>
</wc-info>
<commit
revision="5">
<author>ptt</author>
<date>2013-07-13T15:35:16.406250Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn16_example\folder\quest.txt"
revision="6">
<url>file:///C:/development/svn_example/repos/svn16/main/folder/quest.txt</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn16/main</root>
<uuid>bd8d2cfc-1a74-de45-b166-262010c17c0a</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:35:14.078125Z</text-updated>
<checksum>795240c6a830c14f83961e57e07dad12</checksum>
</wc-info>
<commit
revision="2">
<author>ptt</author>
<date>2013-07-13T15:35:14.421875Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn16_example\folder\lalala.txt"
revision="6">
<url>file:///C:/development/svn_example/repos/svn16/main/folder/lalala.txt</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn16/main</root>
<uuid>bd8d2cfc-1a74-de45-b166-262010c17c0a</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:35:12.171875Z</text-updated>
<checksum>d41d8cd98f00b204e9800998ecf8427e</checksum>
</wc-info>
<commit
revision="1">
<author>ptt</author>
<date>2013-07-13T15:35:13.906250Z</date>
</commit>
</entry>
</info>
"third party3" file:///C:/development/svn_example/repos/svn17/extra1
'third party3b' file:///C:/development/svn_example/repos/svn17/extra1
-r3 file:///C:/development/svn_example/repos/svn17/extra1 third\ party2
file:///C:/development/svn_example/repos/svn17/extra1@r1 third_party
<?xml version="1.0" encoding="UTF-8"?>
<properties>
<target
path="C:/development/svn_example/svn17_example">
<property
name="svn:externals">"third party3" file:///C:/development/svn_example/repos/svn16/extra1
-r3 file:///C:/development/svn_example/repos/svn16/extra1 third\ party2
file:///C:/development/svn_example/repos/svn16/extra1@r1 third_party大介
</property>
</target>
<target
path="C:/development/svn_example/svn17_example/folder">
<property
name="svn:externals">"third party3" file:///C:/development/svn_example/repos/svn17/extra2
-r3 file:///C:/development/svn_example/repos/svn17/extra2 third\ party2
file:///C:/development/svn_example/repos/svn17/extra2@r1 third_party大介
</property>
</target>
</properties>
<?xml version="1.0" encoding="UTF-8"?>
<info>
<entry
kind="dir"
path="svn17_example"
revision="6">
<url>file:///C:/development/svn_example/repos/svn17/main</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn17/main</root>
<uuid>5ba45434-5197-164e-afab-81923f4744f5</uuid>
</repository>
<wc-info>
<wcroot-abspath>C:/development/svn_example/svn17_example</wcroot-abspath>
<schedule>normal</schedule>
<depth>infinity</depth>
</wc-info>
<commit
revision="6">
<author>ptt</author>
<date>2013-07-13T15:35:36.171875Z</date>
</commit>
</entry>
<entry
path="svn17_example\folder"
revision="6"
kind="dir">
<url>file:///C:/development/svn_example/repos/svn17/main/folder</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn17/main</root>
<uuid>5ba45434-5197-164e-afab-81923f4744f5</uuid>
</repository>
<wc-info>
<wcroot-abspath>C:/development/svn_example/svn17_example</wcroot-abspath>
<schedule>normal</schedule>
<depth>infinity</depth>
</wc-info>
<commit
revision="5">
<author>ptt</author>
<date>2013-07-13T15:35:34.859375Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn17_example\folder\quest.txt"
revision="6">
<url>file:///C:/development/svn_example/repos/svn17/main/folder/quest.txt</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn17/main</root>
<uuid>5ba45434-5197-164e-afab-81923f4744f5</uuid>
</repository>
<wc-info>
<wcroot-abspath>C:/development/svn_example/svn17_example</wcroot-abspath>
<schedule>normal</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:35:32.812500Z</text-updated>
<checksum>bc80eba9e7a10c0a571a4678c520bc9683f3bac2</checksum>
</wc-info>
<commit
revision="2">
<author>ptt</author>
<date>2013-07-13T15:35:33.109375Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn17_example\folder\lalala.txt"
revision="6">
<url>file:///C:/development/svn_example/repos/svn17/main/folder/lalala.txt</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn17/main</root>
<uuid>5ba45434-5197-164e-afab-81923f4744f5</uuid>
</repository>
<wc-info>
<wcroot-abspath>C:/development/svn_example/svn17_example</wcroot-abspath>
<schedule>normal</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:35:32.343750Z</text-updated>
<checksum>da39a3ee5e6b4b0d3255bfef95601890afd80709</checksum>
</wc-info>
<commit
revision="1">
<author>ptt</author>
<date>2013-07-13T15:35:32.687500Z</date>
</commit>
</entry>
<entry
path="svn17_example\a file"
revision="6"
kind="file">
<url>file:///C:/development/svn_example/repos/svn17/main/a%20file</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn17/main</root>
<uuid>5ba45434-5197-164e-afab-81923f4744f5</uuid>
</repository>
<wc-info>
<wcroot-abspath>C:/development/svn_example/svn17_example</wcroot-abspath>
<schedule>normal</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:35:33.187500Z</text-updated>
<checksum>43785ab4b1816b49f242990883292813cd4f486c</checksum>
</wc-info>
<commit
revision="3">
<author>ptt</author>
<date>2013-07-13T15:35:33.515625Z</date>
</commit>
</entry>
<entry
path="svn17_example\to_delete"
revision="6"
kind="file">
<url>file:///C:/development/svn_example/repos/svn17/main/to_delete</url>
<repository>
<root>file:///C:/development/svn_example/repos/svn17/main</root>
<uuid>5ba45434-5197-164e-afab-81923f4744f5</uuid>
</repository>
<wc-info>
<wcroot-abspath>C:/development/svn_example/svn17_example</wcroot-abspath>
<schedule>delete</schedule>
<depth>infinity</depth>
<checksum>da39a3ee5e6b4b0d3255bfef95601890afd80709</checksum>
</wc-info>
<commit
revision="6">
<author>ptt</author>
<date>2013-07-13T15:35:36.171875Z</date>
</commit>
</entry>
</info>
"third party3" file:///C:/development/svn_example/repos/svn18/extra1
'third party3b' file:///C:/development/svn_example/repos/svn18/extra1
-r3 file:///C:/development/svn_example/repos/svn18/extra1 third\ party2
file:///C:/development/svn_example/repos/svn18/extra1@r1 third_party
<?xml version="1.0" encoding="UTF-8"?>
<properties>
<target
path="C:/development/svn_example/svn18_example">
<property
name="svn:externals">"third party3" file:///C:/development/svn_example/repos/svn16/extra1
-r3 file:///C:/development/svn_example/repos/svn16/extra1 third\ party2
file:///C:/development/svn_example/repos/svn16/extra1@r1 third_party大介
</property>
</target>
<target
path="C:/development/svn_example/svn18_example/folder">
<property
name="svn:externals">"third party3" file:///C:/development/svn_example/repos/svn18/extra2
-r3 file:///C:/development/svn_example/repos/svn18/extra2 third\ party2
file:///C:/development/svn_example/repos/svn18/extra2@r1 third_party大介
</property>
</target>
</properties>
<?xml version="1.0" encoding="UTF-8"?>
<info>
<entry
path="svn18_example"
revision="6"
kind="dir">
<url>file:///C:/development/svn_example/repos/svn18/main</url>
<relative-url>^/</relative-url>
<repository>
<root>file:///C:/development/svn_example/repos/svn18/main</root>
<uuid>3c5e3929-c92b-7045-9ba9-5e65d3dd1ee9</uuid>
</repository>
<wc-info>
<wcroot-abspath>C:/development/svn_example/svn18_example</wcroot-abspath>
<schedule>normal</schedule>
<depth>infinity</depth>
</wc-info>
<commit
revision="6">
<author>ptt</author>
<date>2013-07-13T15:35:57.796875Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn18_example\a file"
revision="6">
<url>file:///C:/development/svn_example/repos/svn18/main/a%20file</url>
<relative-url>^/a%20file</relative-url>
<repository>
<root>file:///C:/development/svn_example/repos/svn18/main</root>
<uuid>3c5e3929-c92b-7045-9ba9-5e65d3dd1ee9</uuid>
</repository>
<wc-info>
<wcroot-abspath>C:/development/svn_example/svn18_example</wcroot-abspath>
<schedule>normal</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:35:54.906250Z</text-updated>
<checksum>43785ab4b1816b49f242990883292813cd4f486c</checksum>
</wc-info>
<commit
revision="3">
<author>ptt</author>
<date>2013-07-13T15:35:55.265625Z</date>
</commit>
</entry>
<entry
kind="file"
path="svn18_example\to_delete"
revision="6">
<url>file:///C:/development/svn_example/repos/svn18/main/to_delete</url>
<relative-url>^/to_delete</relative-url>
<repository>
<root>file:///C:/development/svn_example/repos/svn18/main</root>
<uuid>3c5e3929-c92b-7045-9ba9-5e65d3dd1ee9</uuid>
</repository>
<wc-info>
<wcroot-abspath>C:/development/svn_example/svn18_example</wcroot-abspath>
<schedule>delete</schedule>
<depth>infinity</depth>
<checksum>da39a3ee5e6b4b0d3255bfef95601890afd80709</checksum>
</wc-info>
<commit
revision="6">
<author>ptt</author>
<date>2013-07-13T15:35:57.796875Z</date>
</commit>
</entry>
<entry
kind="dir"
path="svn18_example\folder"
revision="6">
<url>file:///C:/development/svn_example/repos/svn18/main/folder</url>
<relative-url>^/folder</relative-url>
<repository>
<root>file:///C:/development/svn_example/repos/svn18/main</root>
<uuid>3c5e3929-c92b-7045-9ba9-5e65d3dd1ee9</uuid>
</repository>
<wc-info>
<wcroot-abspath>C:/development/svn_example/svn18_example</wcroot-abspath>
<schedule>normal</schedule>
<depth>infinity</depth>
</wc-info>
<commit
revision="5">
<author>ptt</author>
<date>2013-07-13T15:35:56.750000Z</date>
</commit>
</entry>
<entry
path="svn18_example\folder\quest.txt"
revision="6"
kind="file">
<url>file:///C:/development/svn_example/repos/svn18/main/folder/quest.txt</url>
<relative-url>^/folder/quest.txt</relative-url>
<repository>
<root>file:///C:/development/svn_example/repos/svn18/main</root>
<uuid>3c5e3929-c92b-7045-9ba9-5e65d3dd1ee9</uuid>
</repository>
<wc-info>
<wcroot-abspath>C:/development/svn_example/svn18_example</wcroot-abspath>
<schedule>normal</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:35:54.484375Z</text-updated>
<checksum>bc80eba9e7a10c0a571a4678c520bc9683f3bac2</checksum>
</wc-info>
<commit
revision="2">
<author>ptt</author>
<date>2013-07-13T15:35:54.843750Z</date>
</commit>
</entry>
<entry
path="svn18_example\folder\lalala.txt"
revision="6"
kind="file">
<url>file:///C:/development/svn_example/repos/svn18/main/folder/lalala.txt</url>
<relative-url>^/folder/lalala.txt</relative-url>
<repository>
<root>file:///C:/development/svn_example/repos/svn18/main</root>
<uuid>3c5e3929-c92b-7045-9ba9-5e65d3dd1ee9</uuid>
</repository>
<wc-info>
<wcroot-abspath>C:/development/svn_example/svn18_example</wcroot-abspath>
<schedule>normal</schedule>
<depth>infinity</depth>
<text-updated>2013-07-13T15:35:54.015625Z</text-updated>
<checksum>da39a3ee5e6b4b0d3255bfef95601890afd80709</checksum>
</wc-info>
<commit
revision="1">
<author>ptt</author>
<date>2013-07-13T15:35:54.375000Z</date>
</commit>
</entry>
</info>
import os import os
import sys
import tempfile import tempfile
import shutil import shutil
import unittest import unittest
import pkg_resources import pkg_resources
from setuptools.command import egg_info from setuptools.command import egg_info
from setuptools import svn_utils
ENTRIES_V10 = pkg_resources.resource_string(__name__, 'entries-v10') ENTRIES_V10 = pkg_resources.resource_string(__name__, 'entries-v10')
"An entries file generated with svn 1.6.17 against the legacy Setuptools repo" "An entries file generated with svn 1.6.17 against the legacy Setuptools repo"
...@@ -31,6 +33,17 @@ class TestEggInfo(unittest.TestCase): ...@@ -31,6 +33,17 @@ class TestEggInfo(unittest.TestCase):
def test_version_10_format(self): def test_version_10_format(self):
""" """
""" """
#keeping this set for 1.6 is a good check on the get_svn_revision
#to ensure I return using svnversion what would had been returned
version_str = svn_utils.SvnInfo.get_svn_version()
version = [int(x) for x in version_str.split('.')[:2]]
if version != [1,6]:
if hasattr(self, 'skipTest'):
self.skipTest('')
else:
sys.stderr.write('\n Skipping due to SVN Version\n')
return
self._write_entries(ENTRIES_V10) self._write_entries(ENTRIES_V10)
rev = egg_info.egg_info.get_svn_revision() rev = egg_info.egg_info.get_svn_revision()
self.assertEqual(rev, '89000') self.assertEqual(rev, '89000')
......
...@@ -8,12 +8,14 @@ import sys ...@@ -8,12 +8,14 @@ import sys
import tempfile import tempfile
import unittest import unittest
import unicodedata import unicodedata
from setuptools.tests import environment
from setuptools.compat import StringIO, unicode from setuptools.compat import StringIO, unicode
from setuptools.command.sdist import sdist from setuptools.command.sdist import sdist, walk_revctrl
from setuptools.command.egg_info import manifest_maker from setuptools.command.egg_info import manifest_maker
from setuptools.dist import Distribution from setuptools.dist import Distribution
from setuptools import svn_utils
from setuptools.svn_utils import fsencode
SETUP_ATTRS = { SETUP_ATTRS = {
'name': 'sdist_test', 'name': 'sdist_test',
...@@ -395,6 +397,64 @@ class TestSdistTest(unittest.TestCase): ...@@ -395,6 +397,64 @@ class TestSdistTest(unittest.TestCase):
self.assertTrue(filename in cmd.filelist.files) self.assertTrue(filename in cmd.filelist.files)
class TestSvn(environment.ZippedEnvironment):
def setUp(self):
version = svn_utils.SvnInfo.get_svn_version()
self.base_version = tuple([int(x) for x in version.split('.')][:2])
if not self.base_version:
raise ValueError('No SVN tools installed')
elif self.base_version < (1,3):
raise ValueError('Insufficient SVN Version %s' % version)
elif self.base_version >= (1,9):
#trying the latest version
self.base_version = (1,8)
self.dataname = "svn%i%i_example" % self.base_version
self.datafile = os.path.join('setuptools', 'tests',
'svn_data', self.dataname + ".zip")
super(TestSvn, self).setUp()
def test_walksvn(self):
if self.base_version >= (1,6):
folder2 = 'third party2'
folder3 = 'third party3'
else:
folder2 = 'third_party2'
folder3 = 'third_party3'
#TODO is this right
expected = set([
os.path.join('a file'),
os.path.join(folder2, 'Changes.txt'),
os.path.join(folder2, 'MD5SUMS'),
os.path.join(folder2, 'README.txt'),
os.path.join(folder3, 'Changes.txt'),
os.path.join(folder3, 'MD5SUMS'),
os.path.join(folder3, 'README.txt'),
os.path.join(folder3, 'TODO.txt'),
os.path.join(folder3, 'fin'),
os.path.join('third_party', 'README.txt'),
os.path.join('folder', folder2, 'Changes.txt'),
os.path.join('folder', folder2, 'MD5SUMS'),
os.path.join('folder', folder2, 'WatashiNiYomimasu.txt'),
os.path.join( 'folder', folder3, 'Changes.txt'),
os.path.join('folder', folder3, 'fin'),
os.path.join('folder', folder3, 'MD5SUMS'),
os.path.join('folder', folder3, 'oops'),
os.path.join('folder', folder3, 'WatashiNiYomimasu.txt'),
os.path.join('folder', folder3, 'ZuMachen.txt'),
os.path.join('folder', 'third_party', 'WatashiNiYomimasu.txt'),
os.path.join('folder', 'lalala.txt'),
os.path.join('folder', 'quest.txt'),
#The example will have a deleted file (or should) but shouldn't return it
])
expected = set(fsencode(x) for x in expected)
self.assertEqual(set(x for x in walk_revctrl()), expected)
def test_suite(): def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__) return unittest.defaultTestLoader.loadTestsFromName(__name__)
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment