[pypy-svn] buildbot default: Fix broken no-common-prefix detection.
victorgarcia
commits-noreply at bitbucket.org
Tue Jan 25 10:24:36 CET 2011
Author: victorgarcia <victorgarcianet at gmail.com>
Branch:
Changeset: r444:44d3257ce0a4
Date: 2011-01-25 06:41 -0200
http://bitbucket.org/pypy/buildbot/changeset/44d3257ce0a4/
Log: Fix broken no-common-prefix detection.
diff --git a/bitbucket_hook/hook.py b/bitbucket_hook/hook.py
--- a/bitbucket_hook/hook.py
+++ b/bitbucket_hook/hook.py
@@ -40,15 +40,16 @@
"""
def getpaths(files, listfiles=False):
+
+ # Handle empty input
if not files:
return '', ''
+ files = [f['file'] for f in files]
+ if not any(files):
+ return '', ''
dirname = os.path.dirname
basename = os.path.basename
- files = [f['file'] for f in files]
-
- if not any(files):
- return '', ''
common_prefix = [dirname(f) for f in files]
@@ -57,11 +58,9 @@
common_prefix = files[0]
listfiles = False
- elif not common_prefix or len(common_prefix) == len(set(common_prefix)):
- common_prefix = ''
-
else:
- common_prefix = os.path.commonprefix(common_prefix)
+ common_prefix = [path.split(os.sep) for path in common_prefix]
+ common_prefix = os.sep.join(os.path.commonprefix(common_prefix))
if common_prefix and not common_prefix.endswith('/'):
common_prefix += '/'
diff --git a/bitbucket_hook/test/test_hook.py b/bitbucket_hook/test/test_hook.py
--- a/bitbucket_hook/test/test_hook.py
+++ b/bitbucket_hook/test/test_hook.py
@@ -77,7 +77,13 @@
pypydoubleslash = [d(file='pypy/jit/metainterp/opt/u.py'),
d(file='pypy/jit/metainterp/test/test_c.py'),
d(file='pypy/jit/metainterp/test/test_o.py')]
+
+ pypyempty = [d(file='pypy/rlib/rdtoa.py'),
+ d(file='pypy/rlib/test/test_rdtoa.py')]
+
nothing = ('', '')
+
+ # (input, expected output) for listfiles=False
files_expected = [([], nothing),
([empty], nothing),
([empty, empty], nothing),
@@ -95,11 +101,13 @@
(nocommonplusslash, nothing),
(commonplusslash, ('path/', '')),
(pypydoubleslash, ('pypy/jit/metainterp/', '')),
+ (pypyempty, ('pypy/rlib/', '')),
]
for f, wanted in files_expected:
assert getpaths(f) == wanted
+ # (input, expected output) for listfiles=True
files_expected = [([], nothing),
([empty], nothing),
([empty, empty], nothing),
@@ -119,6 +127,8 @@
(commonplusslash, ('path/',' M(file1, file2, file)')),
(pypydoubleslash, ('pypy/jit/metainterp/',
' M(u.py, test_c.py, test_o.py)')),
+ (pypyempty, ('pypy/rlib/',
+ ' M(rdtoa.py, test_rdtoa.py)')),
]
for f, wanted in files_expected:
More information about the Pypy-commit
mailing list