Patchwork [STABLE,V2] largefiles: remove directories emptied after their files are moved (issue3515)

login
register
mail settings
Submitter Matt Harbison
Date April 29, 2014, 2:50 a.m.
Message ID <ede7d1160bbe5f4f29ba.1398739840@Envy>
Download mbox | patch
Permalink /patch/4453/
State Accepted
Commit 5c0d5b95b8249796a57ff2ff2db49b46f087624c
Headers show

Comments

Matt Harbison - April 29, 2014, 2:50 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1398479649 14400
#      Fri Apr 25 22:34:09 2014 -0400
# Branch stable
# Node ID ede7d1160bbe5f4f29bab5a4b76f328147bb3ac0
# Parent  d36440d843284ba546858b241da9cc4817811fe5
largefiles: remove directories emptied after their files are moved (issue3515)
Matt Mackall - April 29, 2014, 7:02 p.m.
On Mon, 2014-04-28 at 22:50 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1398479649 14400
> #      Fri Apr 25 22:34:09 2014 -0400
> # Branch stable
> # Node ID ede7d1160bbe5f4f29bab5a4b76f328147bb3ac0
> # Parent  d36440d843284ba546858b241da9cc4817811fe5
> largefiles: remove directories emptied after their files are moved (issue3515)

Queued for stable, thanks.

Patch

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