Patchwork [3,of,4,V2] py3: use pycompat.bytestr instead of bytes

login
register
mail settings
Submitter Pulkit Goyal
Date May 4, 2017, 10:40 p.m.
Message ID <c442d698765059a6afa6.1493937617@pulkit-goyal>
Download mbox | patch
Permalink /patch/20438/
State Accepted
Headers show

Comments

Pulkit Goyal - May 4, 2017, 10:40 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1493927809 -19800
#      Fri May 05 01:26:49 2017 +0530
# Node ID c442d698765059a6afa6db3361844e3cc8709d7d
# Parent  40e57ce475231ba494c8c0a9cf8f0278411d0c38
py3: use pycompat.bytestr instead of bytes
Yuya Nishihara - May 5, 2017, 10:08 a.m.
On Fri, 05 May 2017 04:10:17 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1493927809 -19800
> #      Fri May 05 01:26:49 2017 +0530
> # Node ID c442d698765059a6afa6db3361844e3cc8709d7d
> # Parent  40e57ce475231ba494c8c0a9cf8f0278411d0c38
> py3: use pycompat.bytestr instead of bytes

> @@ -2038,6 +2039,7 @@
>      False
>      """
>  
> +    date = pycompat.bytestr(date)

This one should have no effect since we do date.strip() soon. Dropped this
chunk and queued the others, thanks.

Patch

diff -r 40e57ce47523 -r c442d6987650 mercurial/templater.py
--- a/mercurial/templater.py	Fri May 05 01:26:13 2017 +0530
+++ b/mercurial/templater.py	Fri May 05 01:26:49 2017 +0530
@@ -53,6 +53,7 @@ 
     """Parse a template expression into a stream of tokens, which must end
     with term if specified"""
     pos = start
+    program = pycompat.bytestr(program)
     while pos < end:
         c = program[pos]
         if c.isspace(): # skip inter-token whitespace
diff -r 40e57ce47523 -r c442d6987650 mercurial/util.py
--- a/mercurial/util.py	Fri May 05 01:26:13 2017 +0530
+++ b/mercurial/util.py	Fri May 05 01:26:49 2017 +0530
@@ -1913,6 +1913,7 @@ 
     # add missing elements from defaults
     usenow = False # default to using biased defaults
     for part in ("S", "M", "HI", "d", "mb", "yY"): # decreasing specificity
+        part = pycompat.bytestr(part)
         found = [True for p in part if ("%"+p) in format]
         if not found:
             date += "@" + defaults[part][usenow]
@@ -2038,6 +2039,7 @@ 
     False
     """
 
+    date = pycompat.bytestr(date)
     def lower(date):
         d = {'mb': "1", 'd': "1"}
         return parsedate(date, extendeddateformats, d)[0]