# HG changeset patch # User mpm@selenic.com # Date 1120347496 28800 # Node ID e33c85d2812a5f6cfdff9caed9ef6c7c72b88499 # Parent 5291a16324c07b6803a5b92a5497fe3f59c85913 Remove empty directories on update -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Remove empty directories on update manifest hash: 113969ec14c75eb9e1013b23cf096f722932b84d -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCxyVoywK+sNU5EO8RAklKAKCzSUhuFClkHN85qlnDp5iVscZbtgCeJVwx dqaqG20GjPMWBg0d1ggI/ro= =o2Uv -----END PGP SIGNATURE----- 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