Patchwork D8846: templatespec: logcmdutil.templatespec() gets either template or mapfile

login
register
mail settings
Submitter phabricator
Date July 29, 2020, 6:38 p.m.
Message ID <differential-rev-PHID-DREV-cfscigbamucywidrz5ku-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46934/
State Superseded
Headers show

Comments

phabricator - July 29, 2020, 6:38 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The callers of the function already never pass (non-`None`) values for
  both, so let's check that and call the new factory functions.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/logcmdutil.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -603,12 +603,13 @@ 
 
 
 def templatespec(tmpl, mapfile):
-    if pycompat.ispy3:
-        assert not isinstance(tmpl, str), b'tmpl must not be a str'
+    assert not (tmpl and mapfile)
     if mapfile:
-        return formatter.templatespec(b'changeset', tmpl, mapfile)
+        return formatter.mapfile_templatespec(b'changeset', mapfile)
     else:
-        return formatter.templatespec(b'', tmpl, None)
+        if pycompat.ispy3:
+            assert not isinstance(tmpl, str), b'tmpl must not be a str'
+        return formatter.literal_templatespec(tmpl)
 
 
 def _lookuptemplate(ui, tmpl, style):