changeset 578:e33c85d2812a

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-----
author mpm@selenic.com
date Sat, 02 Jul 2005 15:38:16 -0800
parents 5291a16324c0
children ffeb2c3a1966
files mercurial/hg.py tests/test-empty-dir tests/test-empty-dir.out
diffstat 3 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Sat Jul 02 15:34:23 2005 -0800
+++ b/mercurial/hg.py	Sat Jul 02 15:38:16 2005 -0800
@@ -1255,6 +1255,9 @@
         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:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-empty-dir	Sat Jul 02 15:38:16 2005 -0800
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-empty-dir.out	Sat Jul 02 15:38:16 2005 -0800
@@ -0,0 +1,3 @@
+321
+cat: sub/b: No such file or directory
+ls: sub: No such file or directory