aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Thiem <ptthiem@gmail.com>2013-07-04 13:10:35 -0500
committerPhilip Thiem <ptthiem@gmail.com>2013-07-04 13:10:35 -0500
commitadb810246108bfe67f4ac92ab0f644d250cce515 (patch)
treec1b3425a347d7e718db5c946e13932df4049b720
parentf553edb0df7c17b81457820e9333adc56b04d8b9 (diff)
downloadexternal_python_setuptools-adb810246108bfe67f4ac92ab0f644d250cce515.tar.gz
external_python_setuptools-adb810246108bfe67f4ac92ab0f644d250cce515.tar.bz2
external_python_setuptools-adb810246108bfe67f4ac92ab0f644d250cce515.zip
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
-rwxr-xr-xsetuptools/command/sdist.py16
-rw-r--r--setuptools/svn_utils.py46
-rw-r--r--setuptools/tests/test_svn.py13
3 files changed, 37 insertions, 38 deletions
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py
index 081d3c98..5cc2139b 100755
--- a/setuptools/command/sdist.py
+++ b/setuptools/command/sdist.py
@@ -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),
]
diff --git a/setuptools/svn_utils.py b/setuptools/svn_utils.py
index 0f54ba54..350f17c8 100644
--- a/setuptools/svn_utils.py
+++ b/setuptools/svn_utils.py
@@ -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])
@@ -60,7 +74,7 @@ def parse_revision(path):
def parse_dir_entries(path):
code, data = _run_command(['svn', 'info',
- '--depth', 'immediates', '--xml', path])
+ '--depth', 'immediates', '--xml', path])
if code:
log.warn("svn info failed")
@@ -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)
@@ -78,26 +92,17 @@ def parse_dir_entries(path):
_get_entry_name(element)
for element in entries[1:]
if _get_entry_schedule(element).lower() != 'deleted'
- ]
+ ]
else:
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):
try:
code, lines = _run_command(['svn',
- 'propget', 'svn:externals', path])
+ 'propget', 'svn:externals', path])
if code:
log.warn("svn propget failed")
@@ -127,4 +132,3 @@ def get_svn_tool_version():
return data.strip()
else:
return ''
-
diff --git a/setuptools/tests/test_svn.py b/setuptools/tests/test_svn.py
index 6f8399dd..7f5f6108 100644
--- a/setuptools/tests/test_svn.py
+++ b/setuptools/tests/test_svn.py
@@ -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():