File: //proc/self/root/lib64/python2.7/site-packages/mercurial/dagparser.pyo
�
1�3\c @@ s� d d l m Z d d l Z d d l Z d d l m Z d d l m Z m Z d d l m
Z
d � Z e e
e
e
e
e
d d � Z e e
e
e
e
e
d d
� Z d S( i ( t absolute_importNi ( t _( t errort pycompat( t
stringutilc #@ s5 | s
d St j t j t j � � i � d � d � � � � f d � } t j | � � � f d � � � f d � � � f d � � � � � � f d � } � � } x�| d k r0x% | t j t j � k r� � � } q� W| d
k rd � � g f f V� � � d 7� � � } q� | d
k r�� � � t j t j � � \ } } t | � } x�t j d | � D]* } d � � g f f V� � � d 7� qiWq� | d k rQ| d k r�� � } n | | � \ } } | g } x2 | d k r
| � � � \ } } | j | � q�Wg | D] } | | � ^ q}
d � |
f f V� � � d 7� q� | d k r�| � � � \ } } | | � � q� | d k r�| � � � \ } } � � | <d � | f f Vq� | d k r�| � � � \ } } d | f Vq� | d k rs� � } | d k rSd }
� � } x# | d k rD|
| 7}
� � } q"Wd |
f Vq-| | � \ } }
d |
f Vq� | d k r�x� | d k r�� � } q�Wq� | d k r�d � � � } q� | d k r�d Sd } d } x9 | d k r| d k r| | 7} | d 7} � � } q�Wt
j t d � | � � q� Wd S( s# parses a DAG from a concise textual description; generates events
"+n" is a linear run of n nodes based on the current default parent
"." is a single node based on the current default parent
"$" resets the default parent to -1 (implied at the start);
otherwise the default parent is always the last node created
"<p" sets the default parent to the backref p
"*p" is a fork at parent p, where p is a backref
"*p1/p2/.../pn" is a merge of parents p1..pn, where the pi are backrefs
"/p2/.../pn" is a merge of the preceding node and p2..pn
":name" defines a label for the preceding node; labels can be redefined
"@text" emits an annotation event for text
"!command" emits an action event for the current node
"!!my command
" is like "!", but to the end of the line
"#...
" is a comment up to the end of the line
Whitespace between the above elements is ignored.
A backref is either
* a number n, which references the node curr-n, where curr is the current
node, or
* the name of a label you placed earlier using ":name", or
* empty to denote the default parent.
All string valued-elements are either strictly alphanumeric, or must
be enclosed in double quotes ("..."), with "" as escape character.
Generates sequence of
('n', (id, [parentids])) for node creation
('l', (id, labelname)) for labels on nodes
('a', text) for annotations
('c', command) for actions (!)
('C', command) for line actions (!!)
Examples
--------
Example of a complex graph (output not shown for brevity):
>>> len(list(parsedag(b"""
...
... +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
... <forkhere # set default parent to labeled fork node
... +10 # 10 more nodes on a parallel branch
... @stable # following nodes will be annotated as "stable"
... +5 # 5 nodes in stable
... !addfile # custom command; could trigger new file in next node
... +2 # two more nodes
... /mergethis # merge last node with labeled node
... +4 # 4 more nodes descending from merge node
...
... """)))
34
Empty list:
>>> list(parsedag(b""))
[]
A simple linear run:
>>> list(parsedag(b"+3"))
[('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [1]))]
Some non-standard ways to define such runs:
>>> list(parsedag(b"+1+2"))
[('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [1]))]
>>> list(parsedag(b"+1*1*"))
[('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [1]))]
>>> list(parsedag(b"*"))
[('n', (0, [-1]))]
>>> list(parsedag(b"..."))
[('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [1]))]
A fork and a join, using numeric back references:
>>> list(parsedag(b"+2*2*/2"))
[('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [0])), ('n', (3, [2, 1]))]
>>> list(parsedag(b"+2<2+1/2"))
[('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [0])), ('n', (3, [2, 1]))]
Placing a label:
>>> list(parsedag(b"+1 :mylabel +1"))
[('n', (0, [-1])), ('l', (0, 'mylabel')), ('n', (1, [0]))]
An empty label (silly, really):
>>> list(parsedag(b"+1:+1"))
[('n', (0, [-1])), ('l', (0, '')), ('n', (1, [0]))]
Fork and join, but with labels instead of numeric back references:
>>> list(parsedag(b"+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(b"+1:f +1:p2 <f +1 /p2"))
[('n', (0, [-1])), ('l', (0, 'f')), ('n', (1, [0])), ('l', (1, 'p2')),
('n', (2, [0])), ('n', (3, [2, 1]))]
Restarting from the root:
>>> list(parsedag(b"+1 $ +1"))
[('n', (0, [-1])), ('n', (1, [-1]))]
Annotations, which are meant to introduce sticky state for subsequent nodes:
>>> list(parsedag(b"+1 @ann +1"))
[('n', (0, [-1])), ('a', 'ann'), ('n', (1, [0]))]
>>> list(parsedag(b'+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(b"+1 !cmd +1"))
[('n', (0, [-1])), ('c', 'cmd'), ('n', (1, [0]))]
>>> list(parsedag(b'+1 !"my command" +1'))
[('n', (0, [-1])), ('c', 'my command'), ('n', (1, [0]))]
>>> list(parsedag(b'+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(b'+1 # comment\n+1'))
[('n', (0, [-1])), ('n', (1, [0]))]
Error:
>>> try: list(parsedag(b'+1 bad'))
... except Exception as e: print(pycompat.sysstr(bytes(e)))
invalid character in dag description: bad...
Ni����i c @ s@ | s
� S| d t j t j � k r4 � t | � S� | Sd S( Ni ( R t bytestrt stringt digitst int( t ref( t labelst p1t r( s9 /usr/lib64/python2.7/site-packages/mercurial/dagparser.pyt resolve� s
c @ s
t � d � S( Ns ( t next( ( t chiter( s9 /usr/lib64/python2.7/site-packages/mercurial/dagparser.pyt nextch� s c @ s6 d } x# | | k r+ | | 7} � � } q W| | f S( Nt ( ( t ct allowt s( R ( s9 /usr/lib64/python2.7/site-packages/mercurial/dagparser.pyt nextrun� s
c @ sQ d } x; | | k rC | | k r- � � } n | | 7} � � } q W� � | f S( NR ( ( R t limitt escapeR ( R ( s9 /usr/lib64/python2.7/site-packages/mercurial/dagparser.pyt
nextdelimited� s
c @ s0 | d k r � � � d d � S� | � � Sd S( Nt "s \( ( R ( R R R t wordchars( s9 /usr/lib64/python2.7/site-packages/mercurial/dagparser.pyt
nextstring� s s t .t ni t +s */t *t /t <t :t lt @t at !R s
t CR t #t $i
s+ invalid character in dag description: %s...(
R R R t
ascii_lettersR t iterbytestrt
whitespaceR t xranget appendR t AbortR ( t descR
R R t digsR t it preft prefsR t pst namet textt cmdR ( ( R R
R R R R R R s9 /usr/lib64/python2.7/site-packages/mercurial/dagparser.pyt parsedag s� �
$
iF c #@ s� d � � � � � � � � � f d � } d } x� | � D]� }
|
d k rc | r� | Vd } q� q: t | � t |
� | k r� | Vd } n% | r� | r� |
d k r� | d 7} n | |
7} q: W| r� | Vn d S( s$ generates single lines for dagtext()c S@ s: t j d | � r | Sd | j d d � j d d � d S( Ns ^[0-9a-z]*$R s \s \\( t ret matcht replace( R7 ( ( s9 /usr/lib64/python2.7/site-packages/mercurial/dagparser.pyt
wrapstring# s c
3@ sL i } d } d } t } x� D]\ } } | d k r| \ } } | | k rq t j t d � | | f � � n | s� d g } n? x<