# HG changeset patch # User Patrick Mezard # Date 2009-10-08 21:32:36 # Node ID 1f665246dab3140a72954fbd089a784224898462 # Parent 989cb39d1df455cec0ec47ab6ccfcc4810bef9a4 windows: fix unlink() not dropping empty tree (issue1861) diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -258,7 +258,7 @@ def _removedirs(name): head, tail = os.path.split(head) while head and tail: try: - if osutil.listdir(name): + if osutil.listdir(head): return os.rmdir(head) except: diff --git a/tests/test-remove b/tests/test-remove --- a/tests/test-remove +++ b/tests/test-remove @@ -108,3 +108,12 @@ remove -A test echo % dir, options -Af rm test/bar remove -Af test + +echo 'test remove dropping empty trees (issue1861)' +mkdir -p issue1861/b/c +echo x > issue1861/x +echo y > issue1861/b/c/y +hg ci -Am add +hg rm issue1861/b +hg ci -m remove +ls issue1861 diff --git a/tests/test-remove.out b/tests/test-remove.out --- a/tests/test-remove.out +++ b/tests/test-remove.out @@ -111,3 +111,8 @@ R test/foo ./foo ./test/foo 2 files updated, 0 files merged, 0 files removed, 0 files unresolved +test remove dropping empty trees (issue1861) +adding issue1861/b/c/y +adding issue1861/x +removing issue1861/b/c/y +x