o ö]LbRã@s´ddlmZddlmZddlmZmZmZmZm Z m Z m Z ddl m Z mZe eee feee e e¡Ze de diZdd „Zd d „Zd d „Zdd„Zdd„Zdd„ZdS)é)Úabsolute_importé)Ú_é)ÚREVIDX_DEFAULT_FLAGSÚREVIDX_ELLIPSISÚREVIDX_EXTSTOREDÚREVIDX_FLAGS_ORDERÚREVIDX_HASCOPIESINFOÚREVIDX_ISCENSOREDÚREVIDX_RAWTEXT_CHANGING_FLAGS)ÚerrorÚutilNcCst||tƒdS)a!Register a flag processor on a revision data flag. Invariant: - Flags need to be defined in REVIDX_KNOWN_FLAGS and REVIDX_FLAGS_ORDER, and REVIDX_RAWTEXT_CHANGING_FLAGS if they can alter rawtext. - Only one flag processor can be registered on a specific flag. - flagprocessors must be 3-tuples of functions (read, write, raw) with the following signatures: - (read) f(self, rawtext) -> text, bool - (write) f(self, text) -> rawtext, bool - (raw) f(self, rawtext) -> bool "text" is presented to the user. "rawtext" is stored in revlog data, not directly visible to the user. The boolean returned by these transforms is used to determine whether the returned text can be used for hash integrity checking. For example, if "write" returns False, then "text" is used to generate hash. If "write" returns True, that basically means "rawtext" returned by "write" should be used to generate hash. Usually, "write" and "read" return different booleans. And "raw" returns a same boolean as "write". Note: The 'raw' transform is used for changegroup generation and in some debug commands. In this case the transform only indicates whether the contents can be used for hash integrity checks. N)ÚinsertflagprocessorÚflagprocessors)ÚflagÚ processor©rú@/usr/lib/python3/dist-packages/mercurial/revlogutils/flagutil.pyÚaddflagprocessor-srcCsf|t@stdƒ|}t |¡‚|tvrtdƒ|}t |¡‚||vr-tdƒ|}t |¡‚|||<dS)Ns0cannot register processor on unknown flag '%#x'.s+flag '%#x' undefined in REVIDX_FLAGS_ORDER.s2cannot register multiple processors on flag '%#x'.)ÚREVIDX_KNOWN_FLAGSrr ÚProgrammingErrorr ÚAbort)rrrÚmsgrrrrIs       rcCst|||dƒdd…S)a®Inspect revision data flags and applies write transformations defined by registered flag processors. ``text`` - the revision data to process ``flags`` - the revision flags This method processes the flags in the order (or reverse order if ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the flag processors registered for present flags. The order of flags defined in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity. Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the processed text and ``validatehash`` is a bool indicating whether the returned text should be checked for hash integrity. ówriteNr©Ú_processflagsfunc©ÚrevlogÚtextÚflagsrrrÚprocessflagswriteVsüûr!cCst|||dƒS)aInspect revision data flags and applies read transformations defined by registered flag processors. ``text`` - the revision data to process ``flags`` - the revision flags ``raw`` - an optional argument describing if the raw transform should be applied. This method processes the flags in the order (or reverse order if ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the flag processors registered for present flags. The order of flags defined in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity. Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the processed text and ``validatehash`` is a bool indicating whether the returned text should be checked for hash integrity. óreadrrrrrÚprocessflagsreadnsr#cCst|||dƒdS)a—Inspect revision data flags to check is the content hash should be validated. ``text`` - the revision data to process ``flags`` - the revision flags This method processes the flags in the order (or reverse order if ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the flag processors registered for present flags. The order of flags defined in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity. Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the processed text and ``validatehash`` is a bool indicating whether the returned text should be checked for hash integrity. órawrrrrrrÚprocessflagsrawƒsr%c Cs|dkr|dfS|dvrt tdƒ|¡‚|t@r&| tdƒ|t@¡‚d}t}|dkr2t|ƒ}|D]G}||@r{d}||jvrLtdƒ|}| |¡‚|j|} | durw| \} } } |d krd| ||ƒ}n|d krp| ||ƒ\}}n| ||ƒ\}}|oz|}q4||fS) zŒinternal function to process flag on a revlog This function is private to this module, code should never needs to call it directly.rT)r"rr$sinvalid '%s' operations incompatible revision flag '%#x'rs missing processor for flag '%#x'Nr$r")r rrrÚ_flagserrorclassr ÚreversedÚ_flagprocessors) rrr Ú operationÚ validatehashÚ orderedflagsrÚvhashÚmessagerÚ readtransformÚwritetransformÚ rawtransformrrrr–s> ÿÿ      €r)Ú __future__rÚi18nrÚ constantsrrrr r r r Úr rÚbitsfromrrrrr!r#r%rrrrrÚs*  $  þ