largefiles: don't warn when reverting a forgotten largefile
authorMatt Harbison <matt_harbison@yahoo.com>
Sat, 07 Feb 2015 19:40:02 -0500
changeset 24133 79c2c29c71ae
parent 24132 b5898bf7119a
child 24134 afed5d2e7985
largefiles: don't warn when reverting a forgotten largefile Previously, when a largefile is forgotten and then reverted, a warning was issued: $ 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 exactly. Since core revert recurses into subrepos and largefiles only overrides the revert method in commands.py, 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 problems.
hgext/largefiles/overrides.py
tests/test-largefiles-misc.t
--- a/hgext/largefiles/overrides.py	Fri Feb 06 20:39:20 2015 -0500
+++ b/hgext/largefiles/overrides.py	Sat Feb 07 19:40:02 2015 -0500
@@ -716,10 +716,17 @@
                 default='relpath'):
             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]
--- a/tests/test-largefiles-misc.t	Fri Feb 06 20:39:20 2015 -0500
+++ b/tests/test-largefiles-misc.t	Sat Feb 07 19:40:02 2015 -0500
@@ -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