[Updated] D11495: Make hg manifest only print things inside the narrowspec

charlesetc (Charles Chamberlain) phabricator at mercurial-scm.org
Fri Sep 24 18:02:36 UTC 2021


charlesetc retitled this revision from "narrow: Make hg manifest only print things inside the narrowspec" to "Make hg manifest only print things inside the narrowspec".
charlesetc updated this revision to Diff 30403.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D11495?vs=30391&id=30403

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D11495/new/

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

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

CHANGE DETAILS

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,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()



To: charlesetc, durin42, #hg-reviewers, Alphare
Cc: Alphare, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210924/6b789fff/attachment-0002.html>


More information about the Mercurial-patches mailing list