
    	^c+                         d dl mZ ddlmZmZmZmZmZmZm	Z	 d dl
mZmZ e e e ef e e e	  ej        e          ZedediZd Zd Zd Zd	 Zd
 Zd ZdS )   )_   )REVIDX_DEFAULT_FLAGSREVIDX_ELLIPSISREVIDX_EXTSTOREDREVIDX_FLAGS_ORDERREVIDX_HASCOPIESINFOREVIDX_ISCENSOREDREVIDX_RAWTEXT_CHANGING_FLAGS)errorutilNc                 2    t          | |t                     dS )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 i88888    c                 "   | t           z  s&t          d          | z  }t          j        |          | t          vr&t          d          | z  }t          j        |          | |v r&t          d          | z  }t          j        |          ||| <   d S )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   H   s    $$ *CDDtK$S)))%%%>??$F$S)))~EFFMk#$N4r   c                 6    t          | ||d          dd         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#   U   s0      	 
 	qb
 
r   c                 &    t          | ||d          S )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&   m   s    $ VT5':::r   c                 2    t          | ||d          d         S )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.
       rawr   r   r   s      r   processflagsrawr)      s      VT5&99!<<r   c                 6   |dk    r|dfS |dvr$t          j        t          d          |z            |t           z  r.|                     t          d          |t           z  z            d}t
          }|dk    rt          |          }|D ]}||z  rd}|| j        vr't          d          |z  }|                     |          | j        |         }	|	>|	\  }
}}|d	k    r || |          }n%|d
k    r |
| |          \  }}n || |          \  }}|o|}||fS )zinternal function to process flag on a revlog

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