[PATCH 1 of 2 STABLE] largefiles: fix status -S reporting of subrepos (issue3231)

Matt Harbison matt_harbison at yahoo.com
Mon Apr 23 00:18:37 CDT 2012


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1335080854 14400
# Branch stable
# Node ID cdf25679473c6f3cfc4fb560012dc583fd0e3935
# Parent  cbf2ea2f5ca169d22e0729cb71a21b808574b90e
largefiles: fix status -S reporting of subrepos (issue3231)

Wrapping the status command will only invoke overridestatus() and set
the lfstatus field for the top level repository.  Wrapping the status
function is required to set the field on child repositories.

Previously, status -S would report large files in a subrepo as '?'
regardless of their actual states, and was inconsistent with what
status would report from within that subrepo.

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -202,6 +202,13 @@
     restorematchfn()
     removelargefiles(ui, repo, *pats, **opts)
 
+def overridestatusfn(orig, repo, rev2, **opts):
+    try:
+        repo._repo.lfstatus = True
+        return orig(repo, rev2, **opts)
+    finally:
+        repo._repo.lfstatus = False
+
 def overridestatus(orig, ui, repo, *pats, **opts):
     try:
         repo.lfstatus = True
diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -12,6 +12,7 @@
     httprepo, localrepo, merge, sshrepo, sshserver, wireproto
 from mercurial.i18n import _
 from mercurial.hgweb import hgweb_mod, protocol, webcommands
+from mercurial.subrepo import hgsubrepo
 
 import overrides
 import proto
@@ -35,8 +36,13 @@
                                    overrides.overrideremove)
     entry = extensions.wrapcommand(commands.table, 'forget',
                                    overrides.overrideforget)
+
+    # Subrepos call status function
     entry = extensions.wrapcommand(commands.table, 'status',
                                    overrides.overridestatus)
+    entry = extensions.wrapfunction(hgsubrepo, 'status',
+                                    overrides.overridestatusfn)
+
     entry = extensions.wrapcommand(commands.table, 'log',
                                    overrides.overridelog)
     entry = extensions.wrapcommand(commands.table, 'rollback',
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -1050,5 +1050,29 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     add files
   
-
+verify that large files in subrepos handled properly
+  $ hg init subrepo
+  $ echo "subrepo = subrepo" > .hgsub
+  $ hg add .hgsub
+  $ hg ci -m "add subrepo"
+  Invoking status precommit hook
+  A .hgsub
+  ? .hgsubstate
+  $ echo "rev 1" > subrepo/large.txt
+  $ hg -R subrepo add --large subrepo/large.txt
+  $ hg st
+  $ hg st -S
+  A subrepo/large.txt
+# This is a workaround for not noticing the subrepo is dirty
+  $ hg -R subrepo ci -m "commit large file"
+  Invoking status precommit hook
+  A large.txt
+  $ hg ci -S -m "commit top repo"
+  Invoking status precommit hook
+  M .hgsubstate
+  $ hg st -S
+  $ echo "rev 2" > subrepo/large.txt
+  $ hg st -S
+  M subrepo/large.txt
+ 
   $ cd ..


More information about the Mercurial-devel mailing list