ó œt•Pc@s}ddlZddlZddlZddlmZd„Zeeeeeedd„Zeeeeeedd„Z dS(iÿÿÿÿN(t_c#s|s dStjtj‰i‰d‰d‰‡‡‡fd†}d„|Dƒ‰‡fd†‰‡fd†‰‡fd†‰‡‡‡‡fd †}ˆƒ}xr|d krx|tjkr̈ƒ}q±W|d kr d ˆˆgffVˆ‰ˆd 7‰ˆƒ}q¢|dkr}ˆˆƒtjƒ\}}t|ƒ}xÑtd|ƒD]*}d ˆˆgffVˆ‰ˆd 7‰qLWq¢|dkr4|dkr¡ˆƒ}n||ƒ\}}|g}x2|dkrð|ˆƒƒ\}}|j|ƒq¿Wg|D]} || ƒ^qø} d ˆ| ffVˆ‰ˆd 7‰q¢|dkrd|ˆƒƒ\}} || ƒ‰q¢|dkr£|ˆƒƒ\}} ˆˆ| >> len(list(parsedag(""" ... ... +3 # 3 nodes in linear run ... :forkhere # a label for the last of the 3 nodes from above ... +5 # 5 more nodes on one branch ... :mergethis # label again ... >> list(parsedag("")) [] A simple linear run: >>> list(parsedag("+3")) [('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [1]))] Some non-standard ways to define such runs: >>> list(parsedag("+1+2")) [('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [1]))] >>> list(parsedag("+1*1*")) [('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [1]))] >>> list(parsedag("*")) [('n', (0, [-1]))] >>> list(parsedag("...")) [('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [1]))] A fork and a join, using numeric back references: >>> list(parsedag("+2*2*/2")) [('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [0])), ('n', (3, [2, 1]))] >>> list(parsedag("+2<2+1/2")) [('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [0])), ('n', (3, [2, 1]))] Placing a label: >>> list(parsedag("+1 :mylabel +1")) [('n', (0, [-1])), ('l', (0, 'mylabel')), ('n', (1, [0]))] An empty label (silly, really): >>> list(parsedag("+1:+1")) [('n', (0, [-1])), ('l', (0, '')), ('n', (1, [0]))] Fork and join, but with labels instead of numeric back references: >>> list(parsedag("+1:f +1:p2 *f */p2")) [('n', (0, [-1])), ('l', (0, 'f')), ('n', (1, [0])), ('l', (1, 'p2')), ('n', (2, [0])), ('n', (3, [2, 1]))] >>> list(parsedag("+1:f +1:p2 >> list(parsedag("+1 $ +1")) [('n', (0, [-1])), ('n', (1, [-1]))] Annotations, which are meant to introduce sticky state for subsequent nodes: >>> list(parsedag("+1 @ann +1")) [('n', (0, [-1])), ('a', 'ann'), ('n', (1, [0]))] >>> list(parsedag('+1 @"my annotation" +1')) [('n', (0, [-1])), ('a', 'my annotation'), ('n', (1, [0]))] Commands, which are meant to operate on the most recently created node: >>> list(parsedag("+1 !cmd +1")) [('n', (0, [-1])), ('c', 'cmd'), ('n', (1, [0]))] >>> list(parsedag('+1 !"my command" +1')) [('n', (0, [-1])), ('c', 'my command'), ('n', (1, [0]))] >>> list(parsedag('+1 !!my command line\n +1')) [('n', (0, [-1])), ('C', 'my command line'), ('n', (1, [0]))] Comments, which extend to the end of the line: >>> list(parsedag('+1 # comment\n+1')) [('n', (0, [-1])), ('n', (1, [0]))] Error: >>> try: list(parsedag('+1 bad')) ... except Exception, e: print e invalid character in dag description: bad... Niÿÿÿÿics7|s ˆS|dtjkr+ˆt|ƒSˆ|SdS(Ni(tstringtdigitstint(tref(tlabelstp1tr(s7/sys/lib/python2.7/site-packages/mercurial/dagparser.pytresolve¨s css|] }|VqdS(N((t.0tc((s7/sys/lib/python2.7/site-packages/mercurial/dagparser.pys °scs'yˆjƒSWntk r"dSXdS(Nt(tnextt StopIteration((tchiter(s7/sys/lib/python2.7/site-packages/mercurial/dagparser.pytnextch²s cs6d}x#||kr+||7}ˆƒ}q W||fS(Nt((R tallowts(R(s7/sys/lib/python2.7/site-packages/mercurial/dagparser.pytnextrun¸s   csQd}x;||krC||kr-ˆƒ}n||7}ˆƒ}q Wˆƒ|fS(NR((R tlimittescapeR(R(s7/sys/lib/python2.7/site-packages/mercurial/dagparser.pyt nextdelimited¿s    cs0|dkrˆˆƒddƒSˆ|ˆƒSdS(Nt"s\((R (RRRt wordchars(s7/sys/lib/python2.7/site-packages/mercurial/dagparser.pyt nextstringÈs R t.tnit+s*/t*t/t>> dagtext([('n', (0, [-1])), ('n', (1, [0]))]) '+2' Two roots: >>> dagtext([('n', (0, [-1])), ('n', (1, [-1]))]) '+1 $ +1' Fork and join: >>> dagtext([('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [0])), ... ('n', (3, [2, 1]))]) '+2 *2 */2' Fork and join with labels: >>> dagtext([('n', (0, [-1])), ('l', (0, 'f')), ('n', (1, [0])), ... ('l', (1, 'p2')), ('n', (2, [0])), ('n', (3, [2, 1]))]) '+1 :f +1 :p2 *f */p2' Annotations: >>> dagtext([('n', (0, [-1])), ('a', 'ann'), ('n', (1, [0]))]) '+1 @ann +1' >>> dagtext([('n', (0, [-1])), ... ('a', 'my annotation'), ... ('n', (1, [0]))]) '+1 @"my annotation" +1' Commands: >>> dagtext([('n', (0, [-1])), ('c', 'cmd'), ('n', (1, [0]))]) '+1 !cmd +1' >>> dagtext([('n', (0, [-1])), ('c', 'my command'), ('n', (1, [0]))]) '+1 !"my command" +1' >>> dagtext([('n', (0, [-1])), ... ('C', 'my command line'), ... ('n', (1, [0]))]) '+1 !!my command line\n+1' Comments: >>> dagtext([('n', (0, [-1])), ('#', ' comment'), ('n', (1, [0]))]) '+1 # comment\n+1' >>> dagtext([]) '' Combining parsedag and dagtext: >>> dagtext(parsedag('+1 :f +1 :p2 *f */p2')) '+1 :f +1 :p2 *f */p2' s (R@RU(tdagRQRMRKRLRNRJRR((s7/sys/lib/python2.7/site-packages/mercurial/dagparser.pytdagtext…sS ( R8RR,ti18nRR7R?R<RURW(((s7/sys/lib/python2.7/site-packages/mercurial/dagparser.pyts$  ÿ m