largefiles: remove directories emptied after their files are moved (issue3515) stable
authorMatt Harbison <matt_harbison@yahoo.com>
Fri, 25 Apr 2014 22:34:09 -0400
branchstable
changeset 21196 5c0d5b95b824
parent 21195 9336bc7dca8e
child 21197 cb4223c65f79
largefiles: remove directories emptied after their files are moved (issue3515)
hgext/largefiles/overrides.py
tests/test-largefiles.t
--- 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