a
    &0_т                     @   s:  d dl mZ ddlmZ ddlmZmZmZmZ ddl	m
Z
mZmZmZmZmZmZmZmZmZmZmZ ddlmZ ejZejZejZejZejZejZddd	Zd
d ZdZ e d e ddddZ!e!d e!d< i Z"e#e"Z#e#ddhddd Z$e#dddhddd Z%e#ddhddd Z&e#d dhdd!d" Z'e#d#ddhdd$d% Z(e#d&dhdd'd( Z)e#d)ddhdd*d+ Z*e#d,ddhdd-d. Z+e#d/dhdd0d1 Z,e#d2dhdd3d4 Z-e#d5d6dhdd7d8 Z.e#d9d6hdd:d; Z/e#d<dhdd=d> Z0dd@dAZ1ddBdCZ2e#dDh dEddFdG Z3e#dHdIhddJdK Z4e#dLddIhddMdN Z5e#dOddIhddPdQ Z6e#dRddIhddSdT Z7e#dUdhddVdW Z8e#dXh dYddZd[ Z9d\d] Z:d^d_ Z;d`da Z<e#dbdcdddde Z=e#dfdcddgdh Z>e#dih dYddjdk Z?dldm Z@e#dnh dYddodp ZAe#dqh dYddrds ZBdtdu ZCddheC_De#dvddhddwdx ZEe#dyh dzdd{d| ZFd}d~ ZGe#dddhddd ZHe#dddhddd ZIe#ddhddd ZJe#ddhddd ZKe#ddhddd ZLe#ddhddd ZMe#dddhddd ZNe#ddhddd ZOe#ddhddd ZPe#dh dddd ZQe#dddhddd ZRe#dddhddd ZSe#ddhddd ZTe#ddhddd ZUe#ddhddd ZVe#ddhddd ZWe#ddhddd ZXe#ddhddd ZYe#dddhddd ZZe#ddhddd Z[e#ddhddd Z\e#ddhddd Z]e#ddhdddń Z^e#dddhdddȄ Z_e#dd6hddd˄ Z`e#ddhddd΄ Zae#ddhdddф Zbe#dd6hdddԄ Zce#dddhdddׄ Zdddل Zee"f ZgdS )    )absolute_import   )_)hexnullidwdiridwdirrev)diffutilencodingerrorhbisecti18nobsutilpatchpycompat	registrarscmutiltemplateutilutil)
stringutilNc                    s  |  |d|  |d |  |d}d}|durL|d| 7 }t|d ntj||vrndd	d	d
gfi||< ||   }|g}|r| }|v rq|  fdd  D }|r  d	 d	dd t	|D f|< qzfdd 
 D }t|dkrX|d	 d |d d kr6t|\}	}
}n  fdd}t||d\}	}
}n|d	 \}	}
}W n: ty   || |dd  
 D  Y qY n0 |	|
d |f|< q| S )z8return date, distance and name for the latest tag of rev   repo   ctx   caches
   latesttagsN   -   r   s   nullc                    s0   g | ](} |r |d kr |r|qS )s   local)Ztagtype.0t)matchrepo 6/usr/lib/python3/dist-packages/mercurial/templatekw.py
<listcomp>D   s    z!getlatesttags.<locals>.<listcomp>c                 S   s   g | ]}|qS r!   r!   r   r!   r!   r"   r#   J       c                    s   g | ]} |   qS r!   revr   p
latesttagsr!   r"   r#   M   r$   r   c                    sn   | d d }   d u rFdd   D }d||}t|d }nd   |}t|}| | d gS )Nr   r   c                 S   s   g | ]}|  qS r!   r%   )r   cr!   r!   r"   r#   Y   r$   z.getlatesttags.<locals>.key.<locals>.<listcomp>   only(%ld, %s)r   s   only(%d, %s))r&   parentsrevslen)xtagprevsZchangesZchangessincetag)ctxr    r!   r"   keyU   s    zgetlatesttags.<locals>.key)r4   c                 s   s   | ]}|  V  qd S Nr%   r'   r!   r!   r"   	<genexpr>i   r$   z getlatesttags.<locals>.<genexpr>)resourcer   Zstringmatcherr   alwaysr&   poptagsdatesortedr-   r/   maxKeyErrorappendextend)contextmappingpatterncacheZ	cachenamer&   Ztodor:   ZptagsZpdateZpdistZptagr4   r!   )r3   r*   r   r    r"   getlatesttags*   sL    $

rE   c                  C   s6   t j} | d}ttdd | D t|dS )z"Return a dict of log column labelss  bookmark:    %s
branch:      %s
changeset:   %s
copies:      %s
date:        %s
extra:       %s=%s
files+:      %s
files-:      %s
files:       %s
instability: %s
manifest:    %s
obsolete:    %s
parent:      %s
phase:       %s
summary:     %s
tag:         %s
user:        %s
c                 S   s   g | ]}| d dd qS )   :r   r   )split)r   sr!   r!   r"   r#      r$   z!getlogcolumns.<locals>.<listcomp>T)r   identitydictzip
splitlinesr   r   )r   columnsr!   r!   r"   getlogcolumnso   s    rN   s   {rev}:{node|formatnode}    s   {name} ({source})s   {key}={value}s   {key}={value|stringescape})   parent   manifest	   file_copy   envvar   extrarR   s   filecopys   authorr   )Zrequiresc                 C   s
   t | |S )zAlias for ``{user}``)showuserrA   rB   r!   r!   r"   
showauthor   s    rW   s   bisectr   c                 C   s(   |  |d}|  |d}t|| S )z'String. The changeset bisection status.r   r   )r7   r   Zlabelnode)rA   rB   r    r3   r!   r!   r"   
showbisect   s    rY      branchc                 C   s   |  |d}| S )zMString. The name of the branch on which the changeset was
    committed.
    r   )r7   branchrA   rB   r3   r!   r!   r"   
showbranch   s    r]      branchesc                 C   sB   |  |d}| }|dkr0t| |d|gddS t| |dg ddS )zList of strings. The name of the branch on which the
    changeset was committed. Will be empty if the branch name was
    default. (DEPRECATED)
    r   s   defaultrZ   r^   Zplural)r7   r[   
compatlist)rA   rB   r3   r[   r!   r!   r"   showbranches   s    ra   s	   bookmarksc                    sP   |  |d}|  |d}| }|j  fdd}t| |d|}t|||tjS )z{List of strings. Any bookmarks associated with the
    changeset. Also sets 'active', the name of the active bookmark.
    r   r   c                    s   |   dS )N)   bookmarks   actives   currentr!   vactiver!   r"   <lambda>   r$   zshowbookmarks.<locals>.<lambda>rb   )r7   	bookmarks_activebookmark_showcompatlist_hybridr   rI   )rA   rB   r    r3   rh   makemapfr!   re   r"   showbookmarks   s    rn      childrenc                 C   s0   |  |d}dd | D }t| |d|ddS )z/List of strings. The children of the changeset.r   c                 S   s   g | ]}d |  |f qS )s   %d:%sr%   )r   Zcctxr!   r!   r"   r#      r$   z showchildren.<locals>.<listcomp>ro   s   child)element)r7   Zchildrenr`   )rA   rB   r3   Z	childrevsr!   r!   r"   showchildren   s
    
rq   s   currentbookmarkc                 C   s
   t | |S )zUString. The active bookmark, if it is associated with the changeset.
    (DEPRECATED))showactivebookmarkrV   r!   r!   r"   showcurrentbookmark   s    rs   s   activebookmarkc                 C   s6   |  |d}|  |d}|j}|r2|| v r2|S dS )zDString. The active bookmark, if it is associated with the changeset.r   r   r$   )r7   ri   rh   )rA   rB   r    r3   rf   r!   r!   r"   rr      s    rr   s   datec                 C   s   |  |d}tj| ddS )z<Date information. The date when the changeset was committed.r   s   %d.0%d)Zshowfmt)r7   r   r;   r\   r!   r!   r"   showdate   s    rt   s   descc                 C   sZ   |  |d}| }t|tjr4tt| S t|tjrNt| S | S dS )z.String. The text of the changeset description.r   N)	r7   Zdescription
isinstancer
   ZlocalstrZtolocalZ	fromlocalstripZsafelocalstr)rA   rB   r3   rH   r!   r!   r"   showdescription   s    rw   s   diffstat   uic                 C   sj   |  |d}|  |d}t|ddi}|j|d}tt|}t|\}}}	}
}dt	||	|
f S )ziString. Statistics of changes with the following format:
    "modified files: +added/-removed lines"
    rx   r   s   noprefixF)Zoptss   %d: +%d/-%d)
r7   r	   Zdiffalloptsdiffr   Zdiffstatdatar   Z	iterlinesZdiffstatsumr/   )rA   rB   uir3   Zdiffoptsry   ZstatsZmaxnameZmaxtotalZaddsZremovesZbinaryr!   r!   r"   showdiffstat	  s    r{      envvarsc                    sB   |  |d}|  t fddt D  t| |d ddS )z5A dictionary of environment variables. (EXPERIMENTAL)rx   c                 3   s   | ]}| | fV  qd S r5   r!   r   kenvr!   r"   r6     r$   zshowenvvars.<locals>.<genexpr>rS   r|   r_   )r7   Zexportableenvironr   sortdictr<   
compatdictrA   rB   rz   r!   r   r"   showenvvars  s    r      extrasc                    sv   |  |d}|  t fddt D   fddfdd D }t| |d|d	d
}t|  fddS )zRList of dicts with key, value entries of the 'extras'
    field of this changeset.r   c                 3   s   | ]}| | fV  qd S r5   r!   r}   extrasr!   r"   r6   &  r$   zshowextras.<locals>.<genexpr>c                    s   |  |  dS )N)s   keys   valuer!   r~   r   r!   r"   rg   '  r$   zshowextras.<locals>.<lambda>c                    s   g | ]} |qS r!   r!   r}   )rl   r!   r"   r#   (  r$   zshowextras.<locals>.<listcomp>rT   r   r_   c                    s   d| t  |  f S Ns   %s=%s)r   Z	escapestrr   r   r!   r"   rg   .  r$   )r7   Zextrar   r   r<   rj   rk   )rA   rB   r3   r+   rm   r!   )r   rl   r"   
showextras   s    
r   Fc                 C   sZ   |  |d}|  |d}d|vs,|d |k rR| j||||d}||d< ||d< |d S )Nr      revcaches
   filestatus   filestatusall)ZlistignoredZ	listcleanZlistunknown)r7   p1Zstatus)rA   rB   listallr3   revcachestatr!   r!   r"   _getfilestatus2  s    r   c                    st   |  |d}d|vs |d |k rlt| ||d}i  |d< }ttd|D ] \ }| fdd|D  qJ|d S )Nr   s   filestatusmapr   r   s   MAR!?ICc                 3   s   | ]}| fV  qd S r5   r!   )r   rm   charr!   r"   r6   D  r$   z$_getfilestatusmap.<locals>.<genexpr>)r7   r   rK   r   Ziterbytestrupdate)rA   rB   r   r   r   statmapfilesr!   r   r"   _getfilestatusmap>  s    r   s   file_copies>   r   r   r   r   c                 C   st   |  |d}|  |d}|  |d}|  |dd}|du rdd|vrTt||d< |d }||}t| |d|S )	zLList of strings. Files copied in this changeset with
    their sources.
    r   r   r   r      copiesNs	   getcopiesrR   )r7   getr   Zgetcopiesfnr   compatfilecopiesdict)rA   rB   r    r3   rD   copiesZ	getcopiesr!   r!   r"   showfilecopiesH  s    r   s   file_copies_switchr   c                 C   s&   |  |ddpg }t| |d|S )z^List of strings. Like "file_copies" but displayed
    only if the --copied switch is set.
    r   r   rR   )r7   r   r   r   )rA   rB   r   r!   r!   r"   showfilecopiesswitch`  s    r   s	   file_addsc                 C   s    |  |d}t| |d| S )z/List of strings. Files added by this changeset.r   s   file_add)r7   r   compatfileslistZ
filesaddedr\   r!   r!   r"   showfileaddsk  s    r   s	   file_delsc                 C   s    |  |d}t| |d| S )z1List of strings. Files removed by this changeset.r   s   file_del)r7   r   r   Zfilesremovedr\   r!   r!   r"   showfiledelst  s    r   s	   file_modsc                 C   s    |  |d}t| |d| S )z2List of strings. Files modified by this changeset.r   s   file_mod)r7   r   r   Zfilesmodifiedr\   r!   r!   r"   showfilemods}  s    r   s   filesc                 C   s    |  |d}t| |d| S )zRList of strings. All files modified, added, or removed by this
    changeset.
    r   s   file)r7   r   r   r   r\   r!   r!   r"   	showfiles  s    r   s	   graphnode>   r   r   r   c                 C   s0   |  |d}|  |d}|  |d}t|||S )zUString. The character representing the changeset node in an ASCII
    revision graph.r   r   r   )r7   getgraphnode)rA   rB   r    r3   rD   r!   r!   r"   showgraphnode  s    r   c                 C   s   t | ||pt|S r5   )getgraphnodecurrentgetgraphnodesymbol)r    r3   rD   r!   r!   r"   r     s    r   c                 C   s   | j  }|d tkr"|d d }| |v r2dS |d}|d u r~ddlm} |j| }| rr|j	|j
f}nd}||d< | |v rdS dS d S )Nr      @s   merge_nodes)
mergestater!      %r$   )Zdirstater-   r   rX   r    r   readZunresolvedcountZlocalother)r    r3   rD   ZwpnodesZmerge_nodesZmergestatemodr   r!   r!   r"   r     s     

r   c                 C   s,   |   rdS |  rdS |  r$dS dS d S )N   x   *   _   o)obsoleteZ
isunstableZclosesbranchr3   r!   r!   r"   r     s    r   s
   graphwidthr!   c                 C   s   dS )z?Integer. The width of the graph drawn by 'log --graph' or zero.r   r!   rV   r!   r!   r"   showgraphwidth  s    r   s   indexc                 C   s   t tddS )z7Integer. The current iteration of the loop. (0 indexed)s   can't use index in this contextN)r   ZAbortr   rV   r!   r!   r"   	showindex  s    r   	   latesttagc                 C   s   t | |dS )zList of strings. The global tags on the most recent globally
    tagged ancestor of this changeset.  If no such tags exist, the list
    consists of the single string "null".
    N)showlatesttagsrV   r!   r!   r"   showlatesttag  s    r   c                    sB   t | ||  fdd} d }t| |d|dd}t|||tjS )z4helper method for the latesttag keyword and functionc                    s   t  d | | dS )Nr   )s   changess   distancer      tag)_showchangessincetagrc   r)   r!   r"   rg     s
    z showlatesttags.<locals>.<lambda>r   r   rF   )Z	separator)rE   rj   rk   r   rI   )rA   rB   rC   rl   r:   rm   r!   r)   r"   r     s
    r   s   latesttagdistancec                 C   s   t | |d S )z(Integer. Longest path to the latest tag.r   )rE   rV   r!   r!   r"   showlatesttagdistance  s    r   s   changessincelatesttagc                 C   s,   t | |d d }| |d|i}t| |S )z-Integer. All ancestors not in the latest tag.r   r   r   )rE   
overlaymapr   )rA   rB   r1   r!   r!   r"   showchangessincelatesttag  s    r   c                 C   sj   |  |d}|  |d}d}| g}| |d}| d u rTd}dd | D }t|d||| S )	Nr   r   r   r   r   c                 S   s   g | ]}|  qS r!   r%   r'   r!   r!   r"   r#     r$   z(_showchangessincetag.<locals>.<listcomp>r,   )r7   r&   Zsymbolr-   r/   r.   )rA   rB   r    r3   offsetr.   r1   r!   r!   r"   r     s    
r   rQ   c                    s~   |  |d}|  |d}| }|d u r2t}tn|j|t| | | d}| d|}t	
|d | fddS )Nr   r      rev   noderQ   c                    s
    dS )Nr   r!   r0   ZmhexZmrevr!   r"   rg     r$   zshowmanifest.<locals>.<lambda>)r7   Zmanifestnoder   r   Zmanifestlogr&   r   r   Zprocessr   Z
hybriditem)rA   rB   r    r3   Zmnoderm   r!   r   r"   showmanifest
  s    r   s   obsfate>   rx   r   r   c                 C   sl   t | |}| |d}| |d}g }|| |D ]*}t|||d |d tj}|| q2t| |d|S )Nrx   r   
   successors   markerss   fate)	showsuccsandmarkersr7   Ztovaluer   Zobsfateprinterr   formatchangeidr?   r`   )rA   rB   Zsuccsandmarkersrz   r    valuesr0   rd   r!   r!   r"   showobsfate  s    
r   c                 C   sT   |  |d}|  |d}|j|}|du r0dS ||| }t| ||j||dS )z<helper method to generate a template keyword for a namespacer   r   Nr_   )r7   namesr   rX   r`   templatename)rA   rB   	namespacer    r3   nsr   r!   r!   r"   	shownames1  s    r   s
   namespacesc           	         s   |  |d|  |d}t  dd }tjD ]>\}}|| }t| |d|}t||||tj	 |< q4t| |dt
 } fdd}t| |tj	S )	zBDict of lists. Names attached to this changeset per
    namespace.r   r   c                    s    fddS )Nc                    s   d|  j | iS )N   name)r   rc   r   r!   r"   rg   K  r$   z5shownamespaces.<locals>.makensmapfn.<locals>.<lambda>r!   r   r!   r   r"   makensmapfnI  s    z#shownamespaces.<locals>.makensmapfnr   	   namespacec                    s"   |  |  j |  jj |  jdS )N)r   s   namess   builtins	   colorname)r   ZbuiltinZ	colornamer   Z
namespacesr    r!   r"   rl   T  s
    

zshownamespaces.<locals>.makemap)r7   r   r   r   	iteritemsr   rX   rj   rk   rI   list)	rA   rB   r3   r   r~   r   r   rm   rl   r!   r   r"   shownamespaces@  s    r   s   negrevc                 C   s@   |  |d}| }|du s$|dk r(dS |  |d}|t| S )zmInteger. The repository-local changeset negative revision number,
    which counts in the opposite direction.r   Nr   r   )r7   r&   r/   )rA   rB   r3   r&   r    r!   r!   r"   
shownegrev_  s    r   r   c                 C   s   |  |d}| S )zUString. The changeset identification hash, as a 40 hexadecimal
    digit string.
    r   )r7   r   r\   r!   r!   r"   shownodek  s    r      obsoletec                 C   s   |  |d}| rdS dS )z9String. Whether the changeset is obsolete. (EXPERIMENTAL)r   r   r$   )r7   r   r\   r!   r!   r"   showobsoletet  s    r      path   fctxc                 C   s   |  |d}| S )zDString. Repository-absolute path of the current file. (EXPERIMENTAL)r   )r7   pathrA   rB   Zfctxr!   r!   r"   showpath}  s    r   s   peerurlsc                    sT   |  |d}|jj tdd tt D  fdd}td|fddS )	zcA dictionary of repository locations defined in the [paths] section
    of your configuration file.r   c                 s   s   | ]\}}||j fV  qd S r5   )rawloc)r   r~   r(   r!   r!   r"   r6     s   zshowpeerurls.<locals>.<genexpr>c                    s8    |  }| |j d}|dd tt|jD  |S )N)r   s   urlc                 s   s   | ]\}}||fV  qd S r5   r!   )r   ord   r!   r!   r"   r6     r$   z0showpeerurls.<locals>.makemap.<locals>.<genexpr>)r   r   r<   r   r   Z
suboptions)r~   r(   d)pathsr!   r"   rl     s     zshowpeerurls.<locals>.makemapNc                    s   d|  |  f S r   r!   r   )urlsr!   r"   rg     r$   zshowpeerurls.<locals>.<lambda>)	r7   rz   r   r   r   r<   r   r   rk   )rA   rB   r    rl   r!   )r   r   r"   showpeerurls  s    
r   s   predecessorsc                    sV   |  |d |  |d}tt | }tt|}td| fdd fddS )zDReturns the list of the closest visible predecessors. (EXPERIMENTAL)r   r   Nc                    s   d |  iS Nr   r!   r   r    r!   r"   rg     r$   z"showpredecessors.<locals>.<lambda>c                    s   t  |  S r5   r   r   r   r   r!   r"   rg     r$   )	r7   r<   r   ZclosestpredecessorsrX   r   Zmaplistr   rk   )rA   rB   r3   Zpredecessorsr!   r   r"   showpredecessors  s    

r   s   reporootc                 C   s   |  |d}|jS )z5String. The root directory of the current repository.r   )r7   root)rA   rB   r    r!   r!   r"   showreporoot  s    r   s   sizec                 C   s   |  |d}| S )z:Integer. Size of the current file in bytes. (EXPERIMENTAL)r   )r7   sizer   r!   r!   r"   showsize  s    r   s   status>   r   r   r   c                 C   sN   t | |d}t | ||}|s$dS t| |}||vrDt| |dd}||S )z7String. Status code of the current file. (EXPERIMENTAL)r   NTr   )r   Z	runsymbol	stringifyr   r   )rA   rB   r   r   r!   r!   r"   
showstatus  s    
r   s   successorssetsc                    s     d  d}g }| rxtj| dd}dd |D }|D ],}td|fdd	fd
d	}|| qJ fddfdd}t|||dd	 tjS )zReturns a string of sets of successors for a changectx. Format used
    is: [ctx1, ctx2], [ctx3] if ctx has been split into ctx1 and ctx2
    while also diverged into ctx3. (EXPERIMENTAL)r   r   T)Zclosestc                 S   s   g | ]}d d |D qS )c                 S   s   g | ]}t |qS r!   r   r   nr!   r!   r"   r#     r$   z1showsuccessorssets.<locals>.<listcomp>.<listcomp>r!   )r   ssr!   r!   r"   r#     r$   z&showsuccessorssets.<locals>.<listcomp>Nc                    s   d |  iS r   r!   r   r   r!   r"   rg     r$   z$showsuccessorssets.<locals>.<lambda>c                    s   t  |  S r5   r   r   r   r!   r"   rg     r$   c                    s   t  | S r5   )r   r   )r   rV   r!   r"   render  s    z"showsuccessorssets.<locals>.renderc                 3   s   d  fdd| D V  d S )Ns   ; c                 3   s   | ]} |V  qd S r5   r!   )r   r   r   r!   r"   r6     r$   z2showsuccessorssets.<locals>.gen.<locals>.<genexpr>)join)datar   r!   r"   gen  s    zshowsuccessorssets.<locals>.genc                 S   s   d| iS )Ns   successorsetr!   r   r!   r!   r"   rg     r$   )	r7   r   r   ZsuccessorssetsrX   rk   r?   r   rI   )rA   rB   r3   r   Zssetsr   hr   r!   )rA   rB   r   r    r"   showsuccessorssets  s&    

r   s   succsandmarkersc                    s  |  |d |  |d}t |}|du r0g }g }|D ]}|d }dd |D }td| fdd fd	d}g }|d
 D ]|}t|d }	tdd |d D }
d}|d durtdd |d D }|	|
f|dd  |f |dd  }|| q||||d q8t|S )zReturns a list of dict for each final successor of ctx. The dict
    contains successors node id in "successors" keys and the list of
    obs-markers from ctx to the set of successors in "markers".
    (EXPERIMENTAL)
    r   r   Nr   c                 S   s   g | ]}t |qS r!   r   r   r!   r!   r"   r#     r$   z'showsuccsandmarkers.<locals>.<listcomp>c                    s   d |  iS r   r!   r   r   r!   r"   rg     r$   z%showsuccsandmarkers.<locals>.<lambda>c                    s   t  |  S r5   r   r   r   r!   r"   rg      r$   r   r   c                 s   s   | ]}t |V  qd S r5   r   r   r!   r!   r"   r6     r$   z&showsuccsandmarkers.<locals>.<genexpr>r      c                 s   s   | ]}t |V  qd S r5   r   r   r!   r!   r"   r6   
  r$   r      )r   r   )	r7   r   Zsuccessorsandmarkersrk   r   tupler?   r   mappinglist)rA   rB   r3   r   r   iZ
successorsZfinalmarkersmZhexprecZhexsucsZ
hexparentsZ	newmarkerr!   r   r"   r     s4    

&r   s   p1c                 C   s"   |  |d}tjd| itdS )zChangeset. The changeset's first parent. ``{p1.rev}`` for the revision
    number, and ``{p1.node}`` for the identification hash.r   tmpl)r7   r   mappingdictr   _changeidtmplr\   r!   r!   r"   showp1  s    r  s   p2c                 C   s"   |  |d}tjd| itdS )zChangeset. The changeset's second parent. ``{p2.rev}`` for the revision
    number, and ``{p2.node}`` for the identification hash.r   r  )r7   r   r  p2r  r\   r!   r!   r"   showp2  s    r  s   p1revc                 C   s   |  |d}|  S )zInteger. The repository-local revision number of the changeset's
    first parent, or -1 if the changeset has no parents. (DEPRECATED)r   )r7   r   r&   r\   r!   r!   r"   	showp1rev#  s    r	  s   p2revc                 C   s   |  |d}|  S )zInteger. The repository-local revision number of the changeset's
    second parent, or -1 if the changeset has no second parent. (DEPRECATED)r   )r7   r  r&   r\   r!   r!   r"   	showp2rev+  s    r
  s   p1nodec                 C   s   |  |d}|  S )zString. The identification hash of the changeset's first parent,
    as a 40 digit hexadecimal string. If the changeset has no parents, all
    digits are 0. (DEPRECATED)r   )r7   r   r   r\   r!   r!   r"   
showp1node3  s    r  s   p2nodec                 C   s   |  |d}|  S )zString. The identification hash of the changeset's second
    parent, as a 40 digit hexadecimal string. If the changeset has no second
    parent, all digits are 0. (DEPRECATED)r   )r7   r  r   r\   r!   r!   r"   
showp2node<  s    r  s   parentsc                    sp   |  |d |  |d}t |}dd |D }dd |D }t| |d|}t|| fdd fd	dtd
S )zList of strings. The parents of the changeset in "rev:node"
    format. If the changeset has only one "natural" parent (the predecessor
    revision) nothing is shown.r   r   c                 S   s   g | ]}|  qS r!   r%   r'   r!   r!   r"   r#   M  r$   zshowparents.<locals>.<listcomp>c                 S   s.   g | ]&}d |  fd| fd| fgqS )r   r      phase)r&   r   phasestrr'   r!   r!   r"   r#   N  s   rP   c                    s   d |  iS r   r!   r   r   r!   r"   rg   V  r$   zshowparents.<locals>.<lambda>c                    s   t  |  S r5   r   r   r   r!   r"   rg   W  r$   )Zkeytype)r7   r   Zmeaningfulparentsrj   rk   int)rA   rB   r3   Zpctxsr2   r-   rm   r!   r   r"   showparentsE  s    

r  r  c                 C   s   |  |d}| S )z!String. The changeset phase name.r   )r7   r  r\   r!   r!   r"   	showphase\  s    r  s   phaseidxc                 C   s   |  |d}| S )z.Integer. The changeset phase index. (ADVANCED)r   )r7   Zphaser\   r!   r!   r"   showphaseidxc  s    r  r   c                 C   s   |  |d}t|S )z8Integer. The repository-local changeset revision number.r   )r7   r   Zintrevr\   r!   r!   r"   showrevj  s    r  s   subreposc                 C   s   |  |d}|j}|s$t| |dg S | jp0i }g }|D ]&}||vsV|| || kr:|| q:|D ]}||vrf|| qft| |dt|S )z:List of strings. Updated subrepositories in the changeset.r   s   subrepo)r7   substater`   r   r?   r<   )rA   rB   r3   r  Z	psubstateZsubrepossubr!   r!   r"   showsubreposq  s    r     tagsc                 C   s   t | |dS )z8List of strings. Any tags associated with the changeset.r  )r   rV   r!   r!   r"   showtags  s    r  s	   termwidthc                 C   s   |  |d}| S )z+Integer. The width of the current terminal.rx   )r7   Z	termwidthr   r!   r!   r"   showtermwidth  s    r  s   userc                 C   s   |  |d}| S )z/String. The unmodified author of the changeset.r   )r7   userr\   r!   r!   r"   rU     s    rU      instabilitiesc                 C   s"   |  |d}t| |d| ddS )zYList of strings. Evolution instabilities affecting the changeset.
    (EXPERIMENTAL)
    r   s   instabilityr  r_   )r7   r`   Zinstabilitiesr\   r!   r!   r"   showinstabilities  s    r  s	   verbosityc                 C   s.   |  |d}|jrdS |jr dS |jr*dS dS )zOString. The current output verbosity in 'debug', 'quiet', 'verbose',
    or ''.rx   s   debugs   quiets   verboser$   )r7   Z	debugflagquietverboser   r!   r!   r"   showverbosity  s    r  s   whyunstablec                    s   |  |d|  |d}dd  t|}|D ]H}|dr0|d }tddd |D fd	d
 fdd
}||d< q0d}tj||ddS )zRList of dicts explaining all instabilities of a changeset.
    (EXPERIMENTAL)
    r   r   c                 S   s   dt | |  f S )Ns   %s (%s))r   r   r  r   r!   r!   r"   
formatnode  s    z#showwhyunstable.<locals>.formatnodes   divergentnodesNc                 S   s   g | ]}|  qS r!   r   )r   Zdnoder!   r!   r"   r#     r$   z#showwhyunstable.<locals>.<listcomp>c                    s   d |  iS r   r!   r   r   r!   r"   rg     r$   z!showwhyunstable.<locals>.<lambda>c                    s    |  S r5   r!   r   r   r    r!   r"   rg     r$   sM   {instability}:{if(divergentnodes, " ")}{divergentnodes} {reason} {node|short}   
)r  sep)r7   r   Zwhyunstabler   rk   r   r   )rA   rB   r3   entriesentryZdnodesZdnhybridr  r!   r!  r"   showwhyunstable  s"    


r&  c                 C   s"   t |jD ]\}}|t|< qdS )z6Load template keyword from specified registrarobj
    N)r   r   Z_tablekeywords)rz   ZextnameZregistrarobjnamefuncr!   r!   r"   loadkeyword  s    r*  )N)F)F)hZ
__future__r   r   r   rX   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   Zutilsr   Zhybridrk   Z
hybriddictZ
hybridlistr   r`   rj   rE   rN   r  Zdefaulttemplr'  ZtemplatekeywordrW   rY   r]   ra   rn   rq   rs   rr   rt   rw   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Z	_requiresr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r	  r
  r  r  r  r  r  r  r  r  r  rU   r  r  r&  r*  r   Zi18nfunctionsr!   r!   r!   r"   <module>   s&  8
E 


























	




















!
,
















