From ed49d36d411a6be058c27161de98f61de5c9e8f2 Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Fri, 1 May 2020 12:47:20 -0700 Subject: [PATCH] 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 --- eden/scm/edenscm/mercurial/scmutil.py | 4 ++-- eden/scm/edenscm/mercurial/templatekw.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/eden/scm/edenscm/mercurial/scmutil.py b/eden/scm/edenscm/mercurial/scmutil.py index 52f73c87e8..15355cab7e 100644 --- a/eden/scm/edenscm/mercurial/scmutil.py +++ b/eden/scm/edenscm/mercurial/scmutil.py @@ -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): diff --git a/eden/scm/edenscm/mercurial/templatekw.py b/eden/scm/edenscm/mercurial/templatekw.py index ef40b98155..61e740f144 100644 --- a/eden/scm/edenscm/mercurial/templatekw.py +++ b/eden/scm/edenscm/mercurial/templatekw.py @@ -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"]