# HG changeset patch # User Martin von Zweigbergk # Date 2015-03-24 06:04:51 # Node ID 5b85a5bc5bbb9d8365953609d98e4dce7110e9b0 # Parent 2703eb73a3af7ef93c08b458ef38eee39f0b90ba revert: evaluate filesets against working directory (issue4497) As the failing revert tests in test-fileset-generated.t show, Revert currently creates one matcher for matching files in the working copy and another matcher for matching files in the target revision. The two matchers are created with different contexts, which means filesets are evaluated differently. Then the union of the sets of files matching the matchers in the two contexts are reverted. It doesn't seem to make sense to use two different matchers; only the context they're applied to should be different. It seems very likely that the user wants the filesets to be evaluated against the working directory, which the tests test-fileset-generated.t also assume, so let's make it so. I willingly admit that the largefiles code was modified by trial and error (according to tests). diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -765,7 +765,7 @@ def overriderevert(orig, ui, repo, ctx, def tostandin(f): standin = lfutil.standin(f) - if standin in mctx: + if standin in ctx or standin in mctx: return standin elif standin in repo[None] or lfdirstate[f] == 'r': return None @@ -777,7 +777,7 @@ def overriderevert(orig, ui, repo, ctx, def matchfn(f): if lfutil.isstandin(f): return (origmatchfn(lfutil.splitstandin(f)) and - (f in repo[None] or f in mctx)) + (f in ctx or f in mctx)) return origmatchfn(f) m.matchfn = matchfn return m diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2828,7 +2828,6 @@ def revert(ui, repo, ctx, parents, *pats return ui.warn("%s: %s\n" % (m.rel(path), msg)) - m = scmutil.match(ctx, pats, opts) m.bad = badfn for abs in ctx.walk(m): if abs not in names: diff --git a/tests/test-fileset-generated.t b/tests/test-fileset-generated.t --- a/tests/test-fileset-generated.t +++ b/tests/test-fileset-generated.t @@ -141,39 +141,34 @@ Test log Test revert -BROKEN: the files that get undeleted were not modified, they were removed, -and content1_content2_missing-tracked was also not modified, it was deleted - $ hg revert 'set:modified()' reverting content1_content1_content3-tracked reverting content1_content2_content1-tracked - undeleting content1_content2_content1-untracked - undeleting content1_content2_content2-untracked reverting content1_content2_content3-tracked - undeleting content1_content2_content3-untracked - reverting content1_content2_missing-tracked - undeleting content1_content2_missing-untracked reverting missing_content2_content3-tracked -BROKEN: only the files that get forgotten are correct - $ hg revert 'set:added()' forgetting content1_missing_content1-tracked forgetting content1_missing_content3-tracked - undeleting missing_content2_content2-untracked - undeleting missing_content2_content3-untracked - reverting missing_content2_missing-tracked - undeleting missing_content2_missing-untracked forgetting missing_missing_content3-tracked $ hg revert 'set:removed()' undeleting content1_content1_content1-untracked undeleting content1_content1_content3-untracked undeleting content1_content1_missing-untracked + undeleting content1_content2_content1-untracked + undeleting content1_content2_content2-untracked + undeleting content1_content2_content3-untracked + undeleting content1_content2_missing-untracked + undeleting missing_content2_content2-untracked + undeleting missing_content2_content3-untracked + undeleting missing_content2_missing-untracked $ hg revert 'set:deleted()' reverting content1_content1_missing-tracked + reverting content1_content2_missing-tracked forgetting content1_missing_missing-tracked + reverting missing_content2_missing-tracked forgetting missing_missing_missing-tracked $ hg revert 'set:unknown()'