py3: use bytes for template keyword registrations
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 09 Jul 2019 10:56:42 -0700
changeset 4719 358f548f8d6d
parent 4718 23323092f0a7
child 4720 d48b689ea78a
py3: use bytes for template keyword registrations This makes `import hgext3rd.topic` work.
hgext3rd/evolve/templatekw.py
hgext3rd/topic/__init__.py
--- a/hgext3rd/evolve/templatekw.py	Tue Jul 09 10:56:42 2019 -0700
+++ b/hgext3rd/evolve/templatekw.py	Tue Jul 09 10:56:42 2019 -0700
@@ -25,7 +25,7 @@
 ### template keywords
 
 if util.safehasattr(templatekw, 'compatlist'):
-    @eh.templatekeyword('instabilities', requires=set(['ctx', 'templ']))
+    @eh.templatekeyword(b'instabilities', requires=set([b'ctx', b'templ']))
     def showinstabilities(context, mapping):
         """List of strings. Evolution instabilities affecting the changeset
         (zero or more of "orphan", "content-divergent" or "phase-divergent")."""
@@ -34,14 +34,14 @@
                                      ctx.instabilities(),
                                      plural='instabilities')
 
-    @eh.templatekeyword('troubles', requires=set(['ctx', 'templ']))
+    @eh.templatekeyword(b'troubles', requires=set([b'ctx', b'templ']))
     def showtroubles(context, mapping):   # legacy name for instabilities
         ctx = context.resource(mapping, 'ctx')
         return templatekw.compatlist(context, mapping, 'trouble',
                                      ctx.instabilities(), plural='troubles')
 else:
     # older template API in hg < 4.6
-    @eh.templatekeyword('instabilities')
+    @eh.templatekeyword(b'instabilities')
     def showinstabilities(**args):
         """List of strings. Evolution instabilities affecting the changeset
         (zero or more of "orphan", "content-divergent" or "phase-divergent")."""
@@ -49,7 +49,7 @@
         return templatekw.showlist('instability', ctx.instabilities(), args,
                                    plural='instabilities')
 
-    @eh.templatekeyword('troubles')
+    @eh.templatekeyword(b'troubles')
     def showtroubles(**args):
         ctx = args['ctx']
         return templatekw.showlist('trouble', ctx.instabilities(), args,
@@ -60,10 +60,10 @@
     def showprecursors(context, mapping):
         return _sp(context, mapping)
     showprecursors.__doc__ = pycompat.sysstr(_sp._origdoc)
-    _tk = templatekw.templatekeyword("precursors", requires=_sp._requires)
+    _tk = templatekw.templatekeyword(b"precursors", requires=_sp._requires)
     _tk(showprecursors)
 else:
-    templatekw.keywords["precursors"] = _sp
+    templatekw.keywords[b"precursors"] = _sp
 
 
 def closestsuccessors(repo, nodeid):
@@ -76,10 +76,10 @@
     def showsuccessors(context, mapping):
         return _ss(context, mapping)
     showsuccessors.__doc__ = pycompat.sysstr(_ss._origdoc)
-    _tk = templatekw.templatekeyword("successors", requires=_ss._requires)
+    _tk = templatekw.templatekeyword(b"successors", requires=_ss._requires)
     _tk(showsuccessors)
 else:
-    templatekw.keywords["successors"] = _ss
+    templatekw.keywords[b"successors"] = _ss
 
 def _getusername(ui):
     """the default username in the config or None"""
@@ -208,7 +208,7 @@
     return "\n".join(lines)
 
 if not util.safehasattr(templatekw, 'obsfateverb'): # <= hg-4.5
-    @eh.templatekeyword("obsfatedata")
+    @eh.templatekeyword(b"obsfatedata")
     def showobsfatedata(repo, ctx, **args):
         # Get the needed obsfate data
         values = obsfatedata(repo, ctx)
--- a/hgext3rd/topic/__init__.py	Tue Jul 09 10:56:42 2019 -0700
+++ b/hgext3rd/topic/__init__.py	Tue Jul 09 10:56:42 2019 -0700
@@ -572,13 +572,13 @@
             listnames=lambda repo: repo.topics))
 
 if post45template:
-    @templatekeyword('topic', requires={'ctx'})
+    @templatekeyword(b'topic', requires={b'ctx'})
     def topickw(context, mapping):
         """:topic: String. The topic of the changeset"""
         ctx = context.resource(mapping, 'ctx')
         return ctx.topic()
 
-    @templatekeyword('topicidx', requires={'ctx'})
+    @templatekeyword(b'topicidx', requires={b'ctx'})
     def topicidxkw(context, mapping):
         """:topicidx: Integer. Index of the changeset as a stack alias"""
         ctx = context.resource(mapping, 'ctx')