hg grep: fix util.pathto parameter order in biggrep integration

Summary:
we were not producing the correct filter expression when
invoking biggrep, which resulted in incorrect (no!) output.

The `normpath` is needed because `util.pathto` can produce paths like `../../.`
which biggrep doesn't like.

Reviewed By: quark-zju

Differential Revision: D17950451

fbshipit-source-id: 6c29c32b6b4b293fbec820fd76dea51adbefca4e
This commit is contained in:
Wez Furlong 2019-10-18 04:30:23 -07:00 committed by Facebook Github Bot
parent ea7dff0318
commit b1f52df121

View File

@ -2736,7 +2736,10 @@ def grep(ui, repo, pattern, *pats, **opts):
m = scmutil.match(wctx, ["."], match_opts)
# Scope biggrep to the cwd equivalent path, relative to the root
# of its corpus.
biggrepcmd += ["-f", util.pathto(repo.getcwd(), reporoot, ".")]
biggrepcmd += [
"-f",
os.path.normpath(util.pathto(reporoot, repo.getcwd(), ".")),
]
else:
# Search using the specified patterns
m = scmutil.match(wctx, pats, match_opts)
@ -2745,7 +2748,13 @@ def grep(ui, repo, pattern, *pats, **opts):
# so we cross fingers and hope that the patterns are simple filenames.
biggrepcmd += [
"-f",
"(%s)" % "|".join([util.pathto(repo.getcwd(), reporoot, f) for f in pats]),
"(%s)"
% "|".join(
[
os.path.normpath(util.pathto(reporoot, repo.getcwd(), f))
for f in pats
]
),
]
# Add '--' to make sure grep recognizes all remaining arguments