diff -r 5c49a4fdb238 -r 02bf61bb4a70 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Wed May 06 11:41:01 2020 -0700 +++ b/mercurial/cmdutil.py Wed May 06 10:33:56 2020 -0700 @@ -1496,8 +1496,11 @@ def walkpat(pat): srcs = [] - m = scmutil.match(ctx, [pat], opts, globbed=True) - for abs in ctx.walk(m): + # TODO: Inline and simplify the non-working-copy version of this code + # since it shares very little with the working-copy version of it. + ctx_to_walk = ctx if ctx.rev() is None else pctx + m = scmutil.match(ctx_to_walk, [pat], opts, globbed=True) + for abs in ctx_to_walk.walk(m): rel = uipathfn(abs) exact = m.exact(abs) if abs not in ctx: