templatekw: parents template should not return null p2

Summary:
The `parents` template currently returns "meaningfulparents".  This sometimes
returns the null revision as the second parent, making templates think this is a
merge commit when it is not.  Make sure we filter this out.

Reviewed By: quark-zju

Differential Revision: D21347776

fbshipit-source-id: af83fd5cff381850ac39d97b5b2f4c77033fe2fb
This commit is contained in:
Mark Thomas 2020-05-01 12:47:20 -07:00 committed by Facebook GitHub Bot
parent fafe8802b4
commit ed49d36d41
2 changed files with 5 additions and 5 deletions

View File

@ -604,13 +604,13 @@ def meaningfulparents(repo, ctx):
is not the preceding revision.
"""
parents = ctx.parents()
if len(parents) > 1:
if len(parents) > 1 and parents[1].rev() != -1:
return parents
if repo.ui.debugflag:
return [parents[0], repo["null"]]
if parents[0].rev() >= intrev(ctx) - 1:
return []
return parents
return parents[:1]
def expandpats(pats):

View File

@ -914,9 +914,9 @@ def showp2node(repo, ctx, templ, **args):
@templatekeyword("parents")
def showparents(**args):
"""List of strings. The parents of the changeset in "rev:node"
format. If the changeset has only one "natural" parent (the predecessor
revision) nothing is shown."""
"""List of strings. The parents of the changeset in "rev:node" format.
If the changeset's only parent has the previous revision number, it is
omitted."""
args = args
repo = args["repo"]
ctx = args["ctx"]