Patchwork [02,of,10,RFC] templater: ensure callers that expect a string will always get a string

login
register
mail settings
Submitter Sean Farley
Date Dec. 21, 2012, 5:37 a.m.
Message ID <812607049cddf4653985.1356068272@laptop.local>
Download mbox | patch
Permalink /patch/236/
State Superseded
Headers show

Comments

Sean Farley - Dec. 21, 2012, 5:37 a.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1355935470 21600
# Node ID 812607049cddf4653985ed96ecf9ef9c8c7dab78
# Parent  8c8d483cdb59f2cbb1cdc77f83a7edae57e86d23
templater: ensure callers that expect a string will always get a string

In future patches, we will be changing the templater engine to return a dictionary of labels, so this patch is to ensure that callers which expect a string will always get a string.

Patch

diff --git a/hgext/schemes.py b/hgext/schemes.py
--- a/hgext/schemes.py
+++ b/hgext/schemes.py
@@ -68,11 +68,12 @@ 
             tail = parts[-1]
             parts = parts[:-1]
         else:
             tail = ''
         context = dict((str(i + 1), v) for i, v in enumerate(parts))
-        url = ''.join(self.templater.process(self.url, context)) + tail
+        stream = self.templater.process(self.url, context)
+        url = ''.join(templater.stringify(stream)) + tail
         return hg._peerlookup(url).instance(ui, url, create)
 
 def hasdriveletter(orig, path):
     if path:
         for scheme in schemes:
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -418,11 +418,11 @@ 
                                                  self.filters, self.defaults)
         proc = self.ecache[ttype]
 
         stream = proc.process(t, mapping)
         if self.minchunk:
-            stream = util.increasingchunks(stream, min=self.minchunk,
+            stream = util.increasingchunks(stringify(stream), min=self.minchunk,
                                            max=self.maxchunk)
         return stream
 
 def templatepath(name=None):
     '''return location of template file or directory (if no name).