[PATCH 3 of 8 py3] py3: drop use of str() in dagparser.py

Yuya Nishihara yuya at tcha.org
Sat Sep 16 10:31:27 EDT 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1504419950 -32400
#      Sun Sep 03 15:25:50 2017 +0900
# Node ID a3c836e6cd2f8cfcd9f4812ed7195d3d4496dc35
# Parent  9781ea13183a7a64d4b5fdfe13c07244273c0e56
py3: drop use of str() in dagparser.py

diff --git a/mercurial/dagparser.py b/mercurial/dagparser.py
--- a/mercurial/dagparser.py
+++ b/mercurial/dagparser.py
@@ -11,7 +11,10 @@ import re
 import string
 
 from .i18n import _
-from . import error
+from . import (
+    error,
+    util,
+)
 
 def parsedag(desc):
     '''parses a DAG from a concise textual description; generates events
@@ -314,7 +317,7 @@ def dagtextlines(events,
                 if len(ps) == 1 and ps[0] == -1:
                     if needroot:
                         if run:
-                            yield '+' + str(run)
+                            yield '+%d' % run
                             run = 0
                         if wrapnonlinear:
                             yield '\n'
@@ -329,7 +332,7 @@ def dagtextlines(events,
                         run += 1
                 else:
                     if run:
-                        yield '+' + str(run)
+                        yield '+%d' % run
                         run = 0
                     if wrapnonlinear:
                         yield '\n'
@@ -340,11 +343,11 @@ def dagtextlines(events,
                         elif p in labels:
                             prefs.append(labels[p])
                         else:
-                            prefs.append(str(r - p))
+                            prefs.append('%d' % (r - p))
                     yield '*' + '/'.join(prefs)
             else:
                 if run:
-                    yield '+' + str(run)
+                    yield '+%d' % run
                     run = 0
                 if kind == 'l':
                     rid, name = data
@@ -367,10 +370,12 @@ def dagtextlines(events,
                     yield '#' + data
                     yield '\n'
                 else:
-                    raise error.Abort(_("invalid event type in dag: %s")
-                                      % str((kind, data)))
+                    raise error.Abort(_("invalid event type in dag: "
+                                        "('%s', '%s')")
+                                      % (util.escapestr(kind),
+                                         util.escapestr(data)))
         if run:
-            yield '+' + str(run)
+            yield '+%d' % run
 
     line = ''
     for part in gen():


More information about the Mercurial-devel mailing list