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.
This commit is contained in:
Matt Harbison 2015-02-07 19:40:02 -05:00
parent ff672a242a
commit d3f2dde965
2 changed files with 16 additions and 1 deletions

View File

@ -716,10 +716,17 @@ def overriderevert(orig, ui, repo, *pats, **opts):
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]

View File

@ -362,6 +362,14 @@ Test update with subrepos.
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