
    	^c?              
          d 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j        e          Z ej                    Z G d dej                  Z e            Z edd	d
dd ed          fg ed          ej                  d d            Z edd          d             Z edd          d             Z ed          d             Z edd          d             Zd Z d!dZ!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.
    )_)nullrev)cmdutilcommandsdestutilerror	formattergraphmod
logcmdutilphasespycompat	registrarrevset
revsetlangscmutils   ships-with-hg-corec                       e Zd ZdZdZddZdS )showcmdfuncz;Register a function to be invoked for an `hg show <thing>`.s   %s -- %sNc                 "    ||_         ||_        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	csettopics        ,/usr/lib/python3/dist-packages/hgext/show.py_extrasetupzshowcmdfunc._extrasetupA   s    "  #    NN)__name__
__module____qualname____doc__
_docformatr    r   r   r   r   ;   s5        EE J$ $ $ $ $ $r   r      show   T   templater   s   display with templates   TEMPLATEs   VIEW)helpcategoryNc                 |   |                                  r4|s2t          d          }t          j        t          d          |          t          j        }|s|                     d           |                     t          d                     |                     d           t          |	                                          D ]4\  }}|                     dt          j        |j                  z             5|                     d           t          j        t          d          t          d	                    ||vr3t          j        t          d
          |z  t          d                    |pd}||         }|                     d           |j        rId|j        z  }	|                     |	d|i          5 }
 || ||
          cddd           S # 1 swxY w Y   dS |j        rEd|j        z  }t          j        | ||          }t#          j        | ||d          } || ||          S  || |          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)buffered)plainr   r   Abortshowview_tablepagerwritesorteditemsr   sysbytesr#   r   r	   r   lookuptemplater   changesettemplater)uirepoviewtemplater+   viewsr   r   fnr   fmrefspec	displayers                 r   showrC   Y   s   > 
xxzz 
( 
FGGk677d
 
 
 	
 OE 

 	())***
 // 	@ 	@JD$HHWx0>>>????
k"##9::
 
 
 	
 5k!""T):;;
 
 
 	

 "7H	tBHHW	{ 
bk)\\'K#:;; 	$r2b$##	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$	 "-''C::1"dD4PPP	r"dI&&&r"d||s   ?GG Gs	   bookmarks)r   c                    j         }t          |          s>t          |t          j                  s"|                     t          d                     dS fd|                                D             }j        }t          d |D                       }t          |          }t          |                                          D ]\  }}	|                                 |                    |	                    |                    dd|           |                    d|                    |	          |                    |	                     |                    ||k    ||	           dS )
z(bookmarks and their associated changesets   (no bookmarks set)
Nc                 D    g | ]}|                                          S r%   )rev).0noder:   s     r   
<listcomp>z!showbookmarks.<locals>.<listcomp>   s'    888DJNN888r   c              3   4   K   | ]}t          |          V  d S N)len)rG   bs     r   	<genexpr>z showbookmarks.<locals>.<genexpr>   s(      ,,c!ff,,,,,,r   )ctxs   bookmarks   %s   node)activelongestbookmarklennodelen)
_bookmarksrL   
isinstancer	   jsonformatterr3   r   values_activebookmarkmaxlongestshortestr4   r5   	startitemcontexthexfuncdata)
r9   r:   r?   marksrevsrQ   longestnamerS   bmrH   s
    `        r   showbookmarksrc      sf    OEu::  "i566 	1HHQ.//0008888888D!F,,e,,,,,KdD))G5;;==)) 
 
D



tDz
"""
eR(((
"**T**BJJt,<,<===
<K 	 	
 	
 	
 	

 
r   s   stack)r   c                 t   |d         }|                                 t          k    r!t          j        t	          d                    |                                t          j        k    r$|                     t	          d                     dS t          j
        | |          }d}|*|                                 }|                                 h}n#t          |                    d|                    }||         }|                                                                 t          k    r|                                }d}|j        }	|	                    |                                 g          D ]~}
||
         }|                                t          j        k    r nQ|                    |                                            t#          |                                          dk    rd} nt'          t)          |d	                    }|r7t          |                    d
|                                 |                    }nt                      }t          |          |z  |hz  }t+          ||          }	 t-          j        dt0          j                   d}n## t          j        t          j        f$ r d}Y nw xY wt9          j        | |          }t9          j        | d|z  |          fd}|ri |D ]K}|	                    |g|                                           }t#          t'          |                    |<   L||d                  }t)          |fdd          }tA          |          D ]Z\  }}
||
         }|r|                     d           n|                     d           | !                    d           |"                    ||           |#                    |           |                     d           |r|                     d           n|                     d           |                     d           |                     t	          d          |
         z  d           |rC|                     d           |                     d ||           ||          fz  d            |                     d!           \|                     d"           |                     t	          d#          d$           |rN|                     d%           |                     t	          d&          d$           |                     d'           |D ]}
||
         }|
|                                 k    rd(nd)}|r|                     d           n|                     d           |                     |d           |"                    ||           |#                    |           |                     d           |r|r|                     d*           n|                     d+           |                     t	          d,          dd$           | !                    d           |"                    ||           |#                    |           |                     d           dS 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)})	resourcesc                 X                         | |                                 d          S )N)s   ctxrP   )renderdefaulthex)rO   shortesttmpls    r   shortestzshowstack.<locals>.shortest   s'    ))3*K*KLLLr   )stoprevc                     |          S rK   r%   )xrevdistances    r   <lambda>zshowstack.<locals>.<lambda>3  s    KN r   )keyrg   s   : s     s   o  )rS   r,   s   :/s    /s       (s   %d commits aheads   stack.commitdistance)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))$rF   r   r   r/   r   phaser   publicr3   r   	stackbasesetr`   p1	changelogdescendantsaddrL   childrenlistr4   rZ   r   findcmdr   tableAmbiguousCommandUnknownCommandr	   templateresourcesmaketemplater	ancestors	enumeratewritenoi18nrC   flush)r9   r:   rB   wdirctxbaserevbasectx	stackrevsrO   branchpointattipclrF   newheadsallrevsrS   
haverebasetresrm   headr   	sourcectxsortedheadsisymbolrr   rl   s                          @@r   	showstackr      s    4jG{{}}k% 
 
 	
 }}&-''
  	
 	
 	
 	
  T**GG++--[[]]O				(G4455	
w-C
vvxx||~~  &&(( 	B~~w{{}}o..  3i 99;;&-''Ecggii    s||~~""#E # VIt44455I  II3W[[]]I 
 
 55)nnx'7)3GdG,,G	8>222

"E$89   


 &r400D*
#g-  LM M M M M  6=  	5 	5D dVW[[]]CCI #DOO 4 4K2'	2222D
 
 
  ,, #	 #	FAss)C  NN6"""NN3N000OOC   HHUOOO  HHXHH%&&S)99-    
  	:#8I..>? .     HHV

$%%^<<< 

+,,NCCC
  3i--4 	HHUOOOOHHUOOO
sG,,,
    	HHXHHX
?##U.AAA
vw000   
 s   <!J J>=J>s!   _underway([commitage[, headage]])c                    t          j        |dd          }d|vrd |d<   d|vrd |d<   d}g }|d         r@|dz  }|                    t          j        |d         t          d                                | j        |g|R  }t          j        |          }||                     d|          z  }d	}g }|d         r@|dz  }|                    t          j        |d         t          d
                               | | j        |g|R  z  }| d                                         }|t          k    r|t          j        |h          z  }||z  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 stringre   )
r   getargsdictappendr   	getstringr   r`   basesetrF   r   )	r:   subsetrq   argsrsrsargsmutablerelevantwdirrevs	            r   underwayrevsetr     s   a.BCCD4!\Z 
,BFL 

 \"A&D$E$E 	
 	
 	
 di$V$$$G~g&&H 		/7333H 
$BFJ 

 Z !$@"A"A 	
 	
 	
 		"&v&&&&H 4jnnG'FNG9---Hr   s   workc           	          |                     d          }t          ||          }t          j        ||          }|                     ddd           t          j        | |||t          j        d|i           dS )zchangesets that aren't finisheds   sort(_underway(), topo)s   experimentals   graphshortenTs   nodelen)propsN)r`   rZ   r
   	dagwalker	setconfigr   displaygraph
asciiedges)r9   r:   rB   r`   rS   revdags         r   showworkr     s     99/00DdD))Gd++FLL/4888
7#     r   c                    |                      dd          D ]u}t          j        D ]f}d||fz  }t          j        |t
          j        d          \  }}||v r2|                     d|d           rJ|                     d|d|z  d	           gvd S )
Ns   commandss   show.aliasprefixs   %s%sT)stricts   aliass   show %sr&   )source)	
configlistr0   r1   r   findpossibler   r   configr   )r9   prefixr;   r   choiceallcommandss         r   extsetupr     s    ---@AA L LO 	L 	LDfd^+D")"6hnT# # #FK
 v~~ yy4.. LL4d):7LKKKK	LL Lr      c                 X     |sS  j         t           f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      K   | ]:}t          t          j                            |                              V  ;d S rK   )rL   r   shortesthexnodeidprefixrH   )rG   rr   minlenr:   s     r   rN   z"longestshortest.<locals>.<genexpr>  sX         	G+D"''!**fEEFF     r   )r}   rY   )r:   r`   r   r   s   ` `@r   rZ   rZ     s]      	B           r   c            	         t          t          t          t          j                                                            } g }t          t          j                                                  D ]W}|                    dt          j	        |
                    |                     dt          j        |         j                   Xt          j	        d          t          d         d         j                                        t          j	        d                              |          fz  t          d         d         _        d S )Nz    z   s   %s

%s
    r&   r   s   

)rY   maprL   r0   r1   keysr4   r   r   sysstrljust_origdoccmdtabler#   rstripjoin)longestentriesrt   s      r   _updatedocstringr     s   #c8?//112233GGho**,,-- 
 
 		' 2 23333$--	
 	
 	
 	
 $,?3D#E#E!$++--  %%g..I $HWa   r   r   )r   )#r#   mercurial.i18nr   mercurial.noder   	mercurialr   r   r   r   r	   r
   r   r   r   r   r   r   r   
testedwithr   commandrevsetpredicate_funcregistrarbaser   r0   CATEGORY_CHANGE_NAVIGATIONrC   rc   r   r   r   r   rZ   r   r%   r   r   <module>r      s   *       " " " " " "                             ( #

)
H
%
%+)+--$ $ $ $ $). $ $ $6 ;== 	 
{C!911[>>J AgJJ3  @ @ @ @F 
,---
 
 .-
4 
(h'''{ { ('{| 5665 5 765p 
'W%%%  &%&L L L*   4  $       r   