Patchwork [STABLE] largefiles: don't actually remove largefiles in an addremove dry run

login
register
mail settings
Submitter Matt Harbison
Date Dec. 13, 2014, 7:08 p.m.
Message ID <96d335e4eacbe19212d0.1418497725@Envy>
Download mbox | patch
Permalink /patch/7077/
State Accepted
Delegated to: Pierre-Yves David
Headers show

Comments

Matt Harbison - Dec. 13, 2014, 7:08 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1418495628 18000
#      Sat Dec 13 13:33:48 2014 -0500
# Branch stable
# Node ID 96d335e4eacbe19212d018cbeea370a614c30a33
# Parent  424d669118d323ca1aeb309f2a8a4631f69d1fe3
largefiles: don't actually remove largefiles in an addremove dry run

The addlargefiles() method already properly handled dry runs.
Pierre-Yves David - Dec. 14, 2014, 9:21 p.m.
On 12/13/2014 11:08 AM, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1418495628 18000
> #      Sat Dec 13 13:33:48 2014 -0500
> # Branch stable
> # Node ID 96d335e4eacbe19212d018cbeea370a614c30a33
> # Parent  424d669118d323ca1aeb309f2a8a4631f69d1fe3
> largefiles: don't actually remove largefiles in an addremove dry run
>
> The addlargefiles() method already properly handled dry runs.

<chuckle>

Pushed to the clowncopter, thanks.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -189,8 +189,15 @@ 
                 # are removing the file.
                 if isaddremove:
                     ui.status(_('removing %s\n') % f)
-                util.unlinkpath(repo.wjoin(f), ignoremissing=True)
-            lfdirstate.remove(f)
+
+            if not opts.get('dry_run'):
+                if not after:
+                    util.unlinkpath(repo.wjoin(f), ignoremissing=True)
+                lfdirstate.remove(f)
+
+        if opts.get('dry_run'):
+            return result
+
         lfdirstate.write()
         remove = [lfutil.standin(f) for f in remove]
         # If this is being called by addremove, let the original addremove
diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t
--- a/tests/test-largefiles-misc.t
+++ b/tests/test-largefiles-misc.t
@@ -250,6 +250,16 @@ 
 Add a normal file to the subrepo, then test archiving
 
   $ echo 'normal file' > subrepo/normal.txt
+  $ mv subrepo/large.txt subrepo/renamed-large.txt
+  $ hg -R subrepo addremove --dry-run
+  removing large.txt
+  adding normal.txt
+  adding renamed-large.txt
+  $ hg status -S
+  ! subrepo/large.txt
+  ? subrepo/normal.txt
+  ? subrepo/renamed-large.txt
+  $ mv subrepo/renamed-large.txt subrepo/large.txt
   $ hg -R subrepo add subrepo/normal.txt
 
 Lock in subrepo, otherwise the change isn't archived