
    6hJ                    2   S SK Jr  S SKJrJrJrJr  SSKJrJ	r	J
r
  \R                  r " S S5      r " S S\5      rS	r " S
 S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)    )annotations)AnyListOptionalTuple   )configitemserrorpycompatc                  P    \ rS rSrSrSS jrS rS rS rS r	S	 r
SrS
 rS rSrg)_funcregistrarbase   ao  Base of decorator to register a function for specific purpose

This decorator stores decorated functions into own dict 'table'.

The least derived class can be defined by overriding 'formatdoc',
for example::

    class keyword(_funcregistrarbase):
        _docformat = ":%s: %s"

This should be used as below:

    keyword = registrar.keyword()

    @keyword(b'bar')
    def barfunc(*args, **kwargs):
        '''Explanation of bar keyword ....
        '''
        pass

In this case:

- 'barfunc' is stored as 'bar' in '_table' of an instance 'keyword' above
- 'barfunc.__doc__' becomes ":bar: Explanation of bar keyword"
Nc                &    Uc  0 U l         g Xl         g N_table)selftables     5/usr/lib/python3/dist-packages/mercurial/registrar.py__init___funcregistrarbase.__init__4   s    =DKK    c                   ^ ^^^ UUUU 4S j$ )Nc                2   > TR                   " U T/TQ70 TD6$ r   )_doregister)funcargsdeclkwargsr   s    r   <lambda>-_funcregistrarbase.__call__.<locals>.<lambda>;   s    D,,T4I$I&Ir    )r   r   r   r   s   ````r   __call___funcregistrarbase.__call__:   s	    IIr   c                   U R                  U5      nXPR                  ;   a  SU-  n[        R                  " U5      eUR                  (       az  [        US5      (       di  UR                  R                  5       Ul        [        R                  " UR                  5      n[        R                  " U R                  X'5      5      Ul        XR                  U'   U R                  " XQ/UQ70 UD6  U$ )Ns%   duplicate registration for name: "%s"_origdoc)_getnamer   r
   ProgrammingError__doc__hasattrstripr&   r   sysbytessysstr
_formatdoc_extrasetup)r   r   r   r   r   namemsgdocs           r   r   _funcregistrarbase._doregister=   s    }}T";;:TAC((--<<j 9 9 LL..0DM##DMM2C#??4??4+EFDL D5d5f5r   c                p   [        U[        U 5      5      (       d  Sn[        R                  " U5      e[	        UR
                  5      R                  U R
                  5      nU(       a*  SSR                  U5      -  n[        R                  " U5      eU R
                  R                  UR
                  5        g)zMerge the entries of the given registrar object into this one.

The other registrar object must not contain any entries already in the
current one, or a ProgrammmingError is raised.  Additionally, the types
of the two registrars must match.
s)   cannot merge different types of registrars&   duplicate registration for names: "%s"s   ", "N)	
isinstancetyper
   r(   setr   intersectionjoinupdate)r   registrarbaser1   dupss       r   _merge_funcregistrarbase._mergeN   s     -d44>C((--=''(55dkkB;gll4>PPC((--=//0r   c                >    UR                  S5      nUS:  a  USU $ U$ )z@Parse function declaration and return the name of function in it   (r   N)find)r   r   is      r   _parsefuncdecl!_funcregistrarbase._parsefuncdecla   s&    IIdO68OKr   c                    U$ )zReturn the name of the registered function from decl

Derived class should override this, if it allows more
descriptive 'decl' string than just a name.
r"   )r   r   s     r   r'   _funcregistrarbase._getnamei   s	     r   c                "    U R                   X4-  $ )zvReturn formatted document of the registered function for help

'doc' is '__doc__.strip()' of the registered function.
)
_docformat)r   r   r2   s      r   r.   _funcregistrarbase._formatdocs   s    
 $,,r   c                    g)z6Execute extra setup for registered function, if neededNr"   )r   r0   r   s      r   r/   _funcregistrarbase._extrasetupz   s    r   r   r   )__name__
__module____qualname____firstlineno__r)   r   r#   r   r=   rC   r'   rH   r.   r/   __static_attributes__r"   r   r   r   r      s8    4 J"1& J-Er   r   c                  l    \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrSrSrSrSr        SS jrS rSrg)command~   a	  Decorator to register a command function to table

This class receives a command table as its argument. The table should
be a dict.

The created object can be used as a decorator for adding commands to
that command table. This accepts multiple arguments to define a command.

The first argument is the command name (as bytes).

The `options` keyword argument is an iterable of tuples defining command
arguments. See ``mercurial.fancyopts.fancyopts()`` for the format of each
tuple.

The `synopsis` argument defines a short, one line summary of how to use the
command. This shows up in the help output.

There are three arguments that control what repository (if any) is found
and passed to the decorated function: `norepo`, `optionalrepo`, and
`inferrepo`.

The `norepo` argument defines whether the command does not require a
local repository. Most commands operate against a repository, thus the
default is False. When True, no repository will be passed.

The `optionalrepo` argument defines whether the command optionally requires
a local repository. If no repository can be found, None will be passed
to the decorated function.

The `inferrepo` argument defines whether to try to find a repository from
the command line arguments. If True, arguments will be examined for
potential repository locations. See ``findrepo()``. If a repository is
found, it will be used and passed to the decorated function.

The `intents` argument defines a set of intended actions or capabilities
the command is taking. These intents can be used to affect the construction
of the repository object passed to the command. For example, commands
declaring that they are read-only could receive a repository that doesn't
have any methods allowing repository mutation. Other intents could be used
to prevent the command from running if the requested intent could not be
fulfilled.

If `helpcategory` is set (usually to one of the constants in the help
module), the command will be displayed under that category in the help's
list of commands.

The following intents are defined:

readonly
   The command is read-only

The signature of the decorated function looks like this:
    def cmd(ui[, repo] [, <args>] [, <options>])

  `repo` is required if `norepo` is False.
  `<args>` are positional args (or `*args`) arguments, of non-option
  arguments from the command line.
  `<options>` are keyword arguments (or `**options`) of option arguments
  from the command line.

See the WritingExtensions and MercurialApi documentation for more exhaustive
descriptions and examples.
s   repos   remotes   commits
   managements   organizations   filess
   navigations   wdirs   imports   maintenances   helps   miscs   noner"   Nc                    XQl         Xal        Xql        U=(       d
    [        5       Ul        Xl        Xl        U(       a  U[        U5      U4U R                  U'   U$ U[        U5      4U R                  U'   U$ r   )	norepooptionalrepo	inferrepor7   intentshelpcategory	helpbasiclistr   )r   r   r0   optionssynopsisrU   rV   rW   rX   rY   rZ   s              r   r   command._doregister   sn     ("'#%(" $d7mX =DKK  !%d7m 3DKKr   c                T    U R                   R                  U5      U R                   U'   g)zFrename a command. Used to add aliases, debugstrip ->
debugstrip|strip
N)r   pop)r   oldnews      r   renamecommand.rename   s      ;;??3/Cr   )r"   NFFFNNF)rL   rM   rN   rO   r)   CATEGORY_REPO_CREATIONCATEGORY_REMOTE_REPO_MANAGEMENTCATEGORY_COMMITTINGCATEGORY_CHANGE_MANAGEMENTCATEGORY_CHANGE_ORGANIZATIONCATEGORY_FILE_CONTENTSCATEGORY_CHANGE_NAVIGATIONCATEGORY_WORKING_DIRECTORYCATEGORY_IMPORT_EXPORTCATEGORY_MAINTENANCECATEGORY_HELPCATEGORY_MISCCATEGORY_NONEr   rc   rP   r"   r   r   rR   rR   ~   sy    >J %&/##!.#2 %!.!(&)MMM 20r   rR   s   readonlyc                  >    \ rS rSrSr\R                  rSrSS jr	Sr
g)revsetpredicate   a  Decorator to register revset predicate

Usage::

    revsetpredicate = registrar.revsetpredicate()

    @revsetpredicate(b'mypredicate(arg1, arg2[, arg3])')
    def mypredicatefunc(repo, subset, x):
        '''Explanation of this revset predicate ....
        '''
        pass

The first string argument is used also in online help.

Optional argument 'safe' indicates whether a predicate is safe for
DoS attack (False by default).

Optional argument 'takeorder' indicates whether a predicate function
takes ordering policy as the last argument.

Optional argument 'weight' indicates the estimated run-time cost, useful
for static optimization, default is 1. Higher weight means more expensive.
Usually, revsets that are fast and return only one revision has a weight of
0.5 (ex. a symbol); revsets with O(changelog) complexity and read only the
changelog have weight 10 (ex. author); revsets reading manifest deltas have
weight 30 (ex. adds); revset reading manifest contents have weight 100
(ex. contains). Note: those values are flexible. If the revset has a
same big-O time complexity as 'contains', but with a smaller constant, it
might have a weight of 90.

'revsetpredicate' instance in example above can be used to
decorate multiple functions.

Decorated functions are registered automatically at loading
extension, if an instance named as 'revsetpredicate' is used for
decorating in extension.

Otherwise, explicit 'revset.loadpredicate()' is needed.
   ``%s``
    %sc                (    X2l         XBl        XRl        g r   )_safe
_takeorder_weight)r   r0   r   safe	takeorderweights         r   r/   revsetpredicate._extrasetup!  s    
#r   r"   N)FFr   rL   rM   rN   rO   r)   r   rC   r'   rH   r/   rP   r"   r   r   rs   rs      s    &P "00H"Jr   rs   c                  >    \ rS rSrSr\R                  rSrSS jr	Sr
g)filesetpredicatei'  as  Decorator to register fileset predicate

Usage::

    filesetpredicate = registrar.filesetpredicate()

    @filesetpredicate(b'mypredicate()')
    def mypredicatefunc(mctx, x):
        '''Explanation of this fileset predicate ....
        '''
        pass

The first string argument is used also in online help.

Optional argument 'callstatus' indicates whether a predicate
 implies 'matchctx.status()' at runtime or not (False, by
 default).

Optional argument 'weight' indicates the estimated run-time cost, useful
for static optimization, default is 1. Higher weight means more expensive.
There are predefined weights in the 'filesetlang' module.

====== =============================================================
Weight Description and examples
====== =============================================================
0.5    basic match patterns (e.g. a symbol)
10     computing status (e.g. added()) or accessing a few files
30     reading file content for each (e.g. grep())
50     scanning working directory (ignored())
====== =============================================================

'filesetpredicate' instance in example above can be used to
decorate multiple functions.

Decorated functions are registered automatically at loading
extension, if an instance named as 'filesetpredicate' is used for
decorating in extension.

Otherwise, explicit 'fileset.loadpredicate()' is needed.
ru   c                    X2l         XBl        g r   )_callstatusry   )r   r0   r   
callstatusr|   s        r   r/   filesetpredicate._extrasetupT  s    %r   r"   N)Fr   r~   r"   r   r   r   r   '  s    'R "00H"Jr   r   c                      \ rS rSrSrSrSrg)_templateregistrarbaseiY  z@Base of decorator to register functions as template specific ones   :%s: %sr"   N)rL   rM   rN   rO   r)   rH   rP   r"   r   r   r   r   Y  s
    JJr   r   c                  "    \ rS rSrSrSS jrSrg)templatekeywordi_  a  Decorator to register template keyword

Usage::

    templatekeyword = registrar.templatekeyword()

    # new API (since Mercurial 4.6)
    @templatekeyword(b'mykeyword', requires={b'repo', b'ctx'})
    def mykeywordfunc(context, mapping):
        '''Explanation of this template keyword ....
        '''
        pass

The first string argument is used also in online help.

Optional argument 'requires' should be a collection of resource names
which the template keyword depends on.

'templatekeyword' instance in example above can be used to
decorate multiple functions.

Decorated functions are registered automatically at loading
extension, if an instance named as 'templatekeyword' is used for
decorating in extension.

Otherwise, explicit 'templatekw.loadkeyword()' is needed.
r"   c                    X2l         g r   )	_requires)r   r0   r   requiress       r   r/   templatekeyword._extrasetup|  s    !r   N)r"   rL   rM   rN   rO   r)   r/   rP   r"   r   r   r   r   _  s    8"r   r   c                  "    \ rS rSrSrSS jrSrg)templatefilteri  a  Decorator to register template filer

Usage::

    templatefilter = registrar.templatefilter()

    @templatefilter(b'myfilter', intype=bytes)
    def myfilterfunc(text):
        '''Explanation of this template filter ....
        '''
        pass

The first string argument is used also in online help.

Optional argument 'intype' defines the type of the input argument,
which should be (bytes, int, templateutil.date, or None for any.)

'templatefilter' instance in example above can be used to
decorate multiple functions.

Decorated functions are registered automatically at loading
extension, if an instance named as 'templatefilter' is used for
decorating in extension.

Otherwise, explicit 'templatefilters.loadkeyword()' is needed.
Nc                    X2l         g r   )_intype)r   r0   r   intypes       r   r/   templatefilter._extrasetup  s    r   r"   r   r   r"   r   r   r   r     s    6r   r   c                  :    \ rS rSrSr\R                  rSS jrSr	g)templatefunci  a  Decorator to register template function

Usage::

    templatefunc = registrar.templatefunc()

    @templatefunc(b'myfunc(arg1, arg2[, arg3])', argspec=b'arg1 arg2 arg3',
                  requires={b'ctx'})
    def myfuncfunc(context, mapping, args):
        '''Explanation of this template function ....
        '''
        pass

The first string argument is used also in online help.

If optional 'argspec' is defined, the function will receive 'args' as
a dict of named arguments. Otherwise 'args' is a list of positional
arguments.

Optional argument 'requires' should be a collection of resource names
which the template function depends on.

'templatefunc' instance in example above can be used to
decorate multiple functions.

Decorated functions are registered automatically at loading
extension, if an instance named as 'templatefunc' is used for
decorating in extension.

Otherwise, explicit 'templatefuncs.loadfunction()' is needed.
Nr"   c                    X2l         XBl        g r   )_argspecr   )r   r0   r   argspecr   s        r   r/   templatefunc._extrasetup  s    !r   )Nr"   )
rL   rM   rN   rO   r)   r   rC   r'   r/   rP   r"   r   r   r   r     s    @ "00H"r   r   c                  :    \ rS rSrSrSrSrSrSr    S	S jr	Sr
g)
internalmergei  a  Decorator to register in-process merge tool

Usage::

    internalmerge = registrar.internalmerge()

    @internalmerge(b'mymerge', internalmerge.mergeonly,
                   onfailure=None, precheck=None,
                   binary=False, symlink=False):
    def mymergefunc(repo, mynode, orig, fcd, fco, fca,
                    toolconf, files, labels=None):
        '''Explanation of this internal merge tool ....
        '''
        return 1, False # means "conflicted", "no deletion needed"

The first string argument is used to compose actual merge tool name,
":name" and "internal:name" (the latter is historical one).

The second argument is one of merge types below:

========== ======== ======== =========
merge type precheck premerge fullmerge
========== ======== ======== =========
nomerge     x        x        x
mergeonly   o        x        o
fullmerge   o        o        o
========== ======== ======== =========

Optional argument 'onfailure' is the format of warning message
to be used at failure of merging (target filename is specified
at formatting). Or, None or so, if warning message should be
suppressed.

Optional argument 'precheck' is the function to be used
before actual invocation of internal merge tool itself.
It takes as same arguments as internal merge tool does, other than
'files' and 'labels'. If it returns false value, merging is aborted
immediately (and file is marked as "unresolved").

Optional argument 'binary' is a binary files capability of internal
merge tool. 'nomerge' merge type implies binary=True.

Optional argument 'symlink' is a symlinks capability of inetrnal
merge function. 'nomerge' merge type implies symlink=True.

'internalmerge' instance in example above can be used to
decorate multiple functions.

Decorated functions are registered automatically at loading
extension, if an instance named as 'internalmerge' is used for
decorating in extension.

Otherwise, explicit 'filemerge.loadinternalmerge()' is needed.
s   ``:%s``
    %sNs	   mergeonlys	   fullmergec                    X2l         XBl        XRl        U=(       d    X0R                  :H  nU=(       d    X0R                  :H  n	XS.Ul        g )N)s   binarys   symlink)	mergetype	onfailureprechecknomergecapabilities)
r   r0   r   r   r   r   binarysymlink	binarycap
symlinkcaps
             r   r/   internalmerge._extrasetup  sB     #" 7i<<7	9	\\ 9
 )2Jr   r"   )NNFF)rL   rM   rN   rO   r)   rH   r   	mergeonly	fullmerger/   rP   r"   r   r   r   r     s4    5n $J GII Kr   r   c                  H   ^  \ rS rSrSrSU 4S jjr  S   SS jjrSrU =r$ )verify_checki  z|Decorator to register a check for admin::verify

options is a list of (name, default value, help) to be passed to the check
c                F   > [         TU ]  U5        Uc  0 U l        g X l        g r   )superr   _alias_table)r   r   alias_table	__class__s      r   r   verify_check.__init__"  s$     "D +r   c                H    X2l         XBl        U(       a  XR                  U'   g g r   )aliasr\   r   )r   r0   r   r   r\   s        r   r/   verify_check._extrasetup)  s$     
'+e$ r   )r   )NN)r   zOptional[bytes]r\   z(Optional[List[Tuple[bytes, Any, bytes]]])	rL   rM   rN   rO   r)   r   r/   rP   __classcell__)r   s   @r   r   r     s3    
, "&<@, 	,
 :, ,r   r   N)
__future__r   typingr   r   r   r    r	   r
   r   getitemregister
configitemr   rR   INTENT_READONLYrs   r   r   r   r   r   r   r   r"   r   r   <module>r      s    # - -  ((
bE bEJq0  q0h /( /d/) /d/ ", "B+ @%") %"PQK& QKh,% ,r   