changeset 21196:5c0d5b95b824 stable

largefiles: remove directories emptied after their files are moved (issue3515)
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 25 Apr 2014 22:34:09 -0400
parents 9336bc7dca8e
children cb4223c65f79
files hgext/largefiles/overrides.py tests/test-largefiles.t
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Sat Apr 26 18:13:06 2014 +0900
+++ b/hgext/largefiles/overrides.py	Fri Apr 25 22:34:09 2014 -0400
@@ -579,6 +579,10 @@
                         os.makedirs(destlfiledir)
                     if rename:
                         os.rename(repo.wjoin(srclfile), repo.wjoin(destlfile))
+
+                        # The file is gone, but this deletes any empty parent
+                        # directories as a side-effect.
+                        util.unlinkpath(repo.wjoin(srclfile), True)
                         lfdirstate.remove(srclfile)
                     else:
                         util.copyfile(repo.wjoin(srclfile),
--- a/tests/test-largefiles.t	Sat Apr 26 18:13:06 2014 +0900
+++ b/tests/test-largefiles.t	Fri Apr 25 22:34:09 2014 -0400
@@ -214,8 +214,18 @@
   ./baz/largefile
   ./dirb
   ./dirb/largefile
-  ./foo
-  $ cd ../../a
+  $ cd ..
+  $ hg mv dira dirc
+  moving .hglf/dira/baz/largefile to .hglf/dirc/baz/largefile (glob)
+  moving .hglf/dira/dirb/largefile to .hglf/dirc/dirb/largefile (glob)
+  $ find * | sort
+  dirc
+  dirc/baz
+  dirc/baz/largefile
+  dirc/dirb
+  dirc/dirb/largefile
+  $ hg up -qC
+  $ cd ../a
 
 #if serve
 Test display of largefiles in hgweb