^cF*ddlmZmZmZmZejZGddZGddeZdZ GddeZ Gd d eZ Gd d eZ Gd de Z Gdde ZGdde ZGddeZdS)) configitemserrorpycompatutilcHeZdZdZd dZdZdZdZdZdZ dZ d Z d Z dS) _funcregistrarbaseaBase 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*| i|_dS||_dSN)_table)selftables 5/usr/lib/python3/dist-packages/mercurial/registrar.py__init__z_funcregistrarbase.__init__3s =DKKKDKKKcfdS)Nc(j|gRiSr ) _doregister)funcargsdeclkwargsr s rz-_funcregistrarbase.__call__..:s',D,T4I$III&IIr)r rrrs````r__call__z_funcregistrarbase.__call__9sIIIIIIIIrc||}||jvrd|z}tj||jryt j|dsd|j|_tj |j}tj | |||_||j|<|j ||g|Ri||S)Ns%duplicate registration for name: "%s"_origdoc)_getnamer rProgrammingError__doc__r safehasattrstriprrsysbytessysstr _formatdoc _extrasetup)r rrrrnamemsgdocs rrz_funcregistrarbase._doregister<s}}T"" 4;  :TAC(-- - < G 0z B B G L..00DM#DM22C#?4??4+E+EFFDL  Dt5d555f555 rc^t|t|sd}tj|t |j|j}|r,dd|z}tj||j|jdS)aMerge 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) isinstancetyperrsetr intersectionjoinupdate)r registrarbaser'dupss r_mergez_funcregistrarbase._mergeMs-d44 .>C(-- -='((55dkBB  .;gll4>P>PPC(-- - =/00000rcP|d}|dkr |d|S|S)z@Parse function declaration and return the name of function in it(N)find)r ris r_parsefuncdeclz!_funcregistrarbase._parsefuncdecl`s, IIdOO 668OKrc|S)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 rs rrz_funcregistrarbase._getnamehs  rc|j||fzS)zReturn formatted document of the registered function for help 'doc' is '__doc__.strip()' of the registered function. ) _docformat)r rr(s rr$z_funcregistrarbase._formatdocrs $,,rcdS)z6Execute extra setup for registered function, if neededNr)r r&rs rr%z_funcregistrarbase._extrasetupysrr ) __name__ __module__ __qualname__rrrrr2r8rr;r$r%rrrrrs4    JJJ"111&J---EEEEErrcdeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZ ddZdZdS)commanda 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] [, ] [, ]) `repo` is required if `norepo` is False. `` are positional args (or `*args`) arguments, of non-option arguments from the command line. `` are keyword arguments (or `**options`) of option arguments from the command line. See the WritingExtensions and MercurialApi documentation for more exhaustive descriptions and examples. sreposremotescommits managements organizationsfiless navigationswdirsimports maintenanceshelpsmiscsnonerNFc ||_||_||_|p t|_| |_| |_|r|t||f|j|<n|t|f|j|<|Sr ) norepo optionalrepo inferrepor,intents helpcategory helpbasiclistr ) r rr&optionssynopsisrCrDrErFrGrHs rrzcommand._doregistersy ("'#%% ("  4 $d7mmX =DK   $d7mm 3DK  rcJ|j||j|<dS)zVrename a command. Used to add aliases, debugstrip -> debugstrip|strip N)r pop)r oldnews rrenamezcommand.renames$ ;??3// Cr)rNFFFNNF)r=r>r?rCATEGORY_REPO_CREATIONCATEGORY_REMOTE_REPO_MANAGEMENTCATEGORY_COMMITTINGCATEGORY_CHANGE_MANAGEMENTCATEGORY_CHANGE_ORGANIZATIONCATEGORY_FILE_CONTENTSCATEGORY_CHANGE_NAVIGATIONCATEGORY_WORKING_DIRECTORYCATEGORY_IMPORT_EXPORTCATEGORY_MAINTENANCE CATEGORY_HELP CATEGORY_MISC CATEGORY_NONErrPrrrrArA}s>>J%&/##!.#2 %!.!(&)MMM 200000rrAsreadonlyc,eZdZdZejZdZddZdS)revsetpredicatea$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`` %sFrc0||_||_||_dSr )_safe _takeorder_weight)r r&rsafe takeorderweights rr%zrevsetpredicate._extrasetup s # rN)FFr r=r>r?rrr8rr;r%rrrr_r_sB&&P"0H"Jrr_c,eZdZdZejZdZddZdS)filesetpredicateaDecorator 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. r`Frc"||_||_dSr ) _callstatusrd)r r&r callstatusrgs rr%zfilesetpredicate._extrasetupSs% rN)Frrhrrrrjrj&sB''R"0H"JrrjceZdZdZdZdS)_templateregistrarbasez@Base of decorator to register functions as template specific ones:%s: %sN)r=r>r?rr;rrrroroXsJJJJJrroceZdZdZddZdS)templatekeywordaWDecorator 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. rc||_dSr ) _requires)r r&rrequiress rr%ztemplatekeyword._extrasetup{s !rN)rr=r>r?rr%rrrrqrq^s28""""""rrqceZdZdZddZdS)templatefiltera(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||_dSr )_intype)r r&rintypes rr%ztemplatefilter._extrasetups  rr rurrrrwrws26rrwc(eZdZdZejZddZdS) templatefuncaDecorator 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. Nrc"||_||_dSr )_argspecrs)r r&rargspecrts rr%ztemplatefunc._extrasetups !r)Nr)r=r>r?rrr8rr%rrrr|r|s=@"0H""""""rr|c2eZdZdZdZdZdZdZ ddZdS) internalmergeaXDecorator 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 fullmergeFcx||_||_||_|p ||jk}|p ||jk} || d|_dS)N)sbinaryssymlink) mergetype onfailureprechecknomerge capabilities) r r&rrrrbinarysymlink binarycap symlinkcaps rr%zinternalmerge._extrasetupsS#"  7i4<7 9 T\ 9 )2zJJr)NNFF) r=r>r?rr;r mergeonly fullmerger%rrrrrs_55n$JGIIKKKKKKrrN)rrrrgetitemregister configitemrrAINTENT_READONLYr_rjrorqrwr|rrrrrs ( bEbEbEbEbEbEbEbEJq0q0q0q0q0 q0q0q0h/////(///d/////)///d/ """"","""B+@%"%"%"%"%")%"%"%"PQKQKQKQKQK&QKQKQKQKQKr