
    6h                     ^    S SK Jr  SSKJr  SSKJrJrJr  S r " S S5      r	 " S S	5      r
g
)    )annotations   )_)	registrar
templatekwutilc                    U c  / $ U /$ )z>
a convenience method to return an empty list instead of None
 )vals    6/usr/lib/python3/dist-packages/mercurial/namespaces.pytolistr      s     {	u    c                  R    \ rS rSrSrSrS rS rS rSS jr	S	 r
\
rSS
 jrS rSrg)
namespaces   zprovides an interface to register and operate on multiple namespaces. See
the namespace class below for details on the namespace object.

r   c                n   [         R                  " 5       U l        [        R                  " 5       nS nS nS n[        SSUS   UUUSS9nU R                  U5        S nS	 nS
 n[        SSUS   UUUS1SS9nU R                  U5        S n	S n
S n[        SSUS   U	U
USS9nU R                  U5        g )Nc                6    U R                   R                  5       $ N)
_bookmarkskeysrepos    r   <lambda>%namespaces.__init__.<locals>.<lambda>#   s     4 4 6r   c                J    [        U R                  R                  U5      5      $ r   )r   r   getr   names     r   r   r   $   s    t/B/B4/H(Ir   c                $    U R                  U5      $ r   )nodebookmarksr   nodes     r   r   r   %   s    (:(:4(@r   s	   bookmarkss   bookmarkT)templatenamelogfmt	listnamesnamemapnodemapbuiltinc                X    U R                  5        VVs/ s H  u  pUPM	     snn$ s  snnf r   )tagslist)r   tns      r   r   r   1   s    t}} ?tq ? ?s   &c                ^    [        U R                  R                  R                  U5      5      $ r   )r   
_tagscachetagsr   r   s     r   r   r   2   s    t/C/C/G/G/M(Nr   c                $    U R                  U5      $ r   )nodetagsr!   s     r   r   r   3   s    d(;r   s   tagss   tags   tip)r#   r$   r%   r&   r'   
deprecatedr(   c                >    U R                  5       R                  5       $ r   )	branchmapr   r   s    r   r   r   @   s    dnn.335r   c                8    [        U R                  US5      5      $ )NT)r   	branchtipr   s     r   r   r   A   s    fT^^D$-G&Hr   c                (    X   R                  5       /$ r   )branchr!   s     r   r   r   B   s    tz'8'8':&;r   s   branchess   branch)r   sortdict_namesr   getlogcolumns	namespaceaddnamespace)selfcolumnsbmknames
bmknamemap
bmknodemapr,   tagnames
tagnamemap
tagnodemapbnamesbnamemapbnodemaps               r   __init__namespaces.__init__   s    mmo**, 7I
@
$;'
 	!?N
;
6?x	
 	!5H;"9%
 	!r   c                     U R                   U   $ )zreturns the namespace objectr:   )r>   r<   s     r   __getitem__namespaces.__getitem__N   s    {{9%%r   c                6    U R                   R                  5       $ r   )r:   __iter__r>   s    r   rP   namespaces.__iter__R   s    {{##%%r   Nc                8    U R                   R                  X5      $ r   )r:   r   )r>   r<   defaults      r   r   namespaces.getU   s    {{y22r   c                6    U R                   R                  5       $ r   )r:   itemsrQ   s    r   rW   namespaces.itemsX   s    {{  ""r   c                L  ^ Ub(  U R                   R                  UTR                  T5        OTU R                   TR                  '   TR                  [        R                  ;  aA  [
        R                  " [        R                  5      nU" TR                  SS1S9U4S j5       ngg)zregister a namespace

namespace: the name to be registered (in plural form)
order: optional argument to specify the order of namespaces
       (e.g. 'branches' should be listed before 'bookmarks')

Ns   repos   ctx)requiresc                F   > [         R                  " XTR                  5      $ r   )r   	shownamesr   )contextmappingr<   s     r   
generatekw+namespaces.addnamespace.<locals>.generatekwn   s    !++GinnMMr   )r:   insertr   r   keywordsr   templatekeyword)r>   r<   orderrc   r_   s    `   r   r=   namespaces.addnamespace]   s     KKuinni@*3DKK	' >>!4!44'77
8K8KLOY^^w6GHN IN	 5r   c                    U R                   R                  5        H!  u  p4UR                  X5      nU(       d  M  Us  $    [        [	        S5      U-  5      e)z
Return the 'best' node for the given name. What's best is defined
by the namespace's singlenode() function. The first match returned by
a namespace in the defined precedence order is used.

Raises a KeyError if there is no such node.
s   no such name: %s)r:   rW   
singlenodeKeyErrorr   )r>   r   r   nsvr,   s         r   rg   namespaces.singlenoder   sM     [[&&(EBT(Aq ) q,-455r   rL   r   )__name__
__module____qualname____firstlineno____doc___names_versionrI   rM   rP   r   rW   	iteritemsr=   rg   __static_attributes__r
   r   r   r   r      s:    
 N/b&&3# IN*6r   r   c                  H    \ rS rSrSr          S	S jrS rS rS rSr	g)
r<      a  provides an interface to a namespace

Namespaces are basically generic many-to-many mapping between some
(namespaced) names and nodes. The goal here is to control the pollution of
jamming things into tags or bookmarks (in extension-land) and to simplify
internal bits of mercurial: log output, tab completion, etc.

More precisely, we define a mapping of names to nodes, and a mapping from
nodes to names. Each mapping returns a list.

Furthermore, each name mapping will be passed a name to lookup which might
not be in its domain. In this case, each method should return an empty list
and not raise an error.

This namespace object will define the properties we need:
  'name': the namespace (plural form)
  'templatename': name to use for templating (usually the singular form
                  of the plural namespace name)
  'listnames': list of all names in the namespace (usually the keys of a
               dictionary)
  'namemap': function that takes a name and returns a list of nodes
  'nodemap': function that takes a node and returns a list of names
  'deprecated': set of names to be masked for ordinary use
  'builtin': bool indicating if this namespace is supported by core
             Mercurial.
Nc                   Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        U(       a  Xl        U R                  c  U R                  U l        U R                  c  U R                  U l        U R                  c&  SU R                  -  R                  S5      S-   U l        U	c  [        5       U l        OXl        Xl        g)a  create a namespace

name: the namespace to be registered (in plural form)
templatename: the name to use for templating
logname: the name to use for log output; if not specified templatename
         is used
colorname: the name to use for colored log output; if not specified
           logname is used
logfmt: the format to use for (i18n-ed) log output; if not specified
        it is composed from logname
listnames: function to list all names
namemap: function that inputs a name, output node(s)
nodemap: function that inputs a node, output name(s)
deprecated: set of names to be masked for ordinary use
builtin: whether namespace is implemented by core Mercurial
singlenode: function that inputs a name, output best node (or None)
Ns   %s:   s   %s
)r   r#   logname	colornamer$   r%   r&   r'   rg   ljustsetr2   r(   )r>   r   r#   rx   ry   r$   r%   r&   r'   r2   r(   rg   s               r   rI   namespace.__init__   s    > 	(""(O <<,,DL >>!!\\DN ;;!DLL077;gEDK!eDO(Or   c                6    [        U R                  X5      5      $ )zSmethod that returns a (sorted) list of names in a namespace that
match a given node)sortedr'   )r>   r   r"   s      r   namesnamespace.names   s     dll4.//r   c                6    [        U R                  X5      5      $ )zMmethod that returns a list of nodes in a namespace that
match a given name.

)r~   r&   )r>   r   r   s      r   nodesnamespace.nodes   s    
 dll4.//r   c                   ^ U R                  X5      nU(       aF  [        U5      S:  a2  UR                  m[        U4S jU 5       5      nTR	                  U5      $ US   $ g)zreturns the best node for the given name

By default, the best node is the node from nodes() with the highest
revision number. It can be overriden by the namespace.r   c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr   )rev).0r"   cls     r   	<genexpr>'namespace.singlenode.<locals>.<genexpr>   s     8adRVVD\\as   !r   N)r&   len	changelogmaxr"   )r>   r   r   r,   maxrevr   s        @r   rg   namespace.singlenode   sT    
 LL$1vz^^8a88wwv&Q4Kr   )r(   ry   r2   r%   r$   rx   r   r&   r'   rg   r#   )
NNNNNNNNFN)
rl   rm   rn   ro   rp   rI   r   r   rg   rs   r
   r   r   r<   r<      s<    < <|0
0r   r<   N)
__future__r   i18nr    r   r   r   r   r   r<   r
   r   r   <module>r      s3    "  i6 i6Xs sr   