Patchwork [2,of,4] largefiles: don't warn when reverting a forgotten largefile

mail settings
Submitter Matt Harbison
Date Feb. 15, 2015, 2:12 a.m.
Message ID <bf99019578c6f499968e.1423966357@Envy>
Download mbox | patch
Permalink /patch/7800/
State Accepted
Headers show


Matt Harbison - Feb. 15, 2015, 2:12 a.m.
# HG changeset patch
# User Matt Harbison <>
# Date 1423356002 18000
#      Sat Feb 07 19:40:02 2015 -0500
# Node ID bf99019578c6f499968e46b4eaeb2fc4cdd40790
# Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
largefiles: don't warn when reverting a forgotten largefile

Previously, when a largefile is forgotten and then reverted, a warning was

   $ hg revert -R subrepo subrepo/large.txt
   file not managed: subrepo/large.txt (glob)

This was purely cosmetic as the file itself actually was reverted.

The problem was even with all of the matcher patching, the largefile pattern
given on the command line wasn't converted to a standin because the standin was
neither in ctx nor wctx.  This causes the named largefile to be added to the
'names' dict in cmdutil.revert() in the repo walk at line 2550.  The warning was
printed out when the 'names' dict is iterated, because the file was specified

Since core revert recurses into subrepos and largefiles only overrides the
revert method in, it doesn't work properly when reverting a subrepo.
However, it still will recurse into the subrepo and call the installed matcher
method, so lfdirstate is reopened for the current repo level to prevent any new


diff --git a/hgext/largefiles/ b/hgext/largefiles/
--- a/hgext/largefiles/
+++ b/hgext/largefiles/
@@ -716,10 +716,17 @@ 
             match = oldmatch(ctx, pats, opts, globbed, default)
             m = copy.copy(match)
+            # revert supports recursing into subrepos, and though largefiles
+            # currently doesn't work correctly in that case, this match is
+            # called, so the lfdirstate above may not be the correct one for
+            # this invocation of match.
+            lfdirstate = lfutil.openlfdirstate(ctx._repo.ui, ctx._repo)
             def tostandin(f):
                 if lfutil.standin(f) in ctx:
                     return lfutil.standin(f)
-                elif lfutil.standin(f) in repo[None]:
+                elif lfutil.standin(f) in repo[None] or lfdirstate[f] == 'r':
                     return None
                 return f
             m._files = [tostandin(f) for f in m._files]
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
@@ -362,6 +362,14 @@ 
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg status -S
+  $ hg forget -v subrepo/large.txt
+  removing subrepo/large.txt (glob)
+Test reverting a forgotten file
+  $ hg revert -R subrepo subrepo/large.txt
+  $ hg status -SA subrepo/large.txt
+  C subrepo/large.txt
   $ hg rm -v subrepo/large.txt
   removing subrepo/large.txt (glob)
   $ hg revert -R subrepo subrepo/large.txt