dirstate: drop explicit files that shouldn't match (BC) (
issue4679)
Before, wctx.walk() could include files excluded by -X pattern, which
disagrees with wctx.matches() and ctx.walk()/matches() behavior. This patch
fixes the problem by testing stat results against the matcher if the matcher
may contain false paths.
I have no idea if the fix should be made before the workaround for case-
insensitive filesystems, but that shouldn't matter since match.anypats()
means 'not match.isexact()'.
This patch also makes narrow and sparse extensions to not exclude explicit
paths on walk() because they appear to depend on the buggy behavior.
More detailed analysis about this issue by Martin von Zweigbergk:
"I think it's just an unintended consequence of how the dirstate walk works,
but I'm not sure. The exception for explicit files also bothered me when I
was working on the matcher code a year or so ago. I actually added the
exception to the matcher code because I thought it was always working like
that (not just for dirstate) in
a83a7d27911e (match: handle excludes using
new differencematcher, 2017-05-16). It was only recently that Yuya realized
that it used to be inconsistent and that I probably made it consistently bad
because I didn't realize it was inconsistent to start with, see
821d8a5ab4ff
(match: do not weirdly include explicit files excluded by -X option,
2018-01-16)."
.. bc::
Working-directory commands now respect ``-X PATTERN`` no matter if PATTERN
matches explicitly-specified FILEs. For example, ``hg add foo -X foo`` no
longer add the file ``foo``.
hgweb: show users recorded in obsolescence markers
It's useful to see who obsoleted a commit, because it's not always done by its
author (hg-committed is a good example, because people rebase stacks of commits
made by various people).
Usernames are obfuscated, but look correct (e.g. "test" is
"test").
revert: use an exact matcher in interactive diff selection (
issue5789)
When going through _performrevert() in the interactive case, we build a
matcher with files to revert and pass it patch.diff() for later
selection of diff hunks to revert. The files set used to build the
matcher comes from dirstate and accounts for patterns explicitly passed
to revert ('hg revert -i <file>') and, in case of nonexistent pattern,
this set is empty (which is expected). Unfortunately, the matcher built
from scmutil.match(ctx, []) is wrong as it leads patch.diff() to rebuild
a 'changes' tuple with dirstate information, ignoring user-specified
pattern. This leads to the situation described in
issue5789, where
one gets prompted about reverting files unrelated to specified patterns
because they made a typo or so.
We fix this by building an exact matcher with the correct set of file
paths (built earlier). Thanks to Yuya Nishihara for suggesting the
correct fix.
tests: add a test demonstrate that 'revert -i' ignores nonexistent patterns
As described in
issue5789, when revert is called through:
hg revert -i <some file that does not exist>
we'd expect the command to abort early. Currently, it just warns about
missing file but prompt about files unrelated to user arguments.
py3: slice over bytes to prevent getting ascii values
Differential Revision: https://phab.mercurial-scm.org/D2271
py3: converts bytes to pycompat.bytestr to get bytechrs while enumerating
Differential Revision: https://phab.mercurial-scm.org/D2270
py3: use pycompat.{bytes|str}kwargs in transplant.py
Differential Revision: https://phab.mercurial-scm.org/D2268
py3: replace file() with open() in transplant.py
Differential Revision: https://phab.mercurial-scm.org/D2267