largefiles: test and simplify empty directory removal in remove
authorPatrick Mezard <pmezard@gmail.com>
Thu, 19 Jan 2012 10:07:13 +0100
changeset 15930 2dc599583ebe
parent 15929 4091660dc130
child 15931 44b5de2d1876
largefiles: test and simplify empty directory removal in remove
hgext/largefiles/overrides.py
tests/test-largefiles.t
--- a/hgext/largefiles/overrides.py	Thu Jan 19 02:14:06 2012 +0100
+++ b/hgext/largefiles/overrides.py	Thu Jan 19 10:07:13 2012 +0100
@@ -159,11 +159,7 @@
                 if getattr(repo, "_isaddremove", False):
                     ui.status(_('removing %s\n' % f))
                 if os.path.exists(repo.wjoin(f)):
-                    os.unlink(repo.wjoin(f))
-                currentdir = os.path.split(f)[0]
-                while currentdir and not os.listdir(repo.wjoin(currentdir)):
-                    os.rmdir(repo.wjoin(currentdir))
-                    currentdir = os.path.split(currentdir)[0]
+                    util.unlinkpath(repo.wjoin(f))
             lfdirstate.remove(f)
         lfdirstate.write()
         forget = [lfutil.standin(f) for f in forget]
--- a/tests/test-largefiles.t	Thu Jan 19 02:14:06 2012 +0100
+++ b/tests/test-largefiles.t	Thu Jan 19 10:07:13 2012 +0100
@@ -556,6 +556,14 @@
   [1]
   $ hg update -q
 
+Test hg remove removes empty largefiles directories
+  $ test -d sub2 && echo "sub2 exists"
+  sub2 exists
+  $ hg remove sub2/*
+  $ test -d sub2 && echo "error: sub2 should not exist anymore"
+  [1]
+  $ hg revert sub2/large6 sub2/large7
+
 "revert" works on largefiles (and normal files too).
   $ echo hack3 >> normal3
   $ echo hack4 >> sub/normal4