Patchwork D6414: narrow: consider empty commits to be "inside the narrow spec" for templates

login
register
mail settings
Submitter phabricator
Date May 21, 2019, 1:19 a.m.
Message ID <differential-rev-PHID-DREV-fp7sqaab3o7k2brephhn-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/40163/
State Superseded
Headers show

Comments

phabricator - May 21, 2019, 1:19 a.m.
hooper created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: martinvonz.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It doesn't seem useful to exclude them, or harmful to include them. Users
  writing log templates using outsidenarrow as a predicate might consider it
  unexpected if their locally created empty drafts are treated as if they
  contained something outside the clone.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowtemplates.py
  tests/test-narrow.t

CHANGE DETAILS




To: hooper, durin42, martinvonz, #hg-reviewers
Cc: 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
@@ -281,6 +281,10 @@ 
   marked working directory as branch foo
   (branches are permanent and global, did you want a bookmark?)
   $ hg ci -m empty
+  $ hg log -T "{rev}: {desc} {outsidenarrow}\n"
+  2: empty 
+  1: add d5/f outsidenarrow
+  0: add d0/f outsidenarrow
   $ hg pull -q
 Can widen the empty clone
   $ hg tracked --addinclude d0
diff --git a/hgext/narrow/narrowtemplates.py b/hgext/narrow/narrowtemplates.py
--- a/hgext/narrow/narrowtemplates.py
+++ b/hgext/narrow/narrowtemplates.py
@@ -37,7 +37,7 @@ 
     repo = context.resource(mapping, 'repo')
     ctx = context.resource(mapping, 'ctx')
     m = repo.narrowmatch()
-    if not m.always():
+    if ctx.files() and not m.always():
         if not any(m(f) for f in ctx.files()):
             return 'outsidenarrow'
     return ''