diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -1255,6 +1255,9 @@ class localrepository: for f in remove: self.ui.note("removing %s\n" % f) os.unlink(f) + # try removing directories that might now be empty + try: os.removedirs(os.path.dirname(f)) + except: pass if mode == 'n': self.dirstate.forget(remove) else: diff --git a/tests/test-empty-dir b/tests/test-empty-dir new file mode 100755 --- /dev/null +++ b/tests/test-empty-dir @@ -0,0 +1,16 @@ +#!/bin/sh + +hg init +echo 123 > a +hg add a +hg commit -t "first" -u test -d "0 0" a +mkdir sub +echo 321 > sub/b +hg add sub/b +hg commit -t "second" -u test -d "0 0" sub/b +cat sub/b +hg co 0 +cat sub/b +ls sub + +true diff --git a/tests/test-empty-dir.out b/tests/test-empty-dir.out new file mode 100644 --- /dev/null +++ b/tests/test-empty-dir.out @@ -0,0 +1,3 @@ +321 +cat: sub/b: No such file or directory +ls: sub: No such file or directory