Commit adb81024 authored by Philip Thiem's avatar Philip Thiem

consolidated externals and enteries because enteries need to file to

interate over and both get called by the same callback.
pep8 on svn_utils

--HG--
extra : rebase_source : fa65ebfc167041b5c2e1b2bd901e9354cfaea57e
parent f553edb0
......@@ -60,23 +60,21 @@ def _default_revctrl(dirname=''):
for item in _default_revctrl(path):
yield item
def externals_finder(dirname, filename):
"""Find any 'svn:externals' directories"""
for name in svn_utils.parse_externals(dirname):
yield joinpath(dirname, name)
def entries_finder(dirname, filename):
def entries_externals_finder(dirname, filename):
for record in svn_utils.parse_dir_entries(dirname):
yield joinpath(dirname, record)
for name in svn_utils.parse_externals(dirname):
yield joinpath(dirname, name)
finders = [
(convert_path('CVS/Entries'),
re_finder(re.compile(r"^\w?/([^/]+)/", re.M))),
(convert_path('.svn/entries'), entries_finder),
(convert_path('.svn/dir-props'), externals_finder),
(convert_path('.svn/dir-prop-base'), externals_finder), # svn 1.4
#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),
]
......
......@@ -14,6 +14,15 @@ from subprocess import Popen as _Popen, PIPE as _PIPE
# and SVN 1.3 hsan't been supported by the
# developers since mid 2008.
#svnversion return values (previous implementations return max revision)
# 4123:4168 mixed revision working copy
# 4168M modified working copy
# 4123S switched working copy
# 4123:4168MS mixed revision, modified, switched working copy
_SVN_VER_RE = re.compile(r'(?:(\d+):)?(\d+)([a-z]*)\s*$', re.I)
#subprocess is called several times with shell=(sys.platform=='win32')
#see the follow for more information:
# http://bugs.python.org/issue8557
......@@ -22,7 +31,7 @@ from subprocess import Popen as _Popen, PIPE as _PIPE
def _run_command(args, stdout=_PIPE, stderr=_PIPE):
#regarding the shell argument, see: http://bugs.python.org/issue8557
proc = _Popen(args, stdout=stdout, stderr=stderr,
shell=(sys.platform=='win32'))
shell=(sys.platform == 'win32'))
data = proc.communicate()[0]
#TODO: this is probably NOT always utf-8
......@@ -33,12 +42,17 @@ def _run_command(args, stdout=_PIPE, stderr=_PIPE):
return proc.returncode, data
#svnversion return values (previous implementations return max revision)
# 4123:4168 mixed revision working copy
# 4168M modified working copy
# 4123S switched working copy
# 4123:4168MS mixed revision, modified, switched working copy
_SVN_VER_RE = re.compile(r'(?:(\d+):)?(\d+)([a-z]*)\s*$', re.I)
def _get_entry_name(entry):
return entry.getAttribute('path')
def _get_entry_schedule(entry):
schedule = entry.getElementsByTagName('schedule')[0]
return "".join([t.nodeValue
for t in schedule.childNodes
if t.nodeType == t.TEXT_NODE])
def parse_revision(path):
code, data = _run_command(['svnversion', path])
......@@ -69,7 +83,7 @@ def parse_dir_entries(path):
doc = xml.dom.pulldom.parseString(data)
entries = list()
for event, node in doc:
if event=='START_ELEMENT' and node.nodeName=='entry':
if event == 'START_ELEMENT' and node.nodeName == 'entry':
doc.expandNode(node)
entries.append(node)
......@@ -83,15 +97,6 @@ def parse_dir_entries(path):
return []
def _get_entry_name(entry):
return entry.getAttribute('path')
def _get_entry_schedule(entry):
schedule = entry.getElementsByTagName('schedule')[0]
return "".join([t.nodeValue for t in schedule.childNodes
if t.nodeType == t.TEXT_NODE])
#--xml wasn't supported until 1.5.x
#-R without --xml parses a bit funny
def parse_externals(path):
......@@ -127,4 +132,3 @@ def get_svn_tool_version():
return data.strip()
else:
return ''
......@@ -17,6 +17,7 @@ from setuptools.command import sdist
#requires python >= 2.4
from subprocess import call as _call
def _remove_dir(target):
#on windows this seems to a problem
......@@ -26,6 +27,7 @@ def _remove_dir(target):
os.chmod(os.path.join(dir_path, filename), stat.S_IWRITE)
shutil.rmtree(target)
class TestSvnVersion(unittest.TestCase):
def test_no_svn_found(self):
......@@ -68,21 +70,16 @@ class TestSvn_1_7(unittest.TestCase):
rev = egg_info.egg_info.get_svn_revision()
self.assertEqual(rev, '4')
def test_entry_iterator(self):
def test_iterator(self):
expected = set([
os.path.join('.', 'readme.txt'),
os.path.join('.', 'other'),
])
self.assertEqual(set(x for x in sdist.entries_finder('.', '')),
expected)
def test_external_iterator(self):
expected = set([
os.path.join('.', 'third_party'),
os.path.join('.', 'third_party2'),
os.path.join('.', 'third_party3'),
])
self.assertEqual(set(x for x in sdist.externals_finder('.', '')),
self.assertEqual(set(x for x
in sdist.entries_externals_finder('.', '')),
expected)
def test_suite():
......
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