Patchwork D11495: Make hg manifest only print things inside the narrowspec

login
register
mail settings
Submitter phabricator
Date Sept. 23, 2021, 5:51 p.m.
Message ID <differential-rev-PHID-DREV-eynncb6cpcwwzcv7g2c5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49813/
State New
Headers show

Comments

phabricator - Sept. 23, 2021, 5:51 p.m.
charlesetc created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The performance of these commands seem roughly unchanged from the manual
  testing I've done.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11495

AFFECTED FILES
  mercurial/commands.py
  tests/test-narrow.t

CHANGE DETAILS




To: charlesetc, durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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
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,9 @@ 
         res = set()
         for rev in repo:
             ctx = repo[rev]
-            res |= set(ctx.files())
+            files = ctx.files()
+            files = filter(m, files)
+            res |= set(files)
 
         ui.pager(b'manifest')
         for f in sorted(res):
@@ -4793,7 +4796,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()