[PATCH] largefiles: test and simplify empty directory removal in remove

Patrick Mezard pmezard at gmail.com
Thu Jan 19 03:12:24 CST 2012


# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1326964033 -3600
# Node ID 5f09a6cbcf182b2c0f60894514d64704a61a7d04
# Parent  3a51eb88046aaecb22cb7d3ee970670502dda783
largefiles: test and simplify empty directory removal in remove

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -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]
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -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


More information about the Mercurial-devel mailing list