Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize the paths of all files, avoiding duplicate misses of directories #16

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ Changelog
0.15 (unreleased)
-----------------

* No changes yet.
* Normalize the paths of all files, avoiding some duplicate misses of
directories.
[maurits]


0.14 (2013-08-28)
Expand Down
17 changes: 10 additions & 7 deletions check_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class Bazaar(VCS):
def get_versioned_files():
"""List all files versioned in Bazaar in the current directory."""
output = run(['bzr', 'ls', '-VR'])
return strip_slashes(output.splitlines())
return output.splitlines()


class Subversion(VCS):
Expand Down Expand Up @@ -308,12 +308,15 @@ def detect_vcs():
def get_vcs_files():
"""List all files under version control in the current directory."""
vcs = detect_vcs()
return vcs.get_versioned_files()
return normalize_names(vcs.get_versioned_files())


def strip_slashes(names):
"""Svn/Bzr print directory names with trailing slashes. Strip them."""
return [name.rstrip('/') for name in names]
def normalize_names(names):
"""Some VCS print directory names with trailing slashes. Strip them.

Easiest is to normalize the path.
"""
return [os.path.normpath(name) for name in names]


def add_directories(names):
Expand Down Expand Up @@ -463,8 +466,8 @@ def check_manifest(source_tree='.', create=False, update=False,
run([python, 'setup.py', 'sdist', '-d', tempdir])
sdist_filename = get_one_file_in(tempdir)
info_continue(": %s" % os.path.basename(sdist_filename))
sdist_files = sorted(strip_sdist_extras(strip_toplevel_name(
get_archive_file_list(sdist_filename))))
sdist_files = sorted(normalize_names(strip_sdist_extras(
strip_toplevel_name(get_archive_file_list(sdist_filename)))))
info_continue(": %d files and directories" % len(sdist_files))
if source_files == sdist_files:
info("files in version control match files in the sdist")
Expand Down
8 changes: 4 additions & 4 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def test_strip_toplevel_name_no_common_prefix(self):
from check_manifest import strip_toplevel_name, Failure
self.assertRaises(Failure, strip_toplevel_name, ["a/b", "c/d"])

def test_strip_slashes(self):
from check_manifest import strip_slashes
self.assertEqual(strip_slashes(["a", "b/", "c/d", "e/f/"]),
["a", "b", "c/d", "e/f"])
def test_normalize_names(self):
from check_manifest import normalize_names
self.assertEqual(normalize_names(["a", "b/", "c/d", "e/f/", "g/h/../i"]),
["a", "b", "c/d", "e/f", "g/i"])

def test_add_directories(self):
from check_manifest import add_directories
Expand Down