a
    %0_?                     @   s6  d Z ddlmZ ddlmZ ddl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mZ dZi ZeeZe ZG dd dejZe Zed	d
dddedfgedejdd)ddZeddddd Zeddddd Zeddd Z edddd d! Z!d"d# Z"d*d%d&Z#d'd( Z$e$  dS )+aj  unified command to show various repository information (EXPERIMENTAL)

This extension provides the :hg:`show` command, which provides a central
command for displaying commonly-accessed repository data and views of that
data.

The following config options can influence operation.

``commands``
------------

``show.aliasprefix``
   List of strings that will register aliases for views. e.g. ``s`` will
   effectively set config options ``alias.s<view> = show <view>`` for all
   views. i.e. `hg swork` would execute `hg show work`.

   Aliases that would conflict with existing registrations will not be
   performed.
    )absolute_import)_)nullrev)cmdutilcommandsdestutilerror	formattergraphmod
logcmdutilphasespycompat	registrarrevset
revsetlangscmutils   ships-with-hg-corec                   @   s   e Zd ZdZdZdddZdS )showcmdfuncz;Register a function to be invoked for an `hg show <thing>`.s   %s -- %sNc                 C   s   ||_ ||_dS )a  Called with decorator arguments to register a show view.

        ``name`` is the sub-command name.

        ``func`` is the function being decorated.

        ``fmtopic`` is the topic in the style that will be rendered for
        this view.

        ``csettopic`` is the topic in the style to be used for a changeset
        printer.

        If ``fmtopic`` is specified, the view function will receive a
        formatter instance. If ``csettopic`` is specified, the view
        function will receive a changeset printer.
        N)_fmtopic
_csettopic)selfnamefuncfmtopic	csettopic r   ,/usr/lib/python3/dist-packages/hgext/show.py_extrasetupB   s    zshowcmdfunc._extrasetup)NN)__name__
__module____qualname____doc__Z
_docformatr   r   r   r   r   r   <   s   r      show   T   template    s   display with templates   TEMPLATEs   VIEW)ZhelpcategoryNc                 C   sx  |   r&|s&td}tjtd|dtj}|s| d | td | d t|	 D ]\}}| dt
|j  q^| d tjtdtd	d||vrtjtd
| tdd|pd}|| }| d |jr,d|j }	| |	d|i}
|| ||
W  d   S 1 s 0    Y  nH|jrjd|j }t| ||}tj| ||dd}|| ||S || |S dS )a  show various repository information

    A requested view of repository data is displayed.

    If no view is requested, the list of available views is shown and the
    command aborts.

    .. note::

       There are no backwards compatibility guarantees for the output of this
       command. Output may change in any future Mercurial release.

       Consumers wanting stable command output should specify a template via
       ``-T/--template``.

    List of available views:
    s2   invoke with -T/--template to control output formats%   must specify a template in plain mode)hintr!   s   available views:
   
s   %s
s   no view requesteds#   use "hg show VIEW" to choose a views   unknown view: %ss$   run "hg show" to see available viewss   show%sr#   NT)Zbuffered)Zplainr   r   Abortshowview_tableZpagerwritesorteditemsr   Zsysbytesr    r   r	   r   Zlookuptemplater   Zchangesettemplater)uirepoviewtemplater%   Zviewsr   r   fnr   fmrefspec	displayerr   r   r   showZ   sF    





.
r6   s	   bookmarks)r   c           
         s    j }t|s,t|tjs(| td dS  fdd| D } j}t	dd |D }t
 |}t| D ]\\}}	|  |j |	 d |dd	| |d
||	||	 |j||k||d qpdS )z(bookmarks and their associated changesets   (no bookmarks set)
Nc                    s   g | ]} |   qS r   )rev).0noder.   r   r   
<listcomp>   r$   z!showbookmarks.<locals>.<listcomp>c                 s   s   | ]}t |V  qd S N)len)r8   br   r   r   	<genexpr>   r$   z showbookmarks.<locals>.<genexpr>ctxs   bookmarks   %s   node)activeZlongestbookmarklennodelen)Z
_bookmarksr=   
isinstancer	   Zjsonformatterr*   r   valuesZ_activebookmarkmaxlongestshortestr+   r,   Z	startitemcontextZhexfuncdata)
r-   r.   r2   ZmarksrevsrC   ZlongestnamerD   Zbmr9   r   r:   r   showbookmarks   s"    

rL   s   stack)r   c              	      s  |d }|  tkr"ttd| tjkrB| td dS t	
| |}d}|du rn|  }|  h}nt|d|}|| }|   tkr| }d}|j}	|	|  gD ]D}
||
 }| tjkr q||   t| dkrd} qqtt|dd	}|r,t|d
|  |}nt }t||B |hB }t||}ztdtj d}W n  tjtjfy   d}Y n0 t| |}tj| d| |dfdd}|ri  |D ]*}|	j|g|  d}tt| |< q||d  }t| fdddd}t |D ]\}}
||
 }|r8| d n
| d | !d |j"||d |#| | d |r| d n
| d | d | jtd |
  dd |r| d  | jd!||||f d"d | d# q| d$ | jtd%d&d |r2| d' | jtd(d&d | d) |D ]n}
||
 }|
|  krTd*nd+}|rj| d n
| d | |d |j"||d |#| | d q6|r|r| d, n
| d- | jtd.dd&d | !d |j"||d |#| | d dS )/zcurrent line of work   .s;   stack view only available when there is a working directorysA   (empty stack; working directory parent is a published changeset)
Ns   %d::.F   T)reverses    heads(%d::) - %ld - not public()s   rebases   {shortest(node, %d)})Z	resourcesc                    s     | |  dS )N)s   ctxrB   )Zrenderdefaulthexr@   )shortesttmplr   r   shortest!  s    zshowstack.<locals>.shortest)Zstoprevc                    s    |  S r<   r   )x)revdistancer   r   <lambda>4  r$   zshowstack.<locals>.<lambda>)keyrO   s   : s     s   o  )rD   r&   s   :/s    /s       (s   %d commits aheads   stack.commitdistance)Zlabels   ; s   hg rebase --source %s --dest %ss   stack.rebasehints   )
s   :
:    s   (stack head)
s   stack.labels    \ /  s   (multiple children)
s     |
   @   os   :/   s    /   s   (stack base))$r7   r   r   r'   r   Zphaser   Zpublicr*   r   Z	stackbasesetrK   Zp1	changelogZdescendantsaddr=   Zchildrenlistr+   rH   r   Zfindcmdr   tableZAmbiguousCommandZUnknownCommandr	   ZtemplateresourcesZmaketemplater	ancestors	enumerateZwritenoi18nr6   flush)r-   r.   r5   ZwdirctxZbaserevZbasectxZ	stackrevsrA   Zbranchpointattipclr7   ZnewheadsZallrevsrD   Z
haverebaseZtresrR   headr_   Z	sourcectxZsortedheadsiZsymbolr   )rU   rQ   r   	showstack   s    


















re   s!   _underway([commitage[, headage]])c           	      C   s   t |dd}d|vrd |d< d|vr.d |d< d}g }|d r`|d7 }|t|d td | j|g|R  }t |}|| d|7 }d	}g }|d r|d7 }|t|d td
 || j|g|R  7 }| d  }|t	kr|t |h7 }||@ S )Ns   underways   commitage headages	   commitages   headages   not public() and not obsolete()s    and date(%s)s   commitage requires a strings   parents(%ld)s   head() and not closed()s   headage requires a stringrM   )
r   Zgetargsdictappendr   Z	getstringr   rK   Zbasesetr7   r   )	r.   ZsubsetrT   argsZrsZrsargsZmutableZrelevantZwdirrevr   r   r   underwayrevset  s>    
rh   s   workc                 C   sN   | d}t||}t||}| ddd tj| |||tjd|id dS )zchangesets that aren't finisheds   sort(_underway(), topo)s   experimentals   graphshortenTs   nodelen)ZpropsN)rK   rH   r
   Z	dagwalker	setconfigr   ZdisplaygraphZ
asciiedges)r-   r.   r5   rK   rD   Zrevdagr   r   r   showwork  s    

rj   c                 C   st   |  ddD ]b}tjD ]V}d||f }tj|tjdd\}}||v rFq| d|d rVq| jd|d| dd	 qqd S )
Ns   commandss   show.aliasprefixs   %s%sT)stricts   aliass   show %sr!   )source)	Z
configlistr(   r)   r   Zfindpossibler   r^   Zconfigri   )r-   prefixr/   r   ZchoiceZallcommandsr   r   r   extsetup  s    

rn      c                    s(   |sS j  t fdd|D S )a  Return the length of the longest shortest node to identify revisions.

    The result of this function can be used with the ``shortest()`` template
    function to ensure that a value is unique and unambiguous for a given
    set of nodes.

    The number of revisions in the repo is taken into account to prevent
    a numeric node prefix from conflicting with an integer revision number.
    If we fail to do this, a value of e.g. ``10023`` could mean either
    revision 10023 or node ``10023abc...``.
    c                 3   s&   | ]}t t |V  qd S r<   )r=   r   Zshortesthexnodeidprefixr9   )r8   rrb   minlenr.   r   r   r?     s   z"longestshortest.<locals>.<genexpr>)r[   rG   )r.   rK   rr   r   rq   r   rH     s    rH   c               	   C   s   t tttj } g }ttj D ]*}|dt	|
| tj| jf  q&t	dtd d j t	d|f td d _d S )Nz    %s   %ss   %s

%s
    r!   r   s   

)rG   mapr=   r(   r)   keysr+   rf   r   ZsysstrljustZ_origdoccmdtabler    rstripjoin)ZlongestentriesrW   r   r   r   _updatedocstring   s    
rz   )NN)ro   )%r    Z
__future__r   Zmercurial.i18nr   Zmercurial.noder   Z	mercurialr   r   r   r   r	   r
   r   r   r   r   r   r   r   Z
testedwithrv   ZcommandZrevsetpredicateZ_funcregistrarbaser   r(   ZCATEGORY_CHANGE_NAVIGATIONr6   rL   re   rh   rj   rn   rH   rz   r   r   r   r   <module>   s>   <
C



 ?
8


