ó
    6°hx<  ã                  ó~   • S SK Jr  S SKrS SKrSSKJr  SSKJrJr  SSK	J
r
  S r       S
S jr       S
S	 jrg)é    )ÚannotationsNé   )Ú_)ÚerrorÚpycompat)Ú
stringutilc              #  óV  ^^^^^^^^#   • U (       d  g[         R                  " [        R                  [        R                  -   5      m0 mSmSmUUU4S jn[         R
                  " U 5      mU4S jmU4S jmU4S jmUUUU4S jnT" 5       nUS	:w  GaŽ  U[         R                  " [        R                  5      ;   a1  T" 5       nU[         R                  " [        R                  5      ;   a  M1  US
:X  a  STT/44v •  TmTS-  mT" 5       nGOUS:X  ab  T" T" 5       [         R                  " [        R                  5      5      u  p4[        U5      n[        SU5       H  nSTT/44v •  TmTS-  mM     GO¤US;   ap  US:X  a  T" 5       nU" U5      u  p7U/nUS:X  a(  U" T" 5       5      u  p7UR                  U5        US:X  a  M(  U V	s/ s H
  o‘" U	5      PM     n
n	STU
44v •  TmTS-  mGO.US:X  a  U" T" 5       5      u  p9U" U	5      mGOUS:X  a  U" T" 5       5      u  p;TTU'   STU44v •  OìUS:X  a  U" T" 5       5      u  p<SU4v •  OÐUS:X  aG  T" 5       nUS:X  a)  SnT" 5       nUS;  a  XÓ-  nT" 5       nUS;  a  M  SU4v •  O”U" U5      u  p=SU4v •  OƒUS:X  a  US;  a  T" 5       nUS;  a  M  OgUS:X  a
  SmT" 5       nOWUS	:X  a  gSnSnUS	:w  a$  US:  a  Xã-  nUS-  nT" 5       nUS	:w  a  US:  a  M  [        R                  " [        S5      U-  5      eUS	:w  a  GM�  ggs  sn	f 7f)a#  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...

    Néÿÿÿÿr   c                ó’   >• U (       d  T$ U S   [         R                  " [        R                  5      ;   a  T[	        U 5      -
  $ TU    $ )Nr   )r   ÚbytestrÚstringÚdigitsÚint)ÚrefÚlabelsÚp1Úrs    €€€Ú5/usr/lib/python3/dist-packages/mercurial/dagparser.pyÚresolveÚparsedag.<locals>.resolve³   s>   ø€ ÞØˆIà�‰V”x×'Ò'¬¯©Ó6Ó6à”s˜3“x‘<Ðà˜#‘;Ðó    c                 ó   >• [        T S5      $ )Nó    )Únext)Úchiters   €r   ÚnextchÚparsedag.<locals>.nextch¿   s   ø€ Ü�F˜EÓ"Ð"r   c                ó<   >• SnX;   a  X -  nT" 5       n X;   a  M  X4$ ©Nr   © )ÚcÚallowÚsr   s      €r   ÚnextrunÚparsedag.<locals>.nextrunÂ   s+   ø€ ØˆØ‹jØ‰FˆAÙ“ˆAð �jð ˆtˆr   c                ó`   >• SnX:w  a  X:X  a  T" 5       n X0-  nT" 5       n X:w  a  M  T" 5       U4$ r   r    )r!   ÚlimitÚescaper#   r   s       €r   ÚnextdelimitedÚparsedag.<locals>.nextdelimitedÉ   s<   ø€ ØˆØ‹jØ‹{Ù“H�Ø‰FˆAÙ“ˆAð	 �jñ
 ‹x˜ˆ{Ðr   c                ó@   >• U S:X  a  T" T" 5       SS5      $ T" U T5      $ )Nó   "ó   \r    )r!   r   r)   r$   Ú	wordcharss    €€€€r   Ú
nextstringÚparsedag.<locals>.nextstringÒ   s(   ø€ Ø�‹9Ù ¡£¨4°Ó7Ð7á˜1˜iÓ(Ð(r   r   ó   .ó   nr   ó   +s   */ó   *ó   /ó   <ó   :ó   ló   @ó   aó   !r   s   
 ó   Có   có   #ó   $é
   s+   invalid character in dag description: %s...)r   r   r   Úascii_lettersr   ÚiterbytestrÚ
whitespacer   ÚrangeÚappendr   ÚAbortr   )Údescr   r/   r!   ÚdigsÚnÚiÚprefÚprefsr   ÚpsÚnameÚtextÚcmdr#   r   r   r   r)   r$   r   r   r.   s                  @@@@@@@@r   ÚparsedagrQ      sG  ÿé € öf Øô × Ò ¤×!5Ñ!5¼¿¹Ñ!EÓF€Ið €FØ	€BØ	€A÷ô ×!Ò! $Ó'€Fõ#õõ÷)ð )ñ 	‹€AØ
ˆuŒ*à”8×#Ò#¤F×$5Ñ$5Ó6Ó6á“ˆAð ”8×#Ò#¤F×$5Ñ$5Ó6Õ6ð �‹9Ø˜˜R˜D˜	�/Ò!ØˆBØ�‰FˆAÙ“ŠAØ�$‹Yá™f›h¬×(8Ò(8¼¿¹Ó(GÓH‰GˆAä�D“	ˆAÜ˜1˜a–[�Ø˜Q  ˜I�oÒ%Ø�Ø�Q‘’ó !ð �%‹ZØ�D‹yÙ“H�Ù  “m‰GˆAØ�FˆEØ�t“)Ù$¡V£XÓ.‘�Ø—‘˜TÔ"ð �t•)ñ +0Ó0ª% 3�'˜#–,©%ˆBÐ0Ø˜˜B˜�-ÒØˆBØ�‰FŠAØ�$‹YÙ¡£Ó)‰FˆAÙ˜“ŠBØ�$‹YÙ ¡£Ó*‰GˆAØˆF�4‰LØ˜˜T˜
Ð"Ó"Ø�$‹YÙ ¡£Ó*‰GˆAØ˜�*ÓØ�$‹YÙ“ˆAØ�D‹yØ�Ù“H�Ø˜yÓ(Ø‘H�CÙ›�Að ˜yÕ(ð ˜C�i“á# A›‘�Ø˜C�i“Ø�$‹YØ˜9Ó$Ù“H�ð ˜9Õ$øà�$‹YØˆBÙ“‰AØ�%‹ZØàˆAØˆAØ�u“*  R£Ø‘�Ø�Q‘�Ù“H�ð �u“*  R¥ô —+’+ÜÐ@ÓAÀAÑEóð ðI ˆu�*ˆ*ùò6 1ùs9   ŠC"L)Ã.CL)ÇL)ÇL$ÇB$L)É>1L)Ê1AL)Ë7(L)Ì"L)c              #  ó  ^ ^^^^^^#   • S mU UUUUUU4S jnSn	U" 5        HY  n
U
S:X  a  U	(       a  U	v •  Sn	M  M  [        U	5      [        U
5      -   U:¼  a  U	v •  Sn	OU(       a  U	(       a  U
S:w  a  U	S-  n	Xš-  n	M[     U	(       a  U	v •  gg7f)z$generates single lines for dagtext()c                óŽ   • [         R                  " SU 5      (       a  U $ SU R                  SS5      R                  SS5      -   S-   $ )Ns   ^[0-9a-z]*$r,   r-   s   \\)ÚreÚmatchÚreplace)rO   s    r   Ú
wrapstringÚ dagtextlines.<locals>.wrapstring.  s@   € Ü�8Š8�N D×)Ñ)ØˆKØ�d—l‘l 5¨'Ó2×:Ñ:¸4ÀÓGÑGÈ$ÑNÐNr   c               3  ó  >#   • 0 n SnSnSnT GHa  u  pEUS:X  Gah  Uu  pgXb:w  a#  [         R                  " [        S5      X&4-  5      eU(       d  S/nO1U H+  nX†:¼  d  M
  [         R                  " [        S5      X†4-  5      e   US-  nUS-
  n	[        U5      S:X  a4  US   S:X  a+  U(       a"  U(       a	  SU-  v •  SnT(       a  S	v •  S
v •  Sn	OSn[        U5      S:X  a  US   U	:X  a  T(       a  Sv •  Mç  US-  nMî  U(       a	  SU-  v •  SnT(       a  S	v •  / n
U HK  nX‰:X  a  U
R	                  S5        M  X€;   a  U
R	                  X   5        M5  U
R	                  SXh-
  -  5        MM     SSR                  U
5      -   v •  GMu  U(       a	  SU-  v •  SnUS:X  a   Uu  p¼XÀU'   SU-   v •  T(       a  S	v •  GM¨  GM«  US:X  a  ST" U5      -   v •  T(       a  S	v •  GMÌ  GMÏ  US:X  a  SU-   v •  S	v •  GMã  US:X  a  T(       a  S	v •  ST" U5      -   v •  GM  US:X  a  SU-   v •  S	v •  GM  [         R                  " [        S5      [        R                  " U5      [        R                  " U5      4-  5      e   U(       a  SU-  v •  g g 7f)Nr   Fr2   s   expected id %i, got %ir
   s)   parent id %i is larger than current id %ir   s   +%dó   
r?   Tr1   r   s   %dr4   r5   r8   r7   r=   r;   r<   s   !!r:   r9   r>   s'   invalid event type in dag: ('%s', '%s'))r   rF   r   ÚlenrE   Újoinr   Ú	escapestr)r   ÚrunÚwantrÚneedrootÚkindÚdatar   rM   Úpr   rL   ÚridrN   ÚeventsÚusedotsÚwrapannotationsÚwrapcommandsÚ
wraplabelsÚwrapnonlinearrW   s                €€€€€€€r   ÚgenÚdagtextlines.<locals>.gen3  s�  øé € ØˆØˆØˆØˆÜ ‰JˆDØ�tŒ|Ø‘�ð “:ÜŸ+š+¤aÐ(AÓ&BÀeÀZÑ&OÓPÐPÞØ˜‘Bã˜Ø�6Ü"'§+¢+Ü !ð%5ó!"ð $% &ñ	!)ó#ð ñ  ð ˜‘
�ð ˜‘U�Ü�r“7˜a“< B q¡E¨R£KÞÞØ"(¨3¡,Ò.Ø"#˜CÞ(Ø"'šKØ"š
Ø™à#'˜Ü�r“7˜a“< B q¡E¨R£KÞØ"œ
à˜q™šæØ$ s™lÒ*Ø˜Þ$Ø#šØ�EÛ˜Ø›7Ø!ŸL™L¨Ö-Ø›[Ø!ŸL™L¨©Ö3à!ŸL™L¨°!±%©Ö9ñ  ð  §¡¨5Ó!1Ñ1Õ1æØ  3™,Ò&Ø�CØ˜4“<Ø $‘I�CØ"&˜3‘KØ ™+Ò%Þ!Ø#�ò "à˜T“\Ø¡¨DÓ!1Ñ1Ò1Þ#Ø#�ò $à˜T“\Ø $™,Ò&Ø•KØ˜T“\Þ&Ø#šØ¡¨DÓ!1Ñ1Õ1Ø˜T“\Ø ™+Ò%Ø•KäŸ+š+ÜÐDÓEä&×0Ò0°Ó6Ü&×0Ò0°Ó6ðñóð ñ_ !öl Ø˜3‘,Óð ùs   ƒAJÁH&Jr   rZ   r1   ó    N)r[   )re   Ú	addspacesri   rg   rh   rj   rf   Úmaxlinewidthrk   ÚlineÚpartrW   s   ` `````    @r   Údagtextlinesrr   "  s�   þé € òO÷
\ó \ð| €DÙ–ˆØ�5‹=ÞØ’
Ø’ñ ô �4‹yœ3˜t›9Ñ$¨Ó4Ø’
Ø‘Þžt¨°«Ø˜‘�Ø‰LŠDñ ö Ø‹
ð ùs   ‰BBc                óD   • SR                  [        U UUUUUUU5      5      $ )a  generates lines of a textual representation for a dag event stream

events should generate what parsedag() does, so:

  ('n', (id, [parentids])) for node creation
  ('l', (id, labelname)) for labels on nodes
  ('a', text) for annotations
  ('c', text) for commands
  ('C', text) for line commands ('!!')
  ('#', text) for comment lines

Parent nodes must come before child nodes.

Examples
--------

Linear run:

    >>> dagtext([(b'n', (0, [-1])), (b'n', (1, [0]))])
    '+2'

Two roots:

    >>> dagtext([(b'n', (0, [-1])), (b'n', (1, [-1]))])
    '+1 $ +1'

Fork and join:

    >>> dagtext([(b'n', (0, [-1])), (b'n', (1, [0])), (b'n', (2, [0])),
    ...          (b'n', (3, [2, 1]))])
    '+2 *2 */2'

Fork and join with labels:

    >>> dagtext([(b'n', (0, [-1])), (b'l', (0, b'f')), (b'n', (1, [0])),
    ...          (b'l', (1, b'p2')), (b'n', (2, [0])), (b'n', (3, [2, 1]))])
    '+1 :f +1 :p2 *f */p2'

Annotations:

    >>> dagtext([(b'n', (0, [-1])), (b'a', b'ann'), (b'n', (1, [0]))])
    '+1 @ann +1'

    >>> dagtext([(b'n', (0, [-1])),
    ...          (b'a', b'my annotation'),
    ...          (b'n', (1, [0]))])
    '+1 @"my annotation" +1'

Commands:

    >>> dagtext([(b'n', (0, [-1])), (b'c', b'cmd'), (b'n', (1, [0]))])
    '+1 !cmd +1'

    >>> dagtext([(b'n', (0, [-1])),
    ...          (b'c', b'my command'),
    ...          (b'n', (1, [0]))])
    '+1 !"my command" +1'

    >>> dagtext([(b'n', (0, [-1])),
    ...          (b'C', b'my command line'),
    ...          (b'n', (1, [0]))])
    '+1 !!my command line\n+1'

Comments:

    >>> dagtext([(b'n', (0, [-1])), (b'#', b' comment'), (b'n', (1, [0]))])
    '+1 # comment\n+1'

    >>> dagtext([])
    ''

Combining parsedag and dagtext:

    >>> dagtext(parsedag(b'+1 :f +1 :p2 *f */p2'))
    '+1 :f +1 :p2 *f */p2'

rZ   )r\   rr   )Údagrn   ri   rg   rh   rj   rf   ro   s           r   Údagtextru   ¢  s6   € ðn �:‰:ÜØØØØØØØØó		
óð r   )TFFFFFéF   )Ú
__future__r   rT   r   Úi18nr   Ú r   r   Úutilsr   rQ   rr   ru   r    r   r   Ú<module>r{      s_   ðõ #ã 	Û å ÷õ òJð^ ØØØØØØô}ðD ØØØØØØõbr   