2012/8/7 Matt Harbison <span dir="ltr"><<a href="mailto:matt_harbison@yahoo.com" target="_blank">matt_harbison@yahoo.com</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
# HG changeset patch<br>
# User Matt Harbison <<a href="mailto:matt_harbison@yahoo.com">matt_harbison@yahoo.com</a>><br>
# Date 1343696201 14400<br>
# Node ID 542cfb521b1297a887410173f5971afc537f2fb3<br>
# Parent  b131e24e2984a610d77e124dd3f58b2b5eda6d1a<br>
largefiles: handle commit -A properly, after a --large commit (issue3542)<br>
<br>
Previous to this, 'commit -A' would add as normal files, files that were already<br>
committed as largefiles, resulting in files being listed twice by 'status -A'.<br>
It also missed when (only) a largefile was deleted, even though status reported<br>
it as '!'.  This also has the side effect of properly reporting the state of the<br>
affected largefiles in the post commit hook after a remove that also affected a<br>
normal file (the largefiles used to be 'R', now are properly absent).<br>
<br>
Since scmutil.addremove() is called both by the ui command (after some trivial<br>
argument validation) and during the commit process when -A is specified, it<br>
seems like a more appropriate method to wrap than the addremove command.<br>
<br>
Currently, a repo is only enabled to use largefiles after an add that explicitly<br>
identifies some file as large, and a subsequent commit.  Therefore, this patch<br>
only changes behavior after such a largefile enabling commit.<br>
<br>
Note that in the test, if the final commit had a '-v', 'removing large8' would<br>
be printed twice.  Both of these originate in removelargefiles().  The first<br>
print is in verbose mode after traversing remove + forget, the second is because<br>
the '_isaddremove' attr is set and 'after' is not.<br>
<br>
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py<br>
--- a/hgext/largefiles/overrides.py<br>
+++ b/hgext/largefiles/overrides.py<br>
@@ -994,11 +994,12 @@<br>
         else:<br>
             ui.status(_('largefiles: %d to upload\n') % len(toupload))<br>
<br>
-def overrideaddremove(orig, ui, repo, *pats, **opts):<br>
+def scmutiladdremove(orig, repo, pats=[], opts={}, dry_run=None,<br>
+                     similarity=None):<br>
     if not lfutil.islfilesrepo(repo):<br>
-        return orig(ui, repo, *pats, **opts)<br>
+        return orig(repo, pats, opts, dry_run, similarity)<br>
     # Get the list of missing largefiles so we can remove them<br>
-    lfdirstate = lfutil.openlfdirstate(ui, repo)<br>
+    lfdirstate = lfutil.openlfdirstate(repo.ui, repo)<br>
     s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [], False,<br>
         False, False)<br>
     (unsure, modified, added, removed, missing, unknown, ignored, clean) = s<br>
@@ -1010,16 +1011,16 @@<br>
     if missing:<br>
         m = [repo.wjoin(f) for f in missing]<br>
         repo._isaddremove = True<br>
-        removelargefiles(ui, repo, *m, **opts)<br>
+        removelargefiles(repo.ui, repo, *m, **opts)<br>
         repo._isaddremove = False<br>
     # Call into the normal add code, and any files that *should* be added as<br>
     # largefiles will be<br>
-    addlargefiles(ui, repo, *pats, **opts)<br>
+    addlargefiles(repo.ui, repo, *pats, **opts)<br>
     # Now that we've handled largefiles, hand off to the original addremove<br>
     # function to take care of the rest.  Make sure it doesn't do anything with<br>
     # largefiles by installing a matcher that will ignore them.<br>
     installnormalfilesmatchfn(repo[None].manifest())<br>
-    result = orig(ui, repo, *pats, **opts)<br>
+    result = orig(repo, pats, opts, dry_run, similarity)<br>
     restorematchfn()<br>
     return result<br>
<br>
diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py<br>
--- a/hgext/largefiles/uisetup.py<br>
+++ b/hgext/largefiles/uisetup.py<br>
@@ -9,7 +9,7 @@<br>
 '''setup for largefiles extension: uisetup'''<br>
<br>
 from mercurial import archival, cmdutil, commands, extensions, filemerge, hg, \<br>
-    httppeer, localrepo, merge, sshpeer, sshserver, wireproto<br>
+    httppeer, localrepo, merge, scmutil, sshpeer, sshserver, wireproto<br>
 from mercurial.i18n import _<br>
 from mercurial.hgweb import hgweb_mod, protocol, webcommands<br>
 from mercurial.subrepo import hgsubrepo<br>
@@ -30,8 +30,10 @@<br>
                                    '(default: 10)'))]<br>
     entry[1].extend(addopt)<br>
<br>
-    entry = extensions.wrapcommand(commands.table, 'addremove',<br>
-            overrides.overrideaddremove)<br>
+    # The scmutil function is called both by the (trivial) addremove command,<br>
+    # and in the process of handling commit -A (issue3542)<br>
+    entry = extensions.wrapfunction(scmutil, 'addremove',<br>
+                                    overrides.scmutiladdremove)<br>
     entry = extensions.wrapcommand(commands.table, 'remove',<br>
                                    overrides.overrideremove)<br>
     entry = extensions.wrapcommand(commands.table, 'forget',<br>
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t<br>
--- a/tests/test-largefiles.t<br>
+++ b/tests/test-largefiles.t<br>
@@ -525,6 +525,33 @@<br>
   C sub2/large6<br>
   C sub2/large7<br>
<br>
+Test commit -A (issue 3542)<br>
+  $ echo large8 > large8<br>
+  $ hg add --large large8<br>
+  $ hg ci -Am 'this used to add large8 as normal and commit both'<br>
+  Invoking status precommit hook<br>
+  A large8<br>
+  Invoking status postcommit hook<br>
+  C large8<br>
+  C normal<br>
+  C normal3<br>
+  C sub/large4<br>
+  C sub/normal4<br>
+  C sub2/large6<br>
+  C sub2/large7<br>
+  $ rm large8<br>
+  $ hg ci -Am 'this used to not notice the rm'<br>
+  removing large8<br>
+  Invoking status precommit hook<br>
+  R large8<br>
+  Invoking status postcommit hook<br>
+  C normal<br>
+  C normal3<br>
+  C sub/large4<br>
+  C sub/normal4<br>
+  C sub2/large6<br>
+  C sub2/large7<br>
+<br>
 Test that a standin can't be added as a large file<br>
<br>
   $ touch large<br>
@@ -570,8 +597,19 @@<br>
   date:        Thu Jan 01 00:00:00 1970 +0000<br>
   summary:     removed large<br>
<br>
+  changeset:   13:0a3e75774479<br>
+  user:        test<br>
+  date:        Thu Jan 01 00:00:00 1970 +0000<br>
+  summary:     this used to add large8 as normal and commit both<br>
+<br>
+  changeset:   14:84f3d378175c<br>
+  user:        test<br>
+  date:        Thu Jan 01 00:00:00 1970 +0000<br>
+  summary:     this used to not notice the rm<br>
+<br>
   searching for changes<br>
   largefiles to upload:<br>
+  large8<br>
   large<br>
   foo<br></blockquote><div><br>I think this patch looks good. <br></div></div><br>-- <br><div><div><span style="color:rgb(153,153,153)"><b>Na'Tosha Bard</b></span></div><div><font color="#999999">Software Developer | Unity Technologies - Copenhagen<br>
</font></div><div><font color="#999999"><br></font></div><div><font color="#999999"><b>E-Mail:</b> <a href="mailto:natosha@unity3d.com" target="_blank">natosha@unity3d.com</a></font></div><div><font color="#999999"><b>Skype:</b> natosha.bard</font></div>
</div><br>