diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4764,6 +4764,7 @@ opts = pycompat.byteskwargs(opts) fm = ui.formatter(b'manifest', opts) + m = repo.narrowmatch() if opts.get(b'all'): if rev or node: raise error.InputError(_(b"can't specify a revision with --all")) @@ -4771,7 +4772,10 @@ res = set() for rev in repo: ctx = repo[rev] - res |= set(ctx.files()) + files = ctx.files() + if not m.always(): + files = filter(m, files) + res |= set(files) ui.pager(b'manifest') for f in sorted(res): @@ -4793,7 +4797,7 @@ ctx = scmutil.revsingle(repo, node) mf = ctx.manifest() ui.pager(b'manifest') - for f in ctx: + for f in ctx.matches(m): fm.startitem() fm.context(ctx=ctx) fl = ctx[f].flags() diff --git a/tests/test-narrow.t b/tests/test-narrow.t --- a/tests/test-narrow.t +++ b/tests/test-narrow.t @@ -539,3 +539,13 @@ deleting meta/d0/00manifest.i (tree !) deleting unwanted files from working copy not deleting possibly dirty file d0/f + + +Test manifest only prints files inside the narrowspec + + $ hg status + $ hg tracked -q --addinclude "" --addexclude d2 + $ { hg manifest ; hg manifest -r . ; hg manifest --all ; } | grep -e d2 -e d4 + d4/f + d4/f + d4/f