
    	^cY,                       d dl Z d dlZd dlZd dlZddlmZ ddlmZmZm	Z	 ddl
mZ ddlmZmZmZmZmZmZm
Z
mZmZ ddlmZmZ ddlmZ  ej        d	          Zej        Zd
Zd Z d Z! G d d          Z" G d d          Z#d Z$d Z%h dZ& G d d          Z'	 ej(        Z'n# e)$ r Y nw xY w ej*        ej+                   G d d                      Z,d6dZ-d Z.d Z/d Z0d Z1 ej*        ej+                   G d d                      Z2 G d d ej3                  Z4d!Z5 G d" d#e6          Z7 ej*        ej8                   G d$ d%                      Z9 ej*        ej:                   G d& d'                      Z; ej*        ej<                   G d( d)                      Z= ej*        ej>                   G d* d+                      Z? ej*        ej<                   G d, d-                      Z@ ej*        ej>                   G d. d/                      ZA G d0 d1e2          ZB G d2 d3eA          ZC G d4 d5e9          ZDdS )7    N   )_)binhexnullrev)getattr)	encodingerrormatchmdiffpathutilpolicypycompatrevlogutil)
repositoryr   )	constantsparsersi  c              #     K   |r|dd          dk    rt          d          d }|                                D ]}|||k    rt          d          |}|                    d          \  }}t          |          }|dd          }|t          v r|d d         }|dz  }nd}|d| z  k    rt          d	          |t          |          |fV  d S )
N   
"   Manifest did not end in a newline.#   Manifest lines not in sorted order.    r             Invalid manifest line)
ValueError
splitlinessplitlen_manifestflagsr   )nodelendataprevlfnnlflagss           4/usr/lib/python3/dist-packages/mercurial/manifest.py_parser,   /   s	       @RSS	U"">???D__  qCDDDwwu~~1VV"##N""#2#A!GBBEW5666Q r   c                     g }g }| D ]C\  }}}|                     |           |                     d|t          |          |fz             Dt          |           d                    |          S )N   %s %s%s
r   )appendr   _checkforbiddenjoin)itfileslinesr'   r(   fls         r+   _textr6   J   sv    EE 6 61bQ 	]aQ_45555E88E??r   c                   $    e Zd Zd Zd Zd ZeZdS )lazymanifestiterc                 "    d| _         || _        d S Nr   )poslmselfr<   s     r+   __init__zlazymanifestiter.__init__X   s    r   c                     | S N r>   s    r+   __iter__zlazymanifestiter.__iter__\       r   c                    	 | j                             | j                  \  }}n# t          $ r t          w xY w|dk    r| xj        dz  c_        |d         S | xj        dz  c_        |                    d|          }|||         S )Nr   r   r   r   )r<   _getr;   
IndexErrorStopIterationfind)r>   r$   r;   zeroposs       r+   nextzlazymanifestiter.next_   s    	 TX..ID## 	  	  	 	 "99HHMHH7NA))GS))CK     "% 7N__name__
__module____qualname__r?   rD   rL   __next__rB   r   r+   r8   r8   W   sB            
! 
! 
! HHHr   r8   c                   $    e Zd Zd Zd Zd ZeZdS )lazymanifestiterentriesc                 "    || _         d| _        d S r:   )r<   r;   r=   s     r+   r?   z lazymanifestiterentries.__init__o   s    r   c                     | S rA   rB   rC   s    r+   rD   z lazymanifestiterentries.__iter__s   rE   r   c                 v   	 | j                             | j                  \  }}n# t          $ r t          w xY w|dk    r| xj        dz  c_        |S |                    d|          }|                    d|          }|dk    s|dk    s||k     rt          j        d          ||dz
  |         }|t          v r	||z
  dz
  }n
||z
  dz
  }d}|d| j         j	        z  k    rt          j        d          t          || j         j        | j                 |dz   |          }| xj        dz  c_        |||         ||fS )Nr   r   r   r   r   r   r   )r<   rG   r;   rH   rI   rJ   r
   StorageErrorr"   _nodelen	unhexlify	extrainfo)r>   r$   r;   rK   nlposr*   hlenhashvals           r+   rL   zlazymanifestiterentries.nextv   sh   	 TX..ID## 	  	  	 	 "99HHMHHK))GS))		%%%b==ERKK57??$%=>>>UQY&'N""7?Q&DD7?Q&DE1tw''''$%=>>>$'#DH-w{D
 
 	AS[!7E22rM   NrN   rB   r   r+   rT   rT   n   sB            3 3 34 HHHr   rT   c                 h    t          | |||z                      }|r|t          |dz            z  }|S )N   )r   chr)r$   extrar;   lengthss        r+   rZ   rZ      s@    DsV|#$%%A 	SHr   c                     | |k    | |k     z
  S rA   rB   )abs     r+   _cmprh      s    Ea!er   >   r      l   t   xc                       e Zd ZdZ	 	 	 	 ddZd Zd Zd Zd Zd	 Z	d
 Z
d Zd Zd Zd Zd Zd Zd ZddZd Zd Zd Zd Zd ZdS )_lazymanifesta  A pure python manifest backed by a byte string.  It is supplimented with
    internal lists as it is modified, until it is compacted back to a pure byte
    string.

    ``data`` is the initial manifest data.

    ``positions`` is a list of offsets, one per manifest entry.  Positive
    values are offsets into ``data``, negative values are offsets into the
    ``extradata`` list.  When an entry is removed, its entry is dropped from
    ``positions``.  The values are encoded such that when walking the list and
    indexing into ``data`` or ``extradata`` as appropriate, the entries are
    sorted by filename.

    ``extradata`` is a list of (key, hash, flags) for entries that were added or
    modified since the manifest was created or compacted.
    NFc                 *   || _         |N|                     |          | _        dgt          | j                  z  | _        || _        g | _        d| _        d S |d d          | _        |d d          | _        |d d          | _        || _        || _        d S )Nr   F)rY   	findlines	positionsr!   r[   r$   	extradatahasremovals)r>   r#   r$   rp   r[   rq   rr   s          r+   r?   z_lazymanifest.__init__   s      !^^D11DNS3t~#6#66DNDIDN$D&qqq\DN&qqq\DN&qqq\DNDI*Dr   c                    |sg S |                     d          }|dk    s|dd          dk    rt          d          dg}|d |                     d                   }|t          |          dz
  k     r|dk    r|                    |dz              ||dz   |                     d|dz                      }||k     rt          d          |}|                     d|dz             }|t          |          dz
  k     r|dk    |S )Nr   r   r   r   r   r   r   )rJ   r   r!   r/   )r>   r$   r;   rp   r%   nextss         r+   ro   z_lazymanifest.findlines   s"    	Iii"99RSS	U**BCCCC	(dii((()CIIM!!cRiiS1W%%%q499WcAg#>#>>?Et|| !GHHHD))E37++C CIIM!!cRii r   c                 `    | j         |         }|dk    r	| j        |fS | j        | dz
           dfS )Nr   r   r   )rp   r$   rq   )r>   indexr;   s      r+   rG   z_lazymanifest._get   s=     nU#!889c>!~sdQh'++r   c                     |dk    r+| j         || j                             d|dz                      S | j        | dz
           d         S )Nr   r   r   )r$   rJ   rq   )r>   r;   s     r+   _getkeyz_lazymanifest._getkey   sI    !889S49>>'37#C#CCDD~sdQh'**r   c                     d}t          | j                  dz
  }||k    rY||z   dz  }| j        |         }|                     |          }t          ||          }|dk    r|S |dk     r|dz
  }n|dz   }||k    YdS )Nr   r   r   r   r!   rp   rx   rh   r>   keyfirstlastmidpointnextpos	candidaters           r+   bsearchz_lazymanifest.bsearch   s    4>""Q&tmm*HnX.GW--IS)$$AAvvq55#a<DD$qLE tmm rr   c                     d}t          | j                  dz
  }||k    r[||z   dz  }| j        |         }|                     |          }t          ||          }|dk    r|dfS |dk     r|dz
  }n|dz   }||k    [|dfS )Nr   r   r   TFrz   r{   s           r+   bsearch2z_lazymanifest.bsearch2   s     4>""Q&tmm*HnX.GW--IS)$$AAvv $''q55#a<DD$qLE tmm u~r   c                 4    |                      |          dk    S Nr   )r   r>   r|   s     r+   __contains__z_lazymanifest.__contains__  s    ||C  B&&r   c                    t          |t                    st          d          |                     |          }|dk    rt          |                     |          \  }}|dk    r|d         |d         fS |                    d|          }|                    d|          }d|cxk    rt          | j                  k    sn J t          | j	                  t          | j                  k    sJ |dk    s|dk    s||k     rt          j        d          ||z
  dz
  }||dz
  |         }|t          v r|dz  }nd	}|d| j        z  k    rt          j        d          t          || j	        |         |dz   |          }	|	|fS )
Ns'   getitem: manifest keys must be a bytes.r   r   r   r   r   r   r   r   )
isinstancebytes	TypeErrorr   KeyErrorrG   rJ   r!   rp   r[   r
   rX   r"   rY   rZ   )
r>   r|   needler$   r;   rK   r\   r]   r*   r^   s
             r+   __getitem__z_lazymanifest.__getitem__  s   #u%% 	HFGGGc""R<<NIIf%%	c"99GT!W%%))GS))		%))F1111c$.111111114>""c$.&9&99999b==ERKK57??$%=>>>w"UQY&'N""AIDDE1t}$$$$%=>>>D$."8'A+tLLr   c                 p   |                      |          \  }}|st          | j        |         }| j        d |         | j        |dz   d          z   | _        | j        d |         | j        |dz   d          z   | _        |dk    r3| j        d |         dz   | j        |dz   d          z   | _        d| _        d S d S )Nr   r   r   T)r   r   rp   r[   r$   rr   )r>   r|   r   foundcurs        r+   __delitem__z_lazymanifest.__delitem__,  s    c** 	NnV$04>&1*,,3OO04>&1*,,3OO!88 	$3$'1DIcAgii4HHDI#D	 8r   c                    t          |t                    st          d          t          |t                    rt	          |          dk    rt          d          |d         }t          |t                    rt	          |          dvrt          d          |d         }t          |t                    rt	          |          dk    rt          d|          |                     |          \  }}|rn| j        |         }|dk     r|||d         f| j        | dz
  <   d S | j                            |||d         f           t	          | j                   | j        |<   d S | j                            |||d         f           | j        d |         t	          | j                   gz   | j        |d          z   | _        | j	        d |         dgz   | j	        |d          z   | _	        d S )	Ns-   setitem: manifest keys must be a byte string.r   s1   Manifest values must be a tuple of (node, flags).r          s-   node must be a 20-byte or 32-byte byte stringr   s'   flags must a 0 or 1 byte string, got %r)
r   r   r   tupler!   r   rp   rq   r/   r[   )r>   r|   valuer^   r*   r   r   r;   s           r+   __setitem__z_lazymanifest.__setitem__9  s   #u%% 	NLMMM%'' 	3u::??D   ('5)) 	NS\\-I-ILMMMa%'' 	O3u::>>FNNNc** 	.(CQww,/%(+Ctax((( %%sGU1X&>???*-dn*=*=)=v&&& N!!3q":;;;ww''''().)* N ww'1#-vww0GG NNNr   c                 f    t          | j        | j        | j        | j        | j        | j                  S rA   )rm   rY   r$   rp   r[   rq   rr   rC   s    r+   copyz_lazymanifest.copy\  s3    MINNN
 
 	
r   c                 z   t          | j                  dk    r	| j        sd S g }d}d}dgt          | j                  z  | _        |t          | j                  k     r5| j        |         dk    r| j        |         }|}	 || j        |<   |dz  }|t          | j                  k    s| j        |         dk     rnT| j        r,| j                            d|| j        |                   dk    rn!|| j        |         |z
  z  }| j        |         }| j                            d|          }|dk    r|dz  }|||z
  z  }|                    | j        ||                    n|t          | j                  k     r| j        |         dk     r| j        |         }| j        | dz
           }|                    |                     |                     || j        |<   d}t          |d                   dk    rd	}t          |d                   |k    r&t          |d         |dz                      | j        |<   |t          |d                   z  }|dz  }|t          | j                  k     r| j        |         dk     |t          | j                  k     5d

                    |          | _        d| _        g | _        d S )Nr   Tr   s   
 r   r   r      r   r   F)r!   rq   rr   rp   r[   r$   rJ   r/   _packordr1   )	r>   r&   ioffsetr   last_cutend_cuttr]   s	            r+   _compactz_lazymanifest._compactg  s   t~!##D,<#Fs4>222#dn%%%%~a A%%nQ'
,(.DN1%FAC////4>!3Dq3H3H ( INN9c4>!;LMM  dnQ/#55F.+C%,& )..44b==qLG'C-'8G#345555#dn----$.2Ca2G2G.+Ctax0AHHTZZ]]+++(.DN1% D1Q4yy2~~!1Q4yy4'',/!TAX,?,?q)c!B%jj(FFA #dn----$.2Ca2G2GC #dn%%%%^ HHQKK	 r   c                     |d         }t          |          dv sJ |d         dz   t          |          z   |d         z   dz   S )Nr   r   r   r   r   r   )r!   r   )r>   dr(   s      r+   r   z_lazymanifest._pack  sI    aD1vv!!!!tg~A&1-55r   c                 8    |                                   | j        S rA   )r   r$   rC   s    r+   textz_lazymanifest.text  s    yr   c                     i }|                                  D ]5\  }}}||vr
||fdf||<   ||         }||f|k    r
||f|f||<   .|rd||<   6|                                 D ]\  }}}|| vr	d||ff||<   |S )z2Finds changes between the current manifest and m2.Nr   N)iterentries)r>   m2cleandifffne1r*   e2s           r+   r   z_lazymanifest.diff  s     !--// 	$ 	$MBE||;3RV;"$$ "E{BDHH $#DH^^-- 	4 	4MBE~~&U3Rr   c                      t          |           S rA   )rT   rC   s    r+   r   z_lazymanifest.iterentries  s    &t,,,r   c                      t          |           S rA   r8   rC   s    r+   iterkeysz_lazymanifest.iterkeys      %%%r   c                      t          |           S rA   r   rC   s    r+   rD   z_lazymanifest.__iter__  r   r   c                 *    t          | j                  S rA   )r!   rp   rC   s    r+   __len__z_lazymanifest.__len__  s    4>"""r   c                     t          | j        d          }|                                 D ]\  }}} ||          r||f||<   |S r   )rm   rY   r   )r>   filterfncr'   r(   r5   s         r+   
filtercopyz_lazymanifest.filtercopy  sW    $---((** 	 	HAq"x{{ "u!r   )NNNFF)rO   rP   rQ   __doc__r?   ro   rG   rx   r   r   r   r   r   r   r   r   r   r   r   r   r   rD   r   r   rB   r   r+   rm   rm      sd        * + + + +.  ", , ,+ + +
  $  (' ' '     4$ $ $! ! !F	
 	
 	
9 9 9v6 6 6
     *- - -& & && & &# # #    r   rm   c                       e Zd Zd dZd Zd Zd Zd ZeZd Z	d Z
d	 Zd
 Zd Zd Zd!dZed             Zd Zd Zd Zd Zd Zd"dZd Zd!dZd Zd Zd Zd Zd Zd Zd Z dS )#manifestdictr   c                 >    || _         t          ||          | _        d S rA   )rY   rm   _lm)r>   r#   r$   s      r+   r?   zmanifestdict.__init__  s     $//r   c                 (    | j         |         d         S r:   r   r   s     r+   r   zmanifestdict.__getitem__  s    x}Qr   c                     | j         |         S rA   r   r   s     r+   rJ   zmanifestdict.find  s    x}r   c                 *    t          | j                  S rA   r!   r   rC   s    r+   r   zmanifestdict.__len__  s    48}}r   c                 2    t          | j                  dk    S r:   r   rC   s    r+   __nonzero__zmanifestdict.__nonzero__  s     48}}!!r   c                 D    ||                      |          f| j        |<   d S rA   )r*   r   )r>   r|   nodes      r+   r   zmanifestdict.__setitem__  s     djjoo-r   c                     |dS || j         v S NFr   r   s     r+   r   zmanifestdict.__contains__  s    ;5dhr   c                     | j         |= d S rA   r   r   s     r+   r   zmanifestdict.__delitem__  s    HSMMMr   c                 4    | j                                         S rA   )r   rD   rC   s    r+   rD   zmanifestdict.__iter__      x  """r   c                 4    | j                                         S rA   )r   r   rC   s    r+   r   zmanifestdict.iterkeys  r   r   c                 D    t          |                                           S rA   listr   rC   s    r+   keyszmanifestdict.keys      DMMOO$$$r   Nc                     |Yt          j        |d           }t                              |                    fd|                     |          D             S fd| D             S )7Set of files in this manifest that are not in the otherNc                     d S rA   rB   )pathmsgs     r+   <lambda>z)manifestdict.filesnotin.<locals>.<lambda>  s    t r   c                     h | ]}|v|	S rB   rB   ).0r'   sm2s     r+   	<setcomp>z*manifestdict.filesnotin.<locals>.<setcomp>
  s    @@@!1C<<A<<<r   c                     h | ]}|v|	S rB   rB   )r   r'   r   s     r+   r   z*manifestdict.filesnotin.<locals>.<setcomp>  s    ///a1B;;;;;r   )matchmodbadmatchsetwalk)r>   r   r   r   s    ` @r+   
filesnotinzmanifestdict.filesnotin  sw    %e-C-CDDEbggenn%%C@@@@tyy//@@@@////4////r   c                 *    t          j        |           S rA   r   dirsrC   s    r+   _dirszmanifestdict._dirs      }T"""r   c                     | j         S rA   r   rC   s    r+   r   zmanifestdict.dirs  
    zr   c                     || j         v S rA   r   )r>   dirs     r+   hasdirzmanifestdict.hasdir  s    dj  r   c                      |                                 }t          |          dk     oB|                                p.|                                ot	           fd|D                       S )znChecks whether we can correctly and quickly iterate over matcher
        files instead of over manifest files.d   c              3       K   | ]}|v V  	d S rA   rB   )r   r   r>   s     r+   	<genexpr>z.manifestdict._filesfastpath.<locals>.<genexpr>  s'      &B&BbrTz&B&B&B&B&B&Br   )r3   r!   isexactprefixall)r>   r   r3   s   `  r+   _filesfastpathzmanifestdict._filesfastpath  sh     5zzC 
MMOO DB3&B&B&B&BE&B&B&B#B#B	
r   c              #     K   |                                 rt          |           D ]}|V  dS t          |                                          }|                     |          rt          |          D ]
}|| v r|V  dS | D ]*}||v r|                    |            ||          r|V  +|                    d           t          |          D ]-}|                     |          s|	                    |d           .dS )zGenerates matching file names.

        Equivalent to manifest.matches(match).iterkeys(), but without creating
        an entirely new manifest.

        It also reports nonexistent files by marking them bad with match.bad().
        Nr   )
alwaysiterr   r3   r   sortedremovediscardr   badr>   r   r'   fsetr   s        r+   r   zmanifestdict.walk   s2      <<>> 	$ZZ  F5;;==!! u%% 	Tll  ::HHHF 	 	BTzzBuRyy  	S,, 	$ 	$B;;r?? $		"d###	$ 	$r   c                 v   |                                 r|                                 S |                     |          rHt          | j                  }| j        }|                                D ]}||v r||         |j        |<   |S t          | j                  }| j                            |          |_        |S )z6generate a new manifest filtered by the match argument)r   r   r   r   rY   r   r3   r   )r>   r   mr<   r   s        r+   _matcheszmanifestdict._matchesE  s    <<>> 	99;;u%% 	T]++ABkkmm ' '88 "2AE"IH''##E**r   Fc                     |rA|                      |          }|                     |          }|                    ||          S | j                            |j        |          S )z  Finds changes between the current manifest and m2.

        Args:
          m2: the manifest to which this manifest should be compared.
          clean: if true, include files unchanged between these manifests
                 with a None value in the returned dictionary.

        The result is returned as a dict with filename as key and
        values of the form ((n1,fl1),(n2,fl2)), where n1/n2 is the
        nodeid in the current/other manifest and fl1/fl2 is the flag
        in the current/other manifest. Where the file does not exist,
        the nodeid will be None and the flags will be the empty
        string.
        r   )r	  r   r   )r>   r   r   r   m1s        r+   r   zmanifestdict.diffV  s\      	,u%%BU##B772U7+++x}}RVU+++r   c                 Z    |t           vrt          d          | |         |f| j        |<   d S )N   Invalid manifest flag set.)r"   r   r   )r>   r|   flags      r+   setflagzmanifestdict.setflagk  s3    ~%%9:::S	4r   c                 N    	 | j         |         d         S # t          $ r |cY S w xY wr:   r   r   )r>   r|   defaults      r+   getzmanifestdict.getp  s<    	8C=## 	 	 	NNN	s    $$c                 L    	 | j         |         d         S # t          $ r Y dS w xY w)Nr   r   r  r   s     r+   r*   zmanifestdict.flagsv  s:    	8C=## 	 	 	33	s    
##c                 j    t          | j                  }| j                                        |_        |S rA   )r   rY   r   r   )r>   r   s     r+   r   zmanifestdict.copy|  s'    ''r   c                 H    d | j                                         D             S )Nc              3   *   K   | ]}|d d         V  d S Nr   rB   r   xs     r+   r   z%manifestdict.items.<locals>.<genexpr>  *      66!"1"666666r   r   r   rC   s    r+   itemszmanifestdict.items  $    66tx33556666r   c                 H    d | j                                         D             S )Nc              3   *   K   | ]}|d d         V  d S r  rB   r  s     r+   r   z)manifestdict.iteritems.<locals>.<genexpr>  r  r   r  rC   s    r+   	iteritemszmanifestdict.iteritems  r   r   c                 4    | j                                         S rA   r  rC   s    r+   r   zmanifestdict.iterentries  s    x##%%%r   c                 4    | j                                         S rA   )r   r   rC   s    r+   r   zmanifestdict.text  s    x}}r   c                 h   g }d}d}dg}d}t          j        |          }t          |          }t          |          t          k     r|D ]\  }	}
t          ||	|          \  }}|
s&| j        |	         \  }}d|	t          |          |fz  }n'||k    rt          t          d          |	z            d}|,||k    r&||k    r ||k     r|}|r|
                    |           |+|
                    ||d                    |          g           |}|}|g}|+|
                    ||d                    |          g           t          ||          \  }}nZt          |                                           }t          j        t          j        |          t          j        |                    }||fS )zGiven a base manifest text as a bytearray and a list of changes
        relative to that text, compute a delta that can be used by revlog.
        Nr   r   r.   s!   failed to remove %s from manifest)r   bufferr   r!   FASTDELTA_TEXTDIFF_THRESHOLD_msearchr   r   AssertionErrorr   r/   r1   _addlistdelta	bytearrayr   r   textdiff)r>   basechangesdeltadstartdenddlinestartaddbufr'   todeleteendhr5   r&   	deltatext	arraytexts                    r+   	fastdeltazmanifestdict.fastdelta  s    T""w--w<<666  '    8%fa77
s 	 HQKEAr%CFFB7AA||,BCCaG   A%&E//demmczz" (Q)fdCHHUOO%DEEE"FDCEE!fdCHHUOO<===#0u#=#= Iyy "$))++..ID!!4;y#9#9 I )##r   r   rA   r   )!rO   rP   rQ   r?   r   rJ   r   r   __bool__r   r   r   rD   r   r   r   propertycacher   r   r   r   r   r	  r   r  r  r*   r   r  r#  r   r   r;  rB   r   r+   r   r     s       0 0 0 0         " " "
 H. . .  
  # # ## # #% % %0 0 0 0 # # ]#  ! ! !
 
 
#$ #$ #$J  ", , , ,*( ( (
       
7 7 77 7 7& & &  5$ 5$ 5$ 5$ 5$r   r   c                    	 	 fd}|s||fS t                     	|s	}||k     r||z   dz  }|}|dk    r- |dz
  |         dk    r|dz  }|dk    r |dz
  |         dk     ||d          }t           ||                   |k     r ||dz   d          dz   }n|}||k      ||d          } ||         }||k    r ||dz   d          }||dz   fS ||fS )aE  return a tuple (start, end) that says where to find s within m.

    If the string is found m[start:end] are the line containing
    that string.  If start == end the string was not found and
    they indicate the proper sorted insertion point.

    m should be a buffer, a memoryview or a byte string.
    s is a byte stringc                 n    | k     r-| | dz            |k    r| dz  } | k     r| | dz            |k    | S )Nr   rB   )r   r   lenmr  s     r+   advancez_msearch.<locals>.advance  sQ    $hh1QQY<1,,FA $hh1QQY<1,,r   r   r   r   r   r   (   )r!   r   )
r  rd   lohirB  midr4  r7  r   rA  s
   `        @r+   r)  r)    sf        
  Bxq66D 
r''Bw1naiiAeai%/0E99QJE aiiAeai%/0E99geU##59"" r5))A-BB B r'' '"e

CbfIEEzzgcBh&&C!G}Bxr   c                     | D ]@}d|v sd|v r6t          j        t          d          t          j        |          z            AdS )z'Check filenames for illegal characters.r      s)   '\n' and '\r' disallowed in filenames: %rN)r
   rX   r   r   bytestr)r&   r'   s     r+   r0   r0     se      A::!$@AA"1%%&   $ r   c                     d}t                      }|D ])\  }}}|| ||         z  }|r|t          |          z  }|}*|| |d          z  }d                    d |D                       }||fS )Nr   r   c           	   3   l   K   | ]/\  }}}t          j        d ||t          |                    |z   V  0dS )s   >lllN)structpackr!   )r   r4  r7  contents       r+   r   z _addlistdelta.<locals>.<genexpr>  sW        E3 	GUCW66@     r   )r,  r1   )addlistr  currentposition
newaddlistr4  r7  rN  r9  s           r+   r+  r+    s     OJ   sGgoe344
 	-)G,,,J'/**++J  #$    I j  r   c                 R    d| v r |                      dd          \  }}|dz   |fS d| fS )N   /r   r   )r    )r'   r   subpaths      r+   _splittopdirrU    s:    qyywwtQ''WTz7""Avr   c                     d S rA   rB   )rd   s    r+   r   r     s    $ r   c                   X   e Zd Zd1dZd Zd Zd Zd Zd Zd Z	d	 Z
e
Zd
 Zej        d             Zd Zd Zd Zd Zd ZeZd Zd Zd Zd Zd2dZd Zd Zd Zd Zd Zd Z d Z!d Z"d2dZ#e$d              Z%d! Z&d" Z'd# Z(d$ Z)d% Z*d& Z+d' Z,d3d)Z-d* Z.d+ Z/d, Z0d- Z1d. Z2d/ Z3d2d0Z4dS )4treemanifestr   c                 $   || _         || _        | j        j        | _        | j        j        | _        t          | _        t          | _        d| _	        i | _
        i | _        i | _        i | _        |r"d }|                     ||           d| _	        d S d S )NFc                      t          d          )Ns4   treemanifest constructor only accepts flat manifests)r*  )subdirsubms     r+   readsubtreez*treemanifest.__init__.<locals>.readsubtree/  s    $K  r   T)_dirnodeconstantsnullid_noder#   rY   _noop	_loadfunc	_copyfunc_dirtyr   	_lazydirs_files_flagsparse)r>   r_  r   r   r]  s        r+   r?   ztreemanifest.__init__   s    	*'.
*2
 	  
 JJt[)))DKKK	 	r   c                     | j         |z   S rA   r^  )r>   r   s     r+   _subpathztreemanifest._subpath7  s    y4r   c                     | j         }| j        }| j                                        D ]N\  }\  }}}|r+ | ||          |                                          ||<   6 | ||          |          ||<   Oi | _        d S rA   )r   rl  rf  r  r   )r>   selfdirsrT  r   r   r]  docopys          r+   _loadalllazyztreemanifest._loadalllazy:  s    :-.2n.B.B.D.D 	< 	<*A*k6 <)k''!**d;;@@BB)k''!**d;;r   c                 $   | j                             |          }|rs|\  }}}|r: ||                     |          |                                          | j        |<   n' ||                     |          |          | j        |<   | j         |= d S d S rA   )rf  r  rl  r   r   )r>   r   vr   r]  ro  s         r+   	_loadlazyztreemanifest._loadlazyD  s    Nq!! 	"()%D+v D +DMM!,<,<d C C H H J J
1 +DMM!,<,<d C C
1q!!!	" 	"r   c                     |sd S |dk    s|dk    r|                                   d S | j        }|D ]} ||dz              |S )N   all   thisrS  )rp  rs  )r>   visitloadlazyks       r+   _loadchildrensetlazyz!treemanifest._loadchildrensetlazyN  sk     	4F??ew..4> 	 	AHQXr   c                    g }|j                                         D ]H\  }}|j                             |          }|r|d         |d         k    r|                    |           I|j                                         D ]#\  }}||j         vr|                    |           $|D ],}|                    |           |                    |           -dS )am  load items in t1 and t2 if they're needed for diffing.

        The criteria currently is:
        - if it's not present in _lazydirs in either t1 or t2, load it in the
          other (it may already be loaded or it may not exist, doesn't matter)
        - if it's present in _lazydirs in both, compare the nodeid; if it
          differs, load it in both
        r   N)rf  r  r  r/   rs  )r>   t1t2
toloadlazyr   v1v2s          r+   _loaddifflazyztreemanifest._loaddifflazyZ  s     
\'')) 	% 	%EAr!!!$$B %A"Q%!!!$$$\'')) 	% 	%EAr$$!!!$$$ 	 	ALLOOOLLOOOO	 	r   c                     |                                   t          | j                  }|                                  | j                                        D ]}||                                z  }|S rA   )_loadr!   rg  rp  r   valuesr   )r>   sizer  s      r+   r   ztreemanifest.__len__p  sf    

4;""$$ 	  	 AAIIKKDDr   c                 ,    |                                   S rA   _isemptyrC   s    r+   r   ztreemanifest.__nonzero__x  s    ==??""r   c                 B   |                                   | j        s7| j        r2t          d | j                                        D                       rdS |                                  | j         p/t          d | j                                        D                       S )Nc              3   @   K   | ]}|                                  V  d S rA   r  r   r  s     r+   r   z(treemanifest._isempty.<locals>.<genexpr>  s-      MMA1::<</MMMMMMr   Fc              3   >   K   | ]}|                                 V  d S rA   r  r  s     r+   r   z(treemanifest._isempty.<locals>.<genexpr>  s*      $O$OaQZZ\\$O$O$O$O$O$Or   )r  rg  r   anyr  rp  r   rC   s    r+   r  ztreemanifest._isempty~  s    

; 	J	MM9J9J9L9LMMMMM	 5:~O$O$O4:;L;L;N;N$O$O$O!O!OOr   c                     d| j         t          | j                  t          | j        t
          u           | j        t          |           fz  S )Ns;   <treemanifest dir=%s, node=%s, loaded=%r, dirty=%r at 0x%x>)r^  r   ra  boolrc  rb  re  idrC   s    r+   __repr__ztreemanifest.__repr__  sG     K	DJT^u,--4		
r   c                     | j         S )z}The directory that this tree manifest represents, including a
        trailing '/'. Empty string for the repo root directory.rk  rC   s    r+   r   ztreemanifest.dir  s     yr   c                 "    | j         rJ | j        S )zThis node of this instance. nullid for unsaved instances. Should
        be updated when the instance is read or written from a revlog.
        re  ra  rC   s    r+   r   ztreemanifest.node  s     ;zr   c                 "    || _         d| _        d S r   )ra  re  r>   r   s     r+   setnodeztreemanifest.setnode  s    
r   c              #     K   |                                   |                                  t          t          j        | j                                        | j                                                            D ]]\  }}|| j        v r4|                     |          || j	        
                    |d          fV  B|                                D ]}|V  ^d S r   )r  rp  r  	itertoolschainr   r  rg  rl  rh  r  r   )r>   pr(   r  s       r+   r   ztreemanifest.iterentries  s      

ODJ,,..0A0A0C0CDD
 
 	 	DAq DKmmA&&4;??1c+B+BBBBBB  AGGGG	 	r   c              #     K   |                                   |                                  t          t          j        | j                                        | j                                                            D ]H\  }}|| j        v r|                     |          |fV  (|                                D ]\  }}||fV  Id S rA   )	r  rp  r  r  r  r   r  rg  rl  )r>   r  r(   r'   sns        r+   r  ztreemanifest.items  s      

ODJ,,..0A0A0C0CDD
 
 	  	 DAq DKmmA&&)))))WWYY    EArR%KKKK 	  	 r   c              #   "  K   |                                   |                                  t          t          j        | j        | j                            D ]7}|| j        v r|                     |          V  #| j        |         D ]}|V  8d S rA   )r  rp  r  r  r  r   rg  rl  )r>   r  r'   s      r+   r   ztreemanifest.iterkeys  s      

	
DK@@AA 	 	ADKmmA&&&&&&A  AGGGG		 	r   c                 D    t          |                                           S rA   r   rC   s    r+   r   ztreemanifest.keys  r   r   c                 *    |                                  S rA   )r   rC   s    r+   rD   ztreemanifest.__iter__  s    }}r   c                     |dS |                                   t          |          \  }}|r@|                     |           || j        vrdS | j        |                             |          S || j        v S r   )r  rU  rs  r   r   rg  r>   r'   r   rT  s       r+   r   ztreemanifest.__contains__  s{    95

#AW 	$NN3$*$$u:c?//888##r   Nc                 
   |                                   t          |          \  }}|rA|                     |           || j        vr|S | j        |                             ||          S | j                            ||          S rA   )r  rU  rs  r   r  rg  )r>   r'   r  r   rT  s        r+   r  ztreemanifest.get  s|    

#AW 	/NN3$*$$:c?&&w888;??1g...r   c                     |                                   t          |          \  }}|r5|                     |           | j        |                             |          S | j        |         S rA   )r  rU  rs  r   r   rg  r  s       r+   r   ztreemanifest.__getitem__  s^    

#AW 	"NN3:c?..w777;q>!r   c                 0   |                                   t          |          \  }}|r@|                     |           || j        vrdS | j        |                             |          S || j        v s	|| j        v rdS | j                            |d          S r   )r  rU  rs  r   r*   rf  rh  r  r  s       r+   r*   ztreemanifest.flags  s    

#AW 		+NN3$*$$s:c?((111DN""a4:oos;??1c***r   c                    |                                   t          |          \  }}|r5|                     |           | j        |                             |          S | j        |         | j                            |d          fS r   )r  rU  rs  r   rJ   rg  rh  r  r  s       r+   rJ   ztreemanifest.find  ss    

#AW 	;NN3:c?''000;q>4;??1c#:#:::r   c                 P   |                                   t          |          \  }}|r]|                     |           | j        |                             |           | j        |                                         r| j        |= n| j        |= || j        v r| j        |= d| _        d S NT)	r  rU  rs  r   r   r  rg  rh  re  r  s       r+   r   ztreemanifest.__delitem__  s    

#AW 
	#NN3JsO''000z#'')) $JsOADKKNr   c                    |J |                                   t          |          \  }}|rp|                     |           || j        vr0t	          | j        |                     |                    | j        |<   | j        |                             ||           nt          |          dv sJ || j	        |<   d| _
        d S )Nr   T)r  rU  rs  r   rX  r_  rl  r   r!   rg  re  )r>   r'   r(   r   rT  s        r+   r   ztreemanifest.__setitem__  s    }}}

#AW 	NN3$*$$".&c(:(:# #
3 JsO''3333
 q66X%%%%DKNr   c                     | j         t          ur!| j         t          c}| _          ||            d S | j        t          ur!| j        t          c}| _         ||            d S d S rA   )rc  rb  rd  )r>   lfcfs      r+   r  ztreemanifest._load/  sf    >&&!%BBtHHHHH^5((!%BBtHHHHH )(r   c                    |t           vrt          d          |                                  t          |          \  }}|rp|                     |           || j        vr0t          | j        |                     |                    | j        |<   | j        |         	                    ||           n
|| j
        |<   d| _        dS )z/Set the flags (symlink, executable) for path f.r  TN)r"   r   r  rU  rs  r   rX  r_  rl  r  rh  re  )r>   r'   r*   r   rT  s        r+   r  ztreemanifest.setflag7  s    &&9:::

#AW 	#NN3$*$$".&c(:(:# #
3 JsO##GU3333"DKNr   c                      t           j         j                  } j        |_         j        |_         j        t          u r' fd} j        t          u r ||           n||_        n j        |_        |S )Nc                                                      d j                                        D             | _        | j        }j                                        D ]\  }}|                                ||<   t
                              j                  | _        t
                              j                  | _        d S )Nc                 (    i | ]\  }\  }}}|||d fS TrB   )r   r   r(   r   r   s        r+   
<dictcomp>z8treemanifest.copy.<locals>._copyfunc.<locals>.<dictcomp>P  s7       (49Aq!A1d|  r   )r  rf  r  r   r   dictrg  rh  )rd   sdirsr   rr  r>   s       r+   rd  z$treemanifest.copy.<locals>._copyfuncN  s    

 8<8L8L8N8N    J,,.. ( (DAq vvxxE!HH99T[1199T[11r   )rX  r_  r^  ra  re  rd  rb  rc  )r>   r   rd  s   `  r+   r   ztreemanifest.copyH  s    D.	::Z
k>U""	2 	2 	2 	2 	2 ~&&	$!*!^DNr   c                      |rS|                                 s?                     |          }|                    |          }|                    |          S t                       fd  |           S )r   c                    | j         |j         k    r| j        s	|j        sd S |                                  |                                                     | |           | j                                        D ]O\  }}||j        v r|j        |         } ||           (                    |                                           P| j        D ]3}||j        vr(	                    | 
                    |                     4d S rA   )ra  re  r  r  r   r  updater   rg  addrl  )	r|  r}  r   r  r   r   _filesnotinr3   r>   s	         r+   r  z,treemanifest.filesnotin.<locals>._filesnotinj  s   x28##BI#bi#HHJJJHHJJJr2&&&)) 0 02==!BKB''''LL////i / /RY&&IIbkk"oo.../ /r   )r   r	  r   r   )r>   r   r   r  r  r3   s   `   @@r+   r   ztreemanifest.filesnotina  s     	% 	%u%%BU##B==$$$	/ 	/ 	/ 	/ 	/ 	/ 	/" 	D"r   c                 *    t          j        |           S rA   r   rC   s    r+   _alldirsztreemanifest._alldirs~  r   r   c                     | j         S rA   )r  rC   s    r+   r   ztreemanifest.dirs  s
    }r   c                     |                                   t          |          \  }}|r@|                     |           || j        v r | j        |                             |          S dS |dz   }|| j        v p|| j        v S )NFrS  )r  rU  rs  r   r   rf  )r>   r   topdirr[  dirslashs        r+   r   ztreemanifest.hasdir  s    

%c** 	NN6"""##z&)008885:4:%CT^)CCr   c              #     K   |                                 rt          |           D ]}|V  dS t          |                                          }|                     |          D ]}||v r|                    |           |V   |                    d           t          |          D ]-}|                     |          s|	                    |d           .dS )zxGenerates matching file names.

        It also reports nonexistent files by marking them bad with match.bad().
        Nr   )
r   r   r   r3   _walkr  r  r  r   r  r  s        r+   r   ztreemanifest.walk  s      
 <<>> 	$ZZ  F5;;==!!**U## 	 	BTzzBHHHH 	S,, 	$ 	$B;;r?? $		"d###	$ 	$r   c              #     K   |                     | j        dd                   }|sdS |                                  |                     |          }t	          t          | j                  t          | j                  z             D ]e}|| j        v r%|                     |          } ||          r|V  0|r|dd         |v r'| j        |         	                    |          D ]}|V  fdS )z5Recursively generates matching file names for walk().Nr   )
visitchildrensetr^  r  rz  r  r   r   rg  rl  r  )r>   r   rw  r  fullpr'   s         r+   r  ztreemanifest._walk  s     &&ty"~66 	F 	

))%00TZ((4+<+<<== 	  	 ADKa((5<<  KKK  #2#%!Z]0077    	  	 r   c                 |    |                                 r|                                 S |                     |          S )zCrecursively generate a new manifest filtered by the match argument.)r   r   _matches_inner)r>   r   s     r+   r	  ztreemanifest._matches  s4    <<>> 	99;;""5)))r   c                 &   |                                 r|                                 S |                    | j        d d                   }|dk    r|                                 S t	          | j        | j                  }|s|S |                                  | j        D ]a}|dk    r||vr|                     |          } ||          s.| j        |         |j        |<   || j	        v r| j	        |         |j	        |<   b| 
                    |          }| j                                        D ]G\  }}|r|d d         |vr|                    |          }|                                s
||j        |<   H|                                sd|_        |S )Nr   ru  rv  T)r   r   r  r^  rX  r_  r  rg  rl  rh  rz  r   r  r  r  re  )	r>   r   rw  retr   r  r   r\  r  s	            r+   r  ztreemanifest._matches_inner  s   <<>> 	99;;&&ty"~66F??99;;4-ty99 	J

+ 	1 	1B BeOOMM"%%E 5<< ![_CJrNT[  !%R
2))%00))++ 	# 	#IC SbS..##E**A::<< #!"	#||~~ 	CJ
r   c                     t                      rA   )FastdeltaUnavailable)r>   r.  r/  s      r+   r;  ztreemanifest.fastdelta  s    "$$$r   Fc                 f   	
 |rU|                                 sA                     |          }|                    |          }|                    |          S i 
t           j                  		
 fd}g } | ||           |r&|                                \  }} ||||           |&
S )r  r  c                    | j         |j         k    r| j        s	|j        sdS |                                  |                                                     | |           | j                                        D ]7\  }}|j                            |          }|                    ||f           8|j                                        D ]%\  }}|| j        vr|                    |f           &| j                                        D ]\  }}| j	                            |d          }|j                            |d          }	|j	                            |d          }
||	k    s||
k    r||f|	|
ff| 
                    |          <   rd| 
                    |          <   |j                                        D ]E\  }}	|| j        vr7|j	                            |d          }
d|	|
ff|
                    |          <   FdS )zicompares two tree manifests and append new tree-manifests which
            needs to be compared to stackNr   r   )ra  re  r  r  r   r  r  r/   rg  rh  rl  )r|  r}  stackr   r  r   r   n1fl1n2fl2r   	emptytreeresultr>   s              r+   _iterativediffz)treemanifest.diff.<locals>._iterativediff  s    x28##BI#bi#HHJJJHHJJJr2&&&)) ' '2X\\!Y//b"X&&&&)) 2 22BH$$LL)R111)//++ 3 3BimmB,,Y]]2t,,immB,,88sczz02Cy2s).DF2;;r??++ 3.2F2;;r??+)//++ G GBRY&&)--C00C/:RI.FF2;;r??+G Gr   )r   r	  r   rX  r_  pop)r>   r   r   r   r  r  stacklsr|  r}  r  r  s   `  `     @@r+   r   ztreemanifest.diff  s      	, 	,u%%BU##B772U7+++ !344		G 	G 	G 	G 	G 	G 	G 	G> tR))) 	,[[]]FBN2r7+++  	, r   c                 B    | j          o|j          o| j        |j        k    S rA   r  )r>   r   s     r+   unmodifiedsinceztreemanifest.unmodifiedsince,  s#    ;Kry=KTZ285KKr   c                     | j         }t          | j        |          D ]R\  }}}|dk    r|dz   }||df||<   d|v r|| |<   |r|                     ||           <|| j        |<   |r
|| j        |<   Sd S )Nrj   rS  F)rf  r,   rY   r  rg  rh  )r>   r   r]  selflazyr'   r(   r5   s          r+   ri  ztreemanifest.parse/  s    >t}d33 	( 	(HAq"TzzH  !+u5
 Q (LLB''' "#A (%'DKN'	( 	(r   c                 l    |                                   t          |                                           S )z3Get the full data of this manifest as a bytestring.)r  r6   r   rC   s    r+   r   ztreemanifest.textF  s)    

T%%''(((r   c                                                         j        d  j                                        D             } fd j        D             } fd j        D             }t          t          ||z   |z                       S )zGet the full data of this directory as a bytestring. Make sure that
        any submanifests have been written first, so their nodeids are correct.
        c                 :    g | ]\  }}|d d         |d         dfS )Nr   r   rj   rB   )r   r   rr  s      r+   
<listcomp>z(treemanifest.dirtext.<locals>.<listcomp>Q  s/    LLLTQQssVQqT4(LLLr   c                 J    g | ]}|d d         j         |         j        df S )Nr   rj   )r   ra  )r   r   r>   s     r+   r  z(treemanifest.dirtext.<locals>.<listcomp>R  s1    HHH3B3A,d3HHHr   c                 B    g | ]}|j         |          |          fS rB   )rg  )r   r'   r*   r>   s     r+   r  z(treemanifest.dirtext.<locals>.<listcomp>S  s.    DDD1!T[^UU1XX.DDDr   )r  r*   rf  r  r   rg  r6   r  )r>   lazydirsr   r3   r*   s   `   @r+   dirtextztreemanifest.dirtextK  s     	


LLT^5I5I5K5KLLLHHHHTZHHHDDDDDDDDVD5L8344555r   c                 $    fd}|| _         d S )Nc                 R    |                                              d| _        d S r   )ri  re  )rd   gettextr]  s    r+   _load_for_readz)treemanifest.read.<locals>._load_for_readW  s(    GGGGII{+++AHHHr   )rc  )r>   r  r]  r  s    `` r+   readztreemanifest.readV  s/    	 	 	 	 	 	 (r   c                    |                                   |                                  |                                  t          | j                  fd}|                    | j        d d                   }|                     |          }|dk    s|dk    rd }| j                                        D ]N\  }}|r|d d         |vr |||          }	 |||          }
|	| j        j        k    r|
|	}
}	 |||	|
|           Od S )Nc                     | j                             |          }|r|d         S | j                            |          j        S r:   )rf  r  r   ra  )r  r   ldr  s      r+   getnodez+treemanifest.writesubtrees.<locals>.getnodec  s@    ##B !u7;;q),,22r   r   rv  ru  )	r  rX  r_  r  r^  rz  r   r  r`  )r>   r  r   writesubtreer   r  rw  r   r\  subp1subp2r  s              @r+   writesubtreesztreemanifest.writesubtrees]  s6   









 !344		3 	3 	3 	3 	3 &&ty"~66))%00GuEz'')) 	4 	4GAt 3B3u,,GBNNEGBNNE*111$euLueU3333	4 	4r   c              #   Z  K   |r$|                     | j        dd                   sdS |r || j        dd                   r| V  |                                  |                                  | j                                        D ]"\  }}|                    |          D ]}|V  #dS )zReturns an iterator of the subtrees of this manifest, including this
        manifest itself.

        If `matcher` is provided, it only returns subtrees that match.
        Nr   )matcher)visitdirr^  r  rp  r   r  walksubtrees)r>   r  r   r\  subtrees        r+   r  ztreemanifest.walksubtreesw  s        	7++DIcrcN;; 	F 	''$)CRC.11 	JJJ

z'')) 	 	GAt,,W,==  	 	r   )r   r   rA   r   )5rO   rP   rQ   r?   rl  rp  rs  rz  r  r   r   r=  r  r	   	strmethodr  r   r   r  r   r  r#  r   r   rD   r   r  r   r*   rJ   r   r   r  r  r   r   r>  r  r   r   r   r  r	  r  r;  r   r  ri  r   r  r  r  r  rB   r   r+   rX  rX    s          .       " " "
 
 
  ,  # # # HP P P 

 

 

  
    
 
 

  
  
  I  % % %  $ $ $
/ 
/ 
/ 
/" " "+ + +; ; ;     &    "  2   : # # ]#  	D 	D 	D$ $ $4     &* * *' ' 'R% % %; ; ; ;zL L L( ( (.) ) )
	6 	6 	6( ( (4 4 44     r   rX  c                        e Zd ZdZdZ fdZ fdZd Z fdZ fdZ	 fdZ
 fd	Z fd
Z fdZd fd	Zd fd	Z xZS )manifestfulltextcachezFile-backed LRU cache for the manifest cache

    File consists of entries, up to EOF:

    - 20 bytes node, 4 bytes length, <length> manifest data

    These are written in reverse cache order (oldest to newest).

    s   manifestfulltextcachec                     t          t          |                               |           d| _        d| _        d | _        d S r   )superr  r?   re  _read_opener)r>   max	__class__s     r+   r?   zmanifestfulltextcache.__init__  s;    #T**33C888
r   c                 d   | j         s| j        d S 	 |                     | j                  5 }t          t          |           j        }	 |                    d          }t          |          dk     rn	 t          j	        d|                    d                    d         }n# t          j
        $ r Y nGw xY wt          |                    |                    }t          |          |k    rn |||           d d d            n# 1 swxY w Y   n# t          $ r Y nw xY wd| _         d| _        d S )NTr      >L   r   F)r  r  _filer  r  r   r  r!   rL  unpackr
   r,  IOErrorre  )r>   fpr   r   r  r   r  s         r+   r  zmanifestfulltextcache.read  s   : 	-F	dj)) %R1488D%772;;D4yy2~~%}UBGGAJJ??B!<   %bggdmm44E5zzT))Ce$$$%% % % % % % % % % % % % % % %   	 	 	D	 
sZ   D AD3.B"!D"B41D3B44AD:D D

D D
D 
DDc           	         | j         r| j        d S 	 |                     | j        ddd          5 }| j        j        }	 |j        | j        v rn|                    |j                   |                    t          j	        dt          |j                                       |                    |j                   || j        u rn|j        }	 d d d            d S # 1 swxY w Y   d S # t          $ r Y d S w xY w)N   wT)
atomictemp
checkambigr  )re  r  r  _headr%   r|   _cachewriterL  rM  r!   r   r  )r>   r  r   s      r+   r  zmanifestfulltextcache.write  sU   { 	dl2F	
DTd    %z%x4;..***UC
OO!D!DEEE,,,tz))9D% % % % % % % % % % % % % % % % % % %  		 		 		 DD		s5   C' BCC' CC' !C"C' '
C54C5c                     | j         s|                                  t          t          |                                           S rA   )r  r  r  r  r   r>   r  s    r+   r   zmanifestfulltextcache.__len__  s7    z 	IIKKK*D1199;;;r   c                     | j         s|                                  t          t          |                               |          S rA   )r  r  r  r  r   r>   ry  r  s     r+   r   z"manifestfulltextcache.__contains__  s9    z 	IIKKK*D11>>qAAAr   c                     | j         s|                                  t          t          |                                           S rA   )r  r  r  r  rD   r  s    r+   rD   zmanifestfulltextcache.__iter__  s7    z 	IIKKK*D11::<<<r   c                     | j         s|                                  | j                            |          | j        u}t          t          |                               |          }|rd| _        |S r  )	r  r  r
  r  r	  r  r  r   re  )r>   ry  setdirtyr   r  s       r+   r   z!manifestfulltextcache.__getitem__  sf    z 	IIKKK;??1%%TZ7+T22>>qAA 	DKr   c                     | j         s|                                  t          t          |                               ||           d| _        d S r  )r  r  r  r  r   re  )r>   ry  rr  r  s      r+   r   z!manifestfulltextcache.__setitem__  sF    z 	IIKKK#T**66q!<<<r   c                     | j         s|                                  t          t          |                               |           d| _        d S r  )r  r  r  r  r   re  r  s     r+   r   z!manifestfulltextcache.__delitem__  sD    z 	IIKKK#T**66q999r   Nc                     | j         s|                                  t          t          |                               ||          S )N)r  )r  r  r  r  r  )r>   ry  r  r  s      r+   r  zmanifestfulltextcache.get  s>    z 	IIKKK*D1155a5IIIr   Fc                     t          t          |                                            |rd| _        |                                  d| _        d S )NTF)r  r  clearre  r  r  )r>   clear_persisted_datar  s     r+   r  zmanifestfulltextcache.clear  sG    #T**00222 	DKJJLLL


r   rA   r   )rO   rP   rQ   r   r  r?   r  r  r   r   rD   r   r   r   r  r  __classcell__r  s   @r+   r  r    sN         %E        8  8< < < < <
B B B B B
= = = = =
            J J J J J J
         r   r     c                       e Zd ZdZdS )r  z;Exception raised when fastdelta isn't usable on a manifest.N)rO   rP   rQ   r   rB   r   r+   r  r    s        EEEEr   r  c                   D   e Zd ZdZ	 	 	 d$dZd Zed             Zd%dZd	 Z		 	 d&d
Z
d Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd'dZd'dZd Zd Zd Zdddej        dfdZ	 	 	 d(dZd Zd Zd Z d Z!d  Z"	 	 	 	 	 d)d!Z#ed"             Z$e$j%        d#             Z$dS )*manifestrevlogznA revlog that stores manifest texts. This is responsible for caching the
    full-text manifest contents.
    r   NFc                 N   || _         d}d}t          |dd          }|,|                    d|          }|                    dd          }|p|| _        t	          |          | _        |r| j        sJ |d|z  f            d}	|rd	|z   |	z   }	|| _        |r|| _        n	d
| i| _        t          j        |t          j
        | j        f|	t          |           dt          |j                            dd                    | _        | j        j        | _        | j        j        | _        dS )a  Constructs a new manifest revlog

        `indexfile` - used by extensions to have two manifests at once, like
        when transitioning between flatmanifeset and treemanifests.

        `treemanifest` - used to indicate this is a tree manifest revlog. Opener
        options can also be used to make this a tree manifest revlog. The opener
        option takes precedence, so if it is set to True, we ignore whatever
        value is passed in to the constructor.
        r   FoptionsN   manifestcachesize   treemanifests
   opts is %rs
   00manifests   meta/r   Ts   persistent-nodemap)targetradixr  mmaplargeindexupperboundcomppersistentnodemap)r_  r   r  _treeondiskr  _fulltextcachetree_dirlogcacher   revlog_constantsKIND_MANIFESTLOGr  MAXCOMPRESSIONr   _revlogrv   _generaldelta)
r>   r_  openerr*  dirlogcacherX  	cachesizeoptiontreemanifestoptsr$  s
             r+   r?   zmanifestrevlog.__init__  sU   $ + 	"vy$//!5yAAI!%/5!A!A-=3I>> 	B#AAdMD,@%AAAA 	,tOe+E	  	, +D!$dD}$5tyA::~)$n001FNN	
 	
 	
 \'
!\7r   c                    t          j        |d          sdS |j        | j        _        |                    |j                  dS t          j        |          t          j        |           fd}|	                    |           dS )z1Persist the manifestfulltextcache on lock releases	   _wlockrefNc                     | sd S              }             }||d S |j                             d          |urd S |j                                         d S r   )manifestlog
getstorager)  r  )successrepor>   manifestrevlogrefreporefs      r+   persistmanifestcachezEmanifestrevlog._setupmanifestcachehooks.<locals>.persistmanifestcache`  ss     799D$$&&D|t|**3//t;;%%'''''r   )
r   safehasattr	wcachevfsr)  r  _currentlock	_wlockrefweakrefref
_afterlock)r>   r;  r>  r<  r=  s      @@r+   _setupmanifestcachehooksz'manifestrevlog._setupmanifestcachehooksT  s    l33 	F&*n#T^,,4F+d###K--	( 	( 	( 	( 	( 	( 	,-----r   c                     | j         S rA   )r)  rC   s    r+   fulltextcachezmanifestrevlog.fulltextcachep  s    ""r   c                     | j                                          | j                            |           | j        | i| _        d S N)r  )r/  clearcachesr)  r  r*  r+  r>   r  s     r+   rK  zmanifestrevlog.clearcachest  sF      """!!7K!LLL!Y-r   c                     |r	| j         sJ || j        vr2t          | j        | j        || j        | j                   }|| j        |<   | j        |         S )N)rX  )r(  r+  r  r_  r1  )r>   r   mfrevlogs      r+   dirlogzmanifestrevlog.dirlogy  sr     	$####D%%%%"!!-  H $,Da  ##r   c
           
         	 || j         vrt                      t          |           t          j        d t          |          D             d t          |          D                       }
|                    | j         |         |
          \  }}| j                            |          |f}t          j
        |          }| j                            ||||||          }| j                            |          }n# t          $ r | j        rY|s
J d            |	s
J d             || j        |          } || j        |          }|                     |||||||	          }d}n[|                                }| j                            |||||          }| j                            |          }t#          |          }Y nw xY w|
|| j         |<   |S )a  add some manifest entry in to the manifest log

        input:

          m:           the manifest dict we want to store
          transaction: the open transaction
          p1:          manifest-node of p1
          p2:          manifest-node of p2
          added:       file added/changed compared to parent
          removed:     file removed compared to parent

        tree manifest input:

          readtree:    a function to read a subtree
          match:       a filematcher for the subpart of the tree manifest
        c                     g | ]}|d fS r   rB   r  s     r+   r  z&manifestrevlog.add.<locals>.<listcomp>  s    333!U333r   c                     g | ]}|d fS r  rB   r  s     r+   r  z&manifestrevlog.add.<locals>.<listcomp>  s    444q!T444r   s,   readtree must be set for treemanifest writess/   match must be specified for treemanifest writesr   N)rH  r  r0   heapqmerger  r;  r/  revr   r'  addrevisionr   r(  r*  _addtreer   r,  )r>   r  transactionlinkp1p2addedremovedreadtreer   workr:  r9  
cachedeltar   rV  r(   r  r   s                      r+   r  zmanifestrevlog.add  s   8)	,+++*,,, E""";33VE]]33344F7OO444 D
 $%;;t/A"/Et#L#L Iy))"--y8J;y))D,**k4R C !!#&&AA# 	, 	, 	,  ,PP!PPPPPPPPPPXdi,,Xdi,,MM{D"b(% "   !		vvxxl..t[$BOOL%%c**%dOO	'	,*  $-Dq!s   C6C9 9CG Gc                      j         dk    r>|                    |          s|                    |          r|                                S  fd}|                    ||||           |                                }	d }
 j         dk    rY|	|                                k    r|                                }
n,|	|                                k    r|                                }
|
s\ j                            |	|                                |                                          } j                            |          }
|                    |
           |
S )Nr   c                                          |                                           }|                    | ||d d |	  	         d S )Nr_  r   )rO  r   r  )	r\  r  r  r   sublogrZ  r_  r>   rY  s	        r+   r  z-manifestrevlog._addtree.<locals>.writesubtree  s\    [[,,FJJ!  
 
 
 
 
r   )r*  r  r   r  r  r/  rW  r  )r>   r  rY  rZ  r  r   r_  r   r  r   r(   rV  s   ` ``  `     r+   rX  zmanifestrevlog._addtree  sZ    9b!! %&%6%6r%:%:  6688O	 	 	 	 	 	 	 	 	
Be444yy{{9rzz||##GGII%%GGII 	',**k4BGGII C !!#&&A 	
		!r   c                 *    t          | j                  S rA   )r!   r/  rC   s    r+   r   zmanifestrevlog.__len__  s    4<   r   c                 4    | j                                         S rA   )r/  rD   rC   s    r+   rD   zmanifestrevlog.__iter__   s    |$$&&&r   c                 6    | j                             |          S rA   )r/  rV  r  s     r+   rV  zmanifestrevlog.rev  s    |%%%r   c                 6    | j                             |          S rA   )r/  r   r>   rV  s     r+   r   zmanifestrevlog.node  s    |  %%%r   c                 6    | j                             |          S rA   )r/  lookupr>   r   s     r+   rl  zmanifestrevlog.lookup	  s    |""5)))r   c                 6    | j                             |          S rA   )r/  
parentrevsrj  s     r+   ro  zmanifestrevlog.parentrevs  s    |&&s+++r   c                 6    | j                             |          S rA   )r/  parentsr  s     r+   rq  zmanifestrevlog.parents  s    |##D)))r   c                 6    | j                             |          S rA   )r/  linkrevrj  s     r+   rs  zmanifestrevlog.linkrev      |##C(((r   c                 4    | j                                         S rA   )r/  	checksizerC   s    r+   rv  zmanifestrevlog.checksize  s    |%%'''r   c                 :    | j                             ||          S N)_df)r/  revisionr>   r   ry  s      r+   rz  zmanifestrevlog.revision  s    |$$Ts$333r   c                 :    | j                             ||          S rx  )r/  rawdatar{  s      r+   r}  zmanifestrevlog.rawdata  s    |##Dc#222r   c                 8    | j                             ||          S rA   )r/  revdiff)r>   rev1rev2s      r+   r  zmanifestrevlog.revdiff  s    |##D$///r   c                 8    | j                             ||          S rA   )r/  cmp)r>   r   r   s      r+   r  zmanifestrevlog.cmp!  s    |d+++r   c                 6    | j                             |          S rA   )r/  deltaparentrj  s     r+   r  zmanifestrevlog.deltaparent$  s    |'',,,r   c                 B    | j                             ||||||          S )N)
nodesorderrevisiondataassumehaveparentrevisions	deltamodesidedata_helpers)r/  emitrevisions)r>   nodesr  r  r  r  r  s          r+   r  zmanifestrevlog.emitrevisions'  s5     |))!%&?- * 
 
 	
r   c                 B    | j                             ||||||          S )N)alwayscacheaddrevisioncbduplicaterevisioncb)r/  addgroup)r>   deltas
linkmapperrY  r  r  r  s          r+   r  zmanifestrevlog.addgroup9  s5     |$$#' 3 % 
 
 	
r   c                 6    | j                             |          S rA   )r/  rawsizerj  s     r+   r  zmanifestrevlog.rawsizeK  rt  r   c                 6    | j                             |          S rA   )r/  getstrippoint)r>   minlinks     r+   r  zmanifestrevlog.getstrippointN  s    |))'222r   c                 8    | j                             ||          S rA   )r/  strip)r>   r  rY  s      r+   r  zmanifestrevlog.stripQ  s    |!!';777r   c                 4    | j                                         S rA   )r/  r3   rC   s    r+   r3   zmanifestrevlog.filesT  s    |!!###r   c                     t          |t                    st          j        d           | j        j        ||j        fi |S )Ns"   expected manifestrevlog to clone())r   r  r
   ProgrammingErrorr/  clone)r>   tr
destrevlogkwargss       r+   r  zmanifestrevlog.cloneW  sI    *n55 	P()NOOO!t|!"j&8CCFCCCr   c                 @    | j                             |||||          S )N)exclusivefilessharedfilesrevisionscounttrackedsize
storedsize)r/  storageinfo)r>   r  r  r  r  r  s         r+   r  zmanifestrevlog.storageinfo]  s2     |'')#)#! ( 
 
 	
r   c                     | j         j        S rA   r/  r1  rC   s    r+   r1  zmanifestrevlog.openerm  s    |""r   c                     || j         _        d S rA   r  rm  s     r+   r1  zmanifestrevlog.openerq  s    #r   )r   NFr   )NNrA   )FNN)FFFFF)&rO   rP   rQ   r   r?   rF  propertyrH  rK  rO  r  rX  r   rD   rV  r   rl  ro  rq  rs  rv  rz  r}  r  r  r  r   CG_DELTAMODE_STDr  r  r  r  r  r3   r  r  r1  setterrB   r   r+   r  r    s         <8 <8 <8 <8|. . .8 # # X#. . . .
$ $ $. J J J JX( ( (T! ! !' ' '& & && & &* * *, , ,* * *) ) )( ( (4 4 4 43 3 3 30 0 0, , ,- - - "'-
 
 
 
.  
 
 
 
$) ) )3 3 38 8 8$ $ $D D D 
 
 
 
  # # X# ]$ $ ]$ $ $r   r  c                   @    e Zd ZdZd Zd ZddZd ZddZd	 Z	d
 Z
dS )r8  a  A collection class representing the collection of manifest snapshots
    referenced by commits in the repository.

    In this situation, 'manifest' refers to the abstract concept of a snapshot
    of the list of files in the given commit. Consumers of the output of this
    class do not care about the implementation details of the actual manifests
    they receive (i.e. tree or flat or lazily loaded, etc).c                 V   |j         | _         d}d}t          |dd           }|,|                    d|          }|                    d|          }|| _        || _        | j                            |           || _        i | _        t          j	        |          | j        d<   || _
        d S )NFr   r   r"  r!  r   )r_  r   r  _treemanifests
_rootstorerF  _narrowmatch_dirmancacher   lrucachedict
_cachesize)r>   r1  r;  	rootstorenarrowmatchusetreemanifestr3  r5  s           r+   r?   zmanifestlog.__init__  s    !/	vy$//"hhHHO!5yAAI-#00666' !%!29!=!=##r   c                 .    |                      d|          S )zgRetrieves the manifest instance for the given node. Throws a
        LookupError if not found.
        r   )r  r  s     r+   r   zmanifestlog.__getitem__  s     xxT"""r   Tc                    || j                             |d          v r| j         |         |         S | j                                        s8| j                            |dd                   st          | j        ||          S |rl| j        j        r<|r(| 	                    |          
                    |           t          | ||          }nit          j        t          d          |z            |r| j        
                    |           | j        rt          | d|          }nt!          | |          }|| j        j        k    rD| j                             |          }|s#t%          j        | j                  }|| j         |<   |||<   |S )zRetrieves the manifest instance for the given node. Throws a
        LookupError if not found.

        `verify` - if True an exception will be thrown if the node is not in
                   the revlog
        rB   Nr   s9   cannot ask for manifest directory '%s' in a flat manifestr   )r  r  r  r   r  excludeddirmanifestctxr_  r  r(  r9  rV  treemanifestctxr
   Abortr   r  manifestctxr`  r   r  r  )r>   r*  r   verifyr  mancaches         r+   r  zmanifestlog.get  s    4$((r2222$T*400 '')) 	N$--d3B3i88 N-d.@$MMM 	,*  4 OOD))--d333#D$55k$  	    *##D)))" ,#D#t44d++4%,,,(,,T22H 3,T_==*2!$'HTNr   c                 6    | j                             |          S rA   )r  rO  )r>   r*  s     r+   r9  zmanifestlog.getstorage  s    %%d+++r   Fc                 n    | j                                          | j                            |           d S rJ  )r  r  r  rK  rL  s     r+   rK  zmanifestlog.clearcaches  s7    !!!##9M#NNNNNr   c                 6    | j                             |          S rA   )r  rV  r  s     r+   rV  zmanifestlog.rev  s    ""4(((r   c                 B    | j         j                            |          S )N)rY  )r  r/  update_caches)r>   rY  s     r+   r  zmanifestlog.update_caches  s    &444MMMr   Nr  r   )rO   rP   rQ   r   r?   r   r  r9  rK  rV  r  rB   r   r+   r8  r8  v  s        ? ?$ $ $,# # #- - - -^, , ,O O O O) ) )N N N N Nr   r8  c                   .    e Zd Zd Zd Zd Zd ZddZdS )memmanifestctxc                 P    || _         t          |j        j                  | _        d S rA   )_manifestlogr   r_  r#   _manifestdict)r>   r8  s     r+   r?   zmemmanifestctx.__init__  s&    ')+*C*KLLr   c                 6    | j                             d          S r   r  r9  rC   s    r+   _storagezmemmanifestctx._storage       ++C000r   c                     t          | j                  }|                                                                 |_        |S rA   r  r  r  r   r  r>   memmfs     r+   r   zmemmanifestctx.copy  3    t011"iikk..00r   c                     | j         S rA   )r  rC   s    r+   r  zmemmanifestctx.read      !!r   Nc           
      j    |                                                      | j        |||||||          S )NrS  )r  r  r  )r>   rY  rZ  r[  r\  r]  r^  r   s           r+   r  zmemmanifestctx.write  sB    }}"" # 	
 	
 		
r   rA   rO   rP   rQ   r?   r  r   r  r  rB   r   r+   r  r    sg        M M M1 1 1  
" " "

 

 

 

 

 

r   r  c                   \    e Zd ZdZd Zd Zd Zd Zed             Z	d Z
dd	Zdd
Zd ZdS )r  zxA class representing a single revision of a manifest, including its
    contents, its parent revs, and its linkrev.
    c                 0    || _         d | _        || _        d S rA   )r  _datara  )r>   r8  r   s      r+   r?   zmanifestctx.__init__  s    '



r   c                 6    | j                             d          S r   r  rC   s    r+   r  zmanifestctx._storage
  r  r   c                     | j         S rA   ra  rC   s    r+   r   zmanifestctx.node  r   r   c                     t          | j                  }|                                                                 |_        |S rA   r  r  s     r+   r   zmanifestctx.copy  r  r   c                 Z    |                                                      | j                  S rA   r  rq  ra  rC   s    r+   rq  zmanifestctx.parents       }}&&tz222r   c                    | j         | j        j        }| j        |j        k    rt          |j                  | _         n|                                 }| j        |j        v r%t          j
        |j        | j                           }n8|                    | j                  }t          |          }||j        | j        <   t          |j        |          | _         | j         S rA   )r  r  r_  ra  r`  r   r#   r  rH  r   rI  rz  r,  )r>   ncstorer   r:  s        r+   r  zmanifestctx.read  s    :"0BzRY&&)"*55

:!444#+E,?
,KLLDD >>$*55D )$I6?E'
3)"*d;;
zr   Fc                    |                                  }|                    | j                  }|                    |          }|t          k    r+||                    |          v r|                                 S |                                 S )a   Calls either readdelta or read, based on which would be less work.
        readdelta is called if the delta is against the p1, and therefore can be
        read quickly.

        If `shallow` is True, nothing changes since this is a flat manifest.
        )r  rV  ra  r  r   ro  	readdeltar  r>   shallowr  r   r  s        r+   readfastzmanifestctx.readfast)  sx     IIdj!!''**'!!kU5E5Ea5H5H&H&H>>###yy{{r   c                    |                                  }|                    | j                  }t          j        |                    |                    |          |                    }t          |j        j	        |          S )a  Returns a manifest containing just the entries that are present
        in this manifest, but not in its p1 manifest. This is efficient to read
        if the revlog delta is already p1.

        Changing the value of `shallow` has no effect on flat manifests.
        )
r  rV  ra  r   	patchtextr  r  r   r_  r#   )r>   r  r  r   r   s        r+   r  zmanifestctx.readdelta7  se     IIdj!!OEMM%*;*;A*>*>BBCCE/7;;;r   c                 P    |                                                      |          S rA   r  rJ   r   s     r+   rJ   zmanifestctx.findC      yy{{$$$r   Nr   )rO   rP   rQ   r   r?   r  r   r   r>  rq  r  r  r  rJ   rB   r   r+   r  r    s           1 1 1    
 3 3 ]3      
< 
< 
< 
<% % % % %r   r  c                   0    e Zd ZddZd Zd Zd Zd	dZdS )
memtreemanifestctxr   c                 T    || _         || _        t          |j                  | _        d S rA   )r  r^  rX  r_  _treemanifest)r>   r8  r   s      r+   r?   zmemtreemanifestctx.__init__I  s*    '	)+*CDDr   c                 6    | j                             d          S r   r  rC   s    r+   r  zmemtreemanifestctx._storageN  r  r   c                 x    t          | j        | j                  }| j                                        |_        |S Nr   )r  r  r^  r  r   r  s     r+   r   zmemtreemanifestctx.copyQ  s5    "4#4$)DDD"05577r   c                     | j         S rA   )r  rC   s    r+   r  zmemtreemanifestctx.readV  r  r   Nc                 x      fd}                                                       j        ||||||||	  	        S )Nc                 ^    j                             | |                                          S rA   r  r  r  )r   r   r>   s     r+   r_  z*memtreemanifestctx.write.<locals>.readtreeZ  s(    $((d3388:::r   rd  )r  r  r  )	r>   rY  rZ  r[  r\  r]  r^  r   r_  s	   `        r+   r  zmemtreemanifestctx.writeY  sa    	; 	; 	; 	; 	; }}"" # 

 

 
	
r   r<  rA   r  rB   r   r+   r  r  G  sm        E E E E
1 1 1  
" " "
 
 
 
 
 
r   r  c                   X    e Zd Zd Zd Zd Zd Zd Zed             Z	ddZ
dd	Zd
 ZdS )r  c                 >    || _         || _        d | _        || _        d S rA   )r  r^  r  ra  )r>   r8  r   r   s       r+   r?   ztreemanifestctx.__init__l  s#    '	



r   c                    | j         j        }|                                sA|                    | j        d d                   st          | j         j        | j                  S | j                             | j                  S r   )r  r  r   r  r^  excludedmanifestrevlogr_  r9  )r>   r  s     r+   r  ztreemanifestctx._storagez  s{    '4!!## 	''	#2#77 -%3TY    ++DI666r   c                      j         H                                  j         j        j        j        k    rt           j        j                   _         nj        rct           j        j         j                  } fd} fd}|	                    ||           |
                     j                   | _         n j        j        v r%t          j        j         j                           }n8                     j                  }t          |          }|j         j        <   t           j        j         j        |           _          j         S )Nr  c                  8                          j                  S rA   )rz  ra  )r>   r  s   r+   r  z%treemanifestctx.read.<locals>.gettext  s     >>$*555r   c                 b    j                             | |d                                          S )NF)r  r  )r   r\  r>   s     r+   r]  z)treemanifestctx.read.<locals>.readsubtree  s/      ,00d50IINNPPPr   )r   r   )r  r  ra  r  r_  r`  rX  r(  r^  r  r  rH  r   rI  rz  r,  )r>   r  r  r]  r   r:  r  s   `     @r+   r  ztreemanifestctx.read  sb   :MMOOEzT.<CCC)$*;*IJJ

"  !2!@diPPP6 6 6 6 6 6Q Q Q Q Q
 w,,,		$*%%%

:!444#+E,?
,KLLDD >>$*55D )$I6?E'
3)%3  
 zr   c                     | j         S rA   r  rC   s    r+   r   ztreemanifestctx.node  r   r   c                     t          | j        | j                  }|                                                                 |_        |S r  )r  r  r^  r  r   r  r  s     r+   r   ztreemanifestctx.copy  s:    "4#4$)DDD"iikk..00r   c                 Z    |                                                      | j                  S rA   r  rC   s    r+   rq  ztreemanifestctx.parents  r  r   Fc                    |                                  }|ro|                    | j                  }t          j        |                    |                    |          |                    }t          |j        j	        |          S |                    |                    | j                            }| j
                            | j        |                    |                                                    }|                                 }t          | j
        j        | j                  }|                    |                                          D ]-\  }	\  \  }
}\  }}|r|||	<   |r|                    |	|           .|S )a  Returns a manifest containing just the entries that are present
        in this manifest, but not in its p1 manifest. This is efficient to read
        if the revlog delta is already p1.

        If `shallow` is True, this will read the delta for this directory,
        without recursively reading subdirectory manifests. Instead, any
        subdirectory entry will be reported as it appears in the manifest, i.e.
        the subdirectory will be reported among files and distinguished only by
        its 't' flag.
        r  )r  rV  ra  r   r  r  r  r   r_  r#   r  r  r^  r   r  rX  r   r  r  )r>   r  r  r   r   r0m0r  mdr'   n0fl0r  r  s                 r+   r  ztreemanifestctx.readdelta  sQ     			$*%%Ae.?.?.B.BA F FGGA 3 ;Q??? ""599TZ#8#899B"&&ty%**R..AAFFHHBBd/=49MMMB-/WWR[[->->-@-@ + +))IRyC +BqE +

1c***Ir   c                    |                                  }|                    | j                  }|                    |          }|t          k    r-||                    |          v r|                     |          S |r2t          |j        j	        |
                    | j                            S |                                 S )a#  Calls either readdelta or read, based on which would be less work.
        readdelta is called if the delta is against the p1, and therefore can be
        read quickly.

        If `shallow` is True, it only returns the entries from this manifest,
        and not any submanifests.
        )r  )r  rV  ra  r  r   ro  r  r   r_  r#   rz  r  r  s        r+   r  ztreemanifestctx.readfast  s     IIdj!!''**'!!kU5E5Ea5H5H&H&H>>'>222 	#+U^^DJ-G-G   99;;r   c                 P    |                                                      |          S rA   r  r   s     r+   rJ   ztreemanifestctx.find  r  r   Nr   )rO   rP   rQ   r?   r  r  r   r   r>  rq  r  r  rJ   rB   r   r+   r  r  j  s          7 7 7  B    
 3 3 ]3   :   *% % % % %r   r  c                   (     e Zd ZdZ fdZd Z xZS )excludeddira  Stand-in for a directory that is excluded from the repository.

    With narrowing active on a repository that uses treemanifests,
    some of the directory revlogs will be excluded from the resulting
    clone. This is a huge storage win for clients, but means we need
    some sort of pseudo-manifest to surface to internals so we can
    detect a merge conflict outside the narrowspec. That's what this
    class is: it stands in for a directory whose node is known, but
    whose contents are unknown.
    c                     t          t          |                               ||           || _        || j        d<   d| j        d<   d S )Nr   rj   )r  r  r?   ra  rg  rh  )r>   r_  r   r   r  s       r+   r?   zexcludeddir.__init__  sJ    k4  ))-===
  CCr   c                     | S rA   rB   rC   s    r+   r   zexcludeddir.copy  rE   r   )rO   rP   rQ   r   r?   r   r  r  s   @r+   r  r    sQ        	 	               r   r  c                   ,    e Zd ZdZd Zd ZddZd ZdS )	r  zBcontext wrapper for excludeddir - see that docstring for rationalec                 0    || _         || _        || _        d S rA   )r_  r^  ra  )r>   r_  r   r   s       r+   r?   zexcludeddirmanifestctx.__init__	  s    *	


r   c                 B    t          | j        | j        | j                  S rA   )r  r_  r^  ra  rC   s    r+   r  zexcludeddirmanifestctx.read	  s    4-ty$*EEEr   Fc                 *    |                                  S rA   )r  )r>   r  s     r+   r  zexcludeddirmanifestctx.readfast	  s    yy{{r   c                 :    t          j        d| j        z            )Ns.   attempt to write manifest from excluded dir %sr
   r  r^  )r>   argss     r+   r  zexcludeddirmanifestctx.write	  s!    $=	I
 
 	
r   Nr   )rO   rP   rQ   r   r?   r  r  r  rB   r   r+   r  r  	  s^        LL  
F F F   
 
 
 
 
r   r  c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	r   a\  Stand-in for excluded treemanifest revlogs.

    When narrowing is active on a treemanifest repository, we'll have
    references to directories we can't see due to the revlog being
    skipped. This class exists to conform to the manifestrevlog
    interface for those directories and proactively prevent writes to
    outside the narrowspec.
    c                 "    || _         || _        d S rA   )r_  r^  )r>   r_  r   s      r+   r?   zexcludedmanifestrevlog.__init__"	  s    *			r   c                 :    t          j        d| j        z            )Ns(   attempt to get length of excluded dir %sr  rC   s    r+   r   zexcludedmanifestrevlog.__len__&	  !    $7$)C
 
 	
r   c                 :    t          j        d| j        z            )Ns'   attempt to get rev from excluded dir %sr  r  s     r+   rV  zexcludedmanifestrevlog.rev+	  s!    $6B
 
 	
r   c                 :    t          j        d| j        z            )Ns+   attempt to get linkrev from excluded dir %sr  r  s     r+   rs  zexcludedmanifestrevlog.linkrev0	  s!    $:TYF
 
 	
r   c                 :    t          j        d| j        z            )Ns(   attempt to get node from excluded dir %sr  rj  s     r+   r   zexcludedmanifestrevlog.node5	  r  r   c                     d S rA   rB   )r>   r  r  s      r+   r  zexcludedmanifestrevlog.add:	  s	     	r   N)
rO   rP   rQ   r   r?   r   rV  rs  r   r  rB   r   r+   r   r   	  sx           
 
 


 
 


 
 


 
 

    r   r   )r   N)ErT  r  rL  rC  i18nr   r   r   r   r   r   r    r	   r
   r   r   r   r   r   r   r   
interfacesr   interfaceutilrevlogutilsr   r,  	importmodr   r>  r(  r,   r6   r8   rT   rZ   rh   r"   rm   lazymanifestAttributeErrorimplementerimanifestdictr   r)  r0   r+  rU  rb  rX  r  r  r.  	Exceptionr  imanifeststorager  imanifestlogr8  imanifestrevisionwritabler  imanifestrevisionstoredr  r  r  r  r  r   rB   r   r+   <module>r1     s                        
      
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
             &
9
%
%"  $   6
 
 
       ." " " " " " " "J     )((q q q q q q q qh		(MM 	 	 	D	 :344g$ g$ g$ g$ g$ g$ g$ 54g$T( ( ( (V  ! ! !,   	 :344h	 h	 h	 h	 h	 h	 h	 54h	Vz z z z zD- z z z~ F F F F F9 F F F :677b$ b$ b$ b$ b$ b$ b$ 87b$J :233_N _N _N _N _N _N _N 43_ND :?@@
 
 
 
 
 
 
 A@
: :=>>L% L% L% L% L% L% L% ?>L%^ :?@@
 
 
 
 
 
 
 A@
D :=>>x% x% x% x% x% x% x% ?>x%v    ,   :
 
 
 
 
_ 
 
 
*( ( ( ( (^ ( ( ( ( (s   B$ $B,+B,