Mercurial > public > mercurial-scm > hg
diff mercurial/util.py @ 1415:c6e6ca96a033
refactor some unlink/remove code and make sure we prune empty dir
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Wed, 19 Oct 2005 00:10:52 -0700 |
parents | 1c64c628d15f |
children | b32b3509c7ab |
line wrap: on
line diff
--- a/mercurial/util.py Wed Oct 19 00:05:08 2005 -0700 +++ b/mercurial/util.py Wed Oct 19 00:10:52 2005 -0700 @@ -310,6 +310,13 @@ os.unlink(dst) os.rename(src, dst) +def unlink(f): + """unlink and remove the directory if it is empty""" + os.unlink(f) + # try removing directories that might now be empty + try: os.removedirs(os.path.dirname(f)) + except: pass + def copyfiles(src, dst, hardlink=None): """Copy a directory tree using hardlinks if possible"""