
    6h                        S SK Jr  SSKJr  SSKJrJrJrJrJ	r	J
r
Jr  SSKJrJr  \
  \  \  \	4  \  \  \  \R                  " \5      r\
S\	S0rS rS	 rS
 rS rS rS rg)    )annotations   )_   )REVIDX_DEFAULT_FLAGSREVIDX_ELLIPSISREVIDX_EXTSTOREDREVIDX_FLAGS_ORDERREVIDX_HASCOPIESINFOREVIDX_ISCENSOREDREVIDX_RAWTEXT_CHANGING_FLAGS)errorutilNc                $    [        X[        5        g)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	processors     @/usr/lib/python3/dist-packages/mercurial/revlogutils/flagutil.pyaddflagprocessorr   -   s    2 8    c                   U [         -  (       d$  [        S5      U -  n[        R                  " U5      eU [        ;  a$  [        S5      U -  n[        R                  " U5      eX;   a$  [        S5      U -  n[        R
                  " U5      eXU '   g )Ns0   cannot register processor on unknown flag '%#x'.s+   flag '%#x' undefined in REVIDX_FLAGS_ORDER.s2   cannot register multiple processors on flag '%#x'.)REVIDX_KNOWN_FLAGSr   r   ProgrammingErrorr
   Abort)r   r   r   msgs       r   r   r   I   s    $$CDtK$$S))%%>?$F$$S))EFMkk#$4r   c                $    [        U UUS5      S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flagss      r   processflagswriter%   V   s)      	
 	q
 
r   c                    [        XUS5      $ )a  Inspect 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.
   readr   r!   s      r   processflagsreadr(   n   s    $ V5'::r   c                "    [        XUS5      S   $ )ak  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.
   rawr   r   r!   s      r   processflagsrawr+      s      V5&9!<<r   c                P   US:X  a  US4$ US;  a"  [         R                  " [        S5      U-  5      eU[        ) -  (       a%  U R	                  [        S5      U[        ) -  -  5      eSn[
        nUS:X  a  [        U5      nU H  nXb-  (       d  M  SnX`R                  ;  a4  SnU[        :X  a  [        S5      n[        S	5      U-  n	U R	                  XS
9eU R                  U   n
U
b/  U
u  pnUS:X  a	  U" X5      nOUS:X  a  U" X5      u  pO
U" X5      u  pU=(       a    UnM     X4$ )zinternal function to process flag on a revlog

This function is private to this module, code should never needs to call it
directly.r   T)r'   r   r*   s   invalid '%s' operations    incompatible revision flag '%#x'r   Ns!   the lfs extension must be enableds    missing processor for flag '%#x')hintr*   r'   )	r   r   r   r   _flagserrorclassr
   reversed_flagprocessorsr	   )r"   r#   r$   	operationvalidatehashorderedflagsr   vhashr-   messager   readtransformwritetransformrawtransforms                 r   r    r       s]    zTz33$$Q'@%AI%MNN"""%%12***,
 	
 L &LH- <<E111++ABD?@4G--g-AA..t4I$>G;|&(6E')"/"=KD%"0">KD'1EL1 4 r   )
__future__r   i18nr   	constantsr   r   r	   r
   r   r   r    r   r   bitsfromr   r   r   r   r%   r(   r+   r     r   r   <module>r?      s~    #             ]]#56  t$98
%
0;*=&1r   