equal
deleted
inserted
replaced
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 util |
14 from . import error |
15 |
15 |
16 def parsedag(desc): |
16 def parsedag(desc): |
17 '''parses a DAG from a concise textual description; generates events |
17 '''parses a DAG from a concise textual description; generates events |
18 |
18 |
19 "+n" is a linear run of n nodes based on the current default parent |
19 "+n" is a linear run of n nodes based on the current default parent |
267 i = 0 |
267 i = 0 |
268 while c != '\0' and i < 10: |
268 while c != '\0' and i < 10: |
269 s += c |
269 s += c |
270 i += 1 |
270 i += 1 |
271 c = nextch() |
271 c = nextch() |
272 raise util.Abort(_('invalid character in dag description: ' |
272 raise error.Abort(_('invalid character in dag description: ' |
273 '%s...') % s) |
273 '%s...') % s) |
274 |
274 |
275 def dagtextlines(events, |
275 def dagtextlines(events, |
276 addspaces=True, |
276 addspaces=True, |
277 wraplabels=False, |
277 wraplabels=False, |
296 if kind == 'n': |
296 if kind == 'n': |
297 r, ps = data |
297 r, ps = data |
298 |
298 |
299 # sanity check |
299 # sanity check |
300 if r != wantr: |
300 if r != wantr: |
301 raise util.Abort(_("expected id %i, got %i") % (wantr, r)) |
301 raise error.Abort(_("expected id %i, got %i") % (wantr, r)) |
302 if not ps: |
302 if not ps: |
303 ps = [-1] |
303 ps = [-1] |
304 else: |
304 else: |
305 for p in ps: |
305 for p in ps: |
306 if p >= r: |
306 if p >= r: |
307 raise util.Abort(_("parent id %i is larger than " |
307 raise error.Abort(_("parent id %i is larger than " |
308 "current id %i") % (p, r)) |
308 "current id %i") % (p, r)) |
309 wantr += 1 |
309 wantr += 1 |
310 |
310 |
311 # new root? |
311 # new root? |
312 p1 = r - 1 |
312 p1 = r - 1 |
364 yield '@' + wrapstring(data) |
364 yield '@' + wrapstring(data) |
365 elif kind == '#': |
365 elif kind == '#': |
366 yield '#' + data |
366 yield '#' + data |
367 yield '\n' |
367 yield '\n' |
368 else: |
368 else: |
369 raise util.Abort(_("invalid event type in dag: %s") |
369 raise error.Abort(_("invalid event type in dag: %s") |
370 % str((type, data))) |
370 % str((type, data))) |
371 if run: |
371 if run: |
372 yield '+' + str(run) |
372 yield '+' + str(run) |
373 |
373 |
374 line = '' |
374 line = '' |