comparison mercurial/dagparser.py @ 34210:8927534cacbc

py3: drop use of str() in dagparser.py
author Yuya Nishihara <yuya@tcha.org>
date Sun, 03 Sep 2017 15:25:50 +0900
parents da9c4b0693c5
children a48ad118c558
comparison
equal deleted inserted replaced
34209:da9c4b0693c5 34210:8927534cacbc
9 9
10 import re 10 import re
11 import string 11 import string
12 12
13 from .i18n import _ 13 from .i18n import _
14 from . import error 14 from . import (
15 error,
16 util,
17 )
15 18
16 def parsedag(desc): 19 def parsedag(desc):
17 '''parses a DAG from a concise textual description; generates events 20 '''parses a DAG from a concise textual description; generates events
18 21
19 "+n" is a linear run of n nodes based on the current default parent 22 "+n" is a linear run of n nodes based on the current default parent
312 # new root? 315 # new root?
313 p1 = r - 1 316 p1 = r - 1
314 if len(ps) == 1 and ps[0] == -1: 317 if len(ps) == 1 and ps[0] == -1:
315 if needroot: 318 if needroot:
316 if run: 319 if run:
317 yield '+' + str(run) 320 yield '+%d' % run
318 run = 0 321 run = 0
319 if wrapnonlinear: 322 if wrapnonlinear:
320 yield '\n' 323 yield '\n'
321 yield '$' 324 yield '$'
322 p1 = -1 325 p1 = -1
327 yield "." 330 yield "."
328 else: 331 else:
329 run += 1 332 run += 1
330 else: 333 else:
331 if run: 334 if run:
332 yield '+' + str(run) 335 yield '+%d' % run
333 run = 0 336 run = 0
334 if wrapnonlinear: 337 if wrapnonlinear:
335 yield '\n' 338 yield '\n'
336 prefs = [] 339 prefs = []
337 for p in ps: 340 for p in ps:
338 if p == p1: 341 if p == p1:
339 prefs.append('') 342 prefs.append('')
340 elif p in labels: 343 elif p in labels:
341 prefs.append(labels[p]) 344 prefs.append(labels[p])
342 else: 345 else:
343 prefs.append(str(r - p)) 346 prefs.append('%d' % (r - p))
344 yield '*' + '/'.join(prefs) 347 yield '*' + '/'.join(prefs)
345 else: 348 else:
346 if run: 349 if run:
347 yield '+' + str(run) 350 yield '+%d' % run
348 run = 0 351 run = 0
349 if kind == 'l': 352 if kind == 'l':
350 rid, name = data 353 rid, name = data
351 labels[rid] = name 354 labels[rid] = name
352 yield ':' + name 355 yield ':' + name
365 yield '@' + wrapstring(data) 368 yield '@' + wrapstring(data)
366 elif kind == '#': 369 elif kind == '#':
367 yield '#' + data 370 yield '#' + data
368 yield '\n' 371 yield '\n'
369 else: 372 else:
370 raise error.Abort(_("invalid event type in dag: %s") 373 raise error.Abort(_("invalid event type in dag: "
371 % str((kind, data))) 374 "('%s', '%s')")
375 % (util.escapestr(kind),
376 util.escapestr(data)))
372 if run: 377 if run:
373 yield '+' + str(run) 378 yield '+%d' % run
374 379
375 line = '' 380 line = ''
376 for part in gen(): 381 for part in gen():
377 if part == '\n': 382 if part == '\n':
378 if line: 383 if line: