
    q&f?              
          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j4                        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"        y)!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y)showcmdfuncz;Register a function to be invoked for an `hg show <thing>`.s   %s -- %sNc                      ||_         ||_        y)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   ;   s    E J$r   r      show   T   templater   s   display with templates   TEMPLATEs   VIEW)helpcategoryNc                 "   | j                         r-|s+t        d      }t        j                  t        d      |      t        j
                  }|s| j                  d       | j                  t        d             | j                  d       t        |j                               D ]6  \  }}| j                  dt        j                  |j                        z         8 | j                  d       t        j                  t        d      t        d	            ||vr,t        j                  t        d
      |z  t        d            |xs d}||   }| j                  d       |j                  r7d|j                  z  }	| j                  |	d|i      5 }
 || ||
      cddd       S |j                  rId|j                  z  }t        j                   | ||      }t#        j$                  | ||d      } || ||      S  || |      S # 1 sw Y   yxY w)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   > 
xxz(FGkk67d
 	
 OOE
 	()*
 / 	@JD$HHWx00>>?	@ 	kk"#9:
 	
 5kk!"T):;
 	

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


tDz
"
eR(
"**T*BJJt,<=
<K 	 	

 9s   Es   stack)r   c                 F   |d   }|j                         t        k(  rt        j                  t	        d            |j                         t        j                  k(  r| j                  t	        d             yt        j                  | |      }d}|"|j                         }|j                         h}nt        |j                  d|            }||   }|j                         j                         t        k7  r|j                         }d}|j                  }	|	j                  |j                         g      D ]i  }
||
   }|j                         t        j                  k(  r nA|j!                  |j                                t#        |j%                               dkD  sgd} n t'        t)        |d	            }|r+t        |j                  d
|j                         |            }n
t               }t        |      |z  |hz  }t+        ||      }	 t-        j.                  dt0        j2                         d}t9        j:                  | |      }t9        j<                  | d|z  |      fd}|ri |D ];  }|	j?                  |g|j                               }t#        t'        |            |<   = ||d      }t)        |fdd      }tA        |      D ]  \  }}
||
   }|r| j                  d       n| j                  d       | jC                  d       |jE                  ||       |jG                  |       | j                  d       |r| j                  d       n| j                  d       | j                  d       | j                  t	        d      |
   z  d       |r5| j                  d       | j                  d ||       ||      fz  d        | j                  d!        | j                  d"       | j                  t	        d#      d$       |r>| j                  d%       | j                  t	        d&      d$       | j                  d'       |D ]  }
||
   }|
|j                         k(  rd(nd)}|r| j                  d       n| j                  d       | j                  |d       |jE                  ||       |jG                  |       | j                  d        |r|r| j                  d*       n| j                  d+       | j                  t	        d,      dd$       | jC                  d       |jE                  ||       |jG                  |       | j                  d       yy# t        j4                  t        j6                  f$ r d}Y iw xY w)-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                 H    j                  | | j                         d      S )N)s   ctxrL   )renderdefaulthex)rK   shortesttmpls    r   shortestzshowstack.<locals>.shortest   s    ))3*KLLr   )stoprevc                     |    S rF   r%   )xrevdistances    r   <lambda>zshowstack.<locals>.<lambda>3  s    KN r   )keyre   s   : s     s   o  )rO   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))$rT   r   r   r/   r   phaser   publicr3   r   	stackbasesetr^   p1	changelogdescendantsaddrG   childrenlistr4   rW   r   findcmdr   tableAmbiguousCommandUnknownCommandr	   templateresourcesmaketemplater	ancestors	enumeratewritenoi18nrC   flush)r9   r:   rB   wdirctxbaserevbasectx	stackrevsrK   branchpointattipclrT   newheadsallrevsrO   
haverebasetresrk   headr   	sourcectxsortedheadsisymbolrp   rj   s                          @@r   	showstackr      s    4jG{{}kk%
 	
 }}&--'
 	
 	
   T*GG++-[[]O			(G45	
w-C
vvx||~ &&( 	B~~w{{}o. 3i 99;&--'cggi  s||~"#!$ VIt45I II3W[[]I
 5)nx'7)3GdG,G	8>>2
 &&r40D**
#g-LM   	5D dVW[[]CI #DO 4K		5 2'	2D
  , #	FAss)CNN6"NN3N0OOC HHUOHHXHH%&S)99-  
 :#I.>? .   HHVG#	J 	
$%^<

+,NC
 3i-4HHUOHHUO
sG,
   HHXHHX
?#U.A
vw0 
 A ""E$8$89 
s   &U7 7%V V s!   _underway([commitage[, headage]])c                 j   t        j                  |dd      }d|vrd |d<   d|vrd |d<   d}g }|d   r6|dz  }|j                  t        j                  |d   t        d                    | j                  |g| }t        j                  |      }|| j                  d|      z  }d	}g }|d   r6|dz  }|j                  t        j                  |d   t        d
                   | | j                  |g| z  }| d   j                         }|t        k7  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 stringrc   )
r   getargsdictappendr   	getstringr   r^   basesetrT   r   )	r:   subsetro   argsrsrsargsmutablerelevantwdirrevs	            r   underwayrevsetr     s_   a.BCD4!\Z 
,BFL
  \"A&D$E	
 dii$V$G~~g&H 		/733H 
$BFJ
  Z !$@"A	
 			"&v&&H 4jnnG'FNNG9--Hr   s   workc           	          |j                  d      }t        ||      }t        j                  ||      }| j	                  ddd       t        j                  | |||t        j                  d|i       y)zchangesets that aren't finisheds   sort(_underway(), topo)s   experimentals   graphshortenTs   nodelen)propsN)r^   rW   r
   	dagwalker	setconfigr   displaygraph
asciiedges)r9   r:   rB   r^   rO   revdags         r   showworkr     sl     99/0DdD)Gd+FLL/48
7#r   c                    | j                  dd      D ]x  }t        j                  D ]c  }d||fz  }t        j                  |t
        j                  d      \  }}||v r8| j                  d|d       rL| j                  d|d|z  d	       e z y )
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 LOO 	LDfd^+D")"6"6hnnT#FK
 v~ yy4.LL4d):7LK	LLr   c                 T     |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   | ]3  }t        t        j                  j                  |                   5 y wrF   )rG   r   shortesthexnodeidprefixr]   )rH   rr   minlenr:   s     r   rJ   z"longestshortest.<locals>.<genexpr>  s5       	G++D"''!*fEFs   9<)r{   rV   )r:   r^   r   r   s   ` `@r   rW   rW     s0     	B   r   c            	      L   t        t        t        t        j                  j                                     } g }t        t        j                  j                               D ]V  }|j                  dt        j                  |j                  |             dt        j                  |   j                         X t        j                  d      t        d   d   j                  j                         t        j                  d      j                  |      fz  t        d   d   _        y )Nz    z   s   %s

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

)rV   maprG   r0   r1   keysr4   r   r   sysstrljust_origdoccmdtabler#   rstripjoin)longestentriesrr   s      r   _updatedocstringr     s    #c8??//123GGhoo**,- 
 		' 23$--	

 $,??3D#E!$$++- %%g.I $HWa 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   ra   r   r   r   r   rW   r   r%   r   r   <module>r      sA  *  "   ( #

)

H
%+)++-$).. $6 = 	 
{C!91[>J gJ33@@F 
,-
 .
4 
(h'{ ({| 565 75p 
'W% &&L*4$  r   