
    q&f-                       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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j6                  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jN                  Z& ejR                  ejT                         G d d             Z+d5dZ,d Z-d Z.d Z/d Z0 ejR                  ejT                         G d d             Z1 G d dejd                        Z3d Z4 G d! d"e5      Z6 ejR                  ejn                         G d# d$             Z8 ejR                  ejr                         G d% d&             Z: ejR                  ejv                         G d' d(             Z< ejR                  ejz                         G d) d*             Z> ejR                  ejv                         G d+ d,             Z? ejR                  ejz                         G d- d.             Z@ G d/ d0e1      ZA G d1 d2e@      ZB G d3 d4e8      ZCy# e($ r Y w xY w)6    N   )_)binhexnullrev)	encodingerrormatchmdiffpathutilpolicypycompatrevlogutil)
repositoryr   )	constantsparsersi  c              #   D  K   |r|dd  dk7  rt        d      d }|j                         D ]r  }|||kD  rt        d      |}|j                  d      \  }}t        |      }|dd  }|t        v r|d d }|dz  }nd}|d| z  k7  rt        d	      |t        |      |f t y w)
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      RS	U">??D__ qCDDwwu~1V"#N"#2A!GBEW566Qs   BB c                     g }g }| D ]7  \  }}}|j                  |       |j                  d|t        |      |fz         9 t        |       dj                  |      S )N   %s %s%s
r   )appendr   _checkforbiddenjoin)itfileslinesr&   r'   fls         r*   _textr5   I   sa    EE 61bQ 	]aQ_45	6 E88E?r   c                   "    e Zd Zd Zd Zd ZeZy)lazymanifestiterc                      d| _         || _        y Nr   )poslmselfr;   s     r*   __init__zlazymanifestiter.__init__W   s    r   c                     | S N r=   s    r*   __iter__zlazymanifestiter.__iter__[       r   c                    	 | j                   j                  | j                        \  }}|dk(  r| xj                  dz  c_        |d   S | xj                  dz  c_        |j                  d|      }||| S # t        $ r t        w xY w)Nr   r   r   r   )r;   _getr:   
IndexErrorStopIterationfind)r=   r#   r:   zeroposs       r*   nextzlazymanifestiter.next^   s    	 TXX.ID# "9HHMH7NA))GS)C    	 	 s   (A5 5BN__name__
__module____qualname__r>   rC   rK   __next__rA   r   r*   r7   r7   V   s    
! Hr   r7   c                   "    e Zd Zd Zd Zd ZeZy)lazymanifestiterentriesc                      || _         d| _        y r9   )r;   r:   r<   s     r*   r>   z lazymanifestiterentries.__init__n   s    r   c                     | S r@   rA   rB   s    r*   rC   z lazymanifestiterentries.__iter__r   rD   r   c                    	 | j                   j                  | j                        \  }}|dk(  r| xj                  dz  c_        |S |j                  d|      }|j                  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  k7  rt        j                  d      t        || j                   j                  | j                     |dz   |      }| xj                  dz  c_        ||| ||fS # t        $ r t        w xY w)Nr   r   r   r   r   r   r   )r;   rF   r:   rG   rH   rI   r	   StorageErrorr!   _nodelen	unhexlify	extrainfo)r=   r#   r:   rJ   nlposr)   hlenhashvals           r*   rK   zlazymanifestiterentries.nextu   sG   	 TXX.ID# "9HHMHK))GS)		%%b=ERK57?$$%=>>UQY'N"7?Q&D7?Q&DE1tww''''$$%=>>$''##DHH-w{D
 	AS!7E22+  	 	 s   (D1 1ENrL   rA   r   r*   rR   rR   m   s    34 Hr   rR   c                 N    t        | |||z          }|r|t        |dz        z  }|S )N   )r   chr)r#   extrar:   lengthss        r*   rX   rX      s2    DsV|$%A	SHr   c                     | |kD  | |k  z
  S r@   rA   )abs     r*   _cmprf      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y)_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.
    Nc                    || _         |J| j                  |      | _        dgt        | j                        z  | _        || _        g | _        d| _        y |d d  | _        |d d  | _        |d d  | _        || _        || _        y )Nr   F)rW   	findlines	positionsr    rY   r#   	extradatahasremovals)r=   r"   r#   rn   rY   ro   rp   s          r*   r>   z_lazymanifest.__init__   s~      !^^D1DNS3t~~#66DNDIDN$D&q\DN&q\DN&q\DNDI*Dr   c                    |sg S |j                  d      }|dk(  s|dd  dk7  rt        d      dg}|d |j                  d       }|t        |      dz
  k  rr|dk7  rm|j                  |dz          ||dz   |j                  d|dz          }||k  rt        d      |}|j                  d|dz         }|t        |      dz
  k  r|dk7  rm|S )Nr   r   r   r   r   r   r   )rI   r   r    r.   )r=   r#   r:   rn   r$   nextss         r*   rm   z_lazymanifest.findlines   s    Iii"9RS	U*BCCC	(dii()CIM!cRiS1W%q499WcAg#>?Et| !GHHD))E37+C CIM!cRi r   c                 p    | j                   |   }|dk\  r| j                  |fS | j                  | dz
     dfS )Nr   r   r   )rn   r#   ro   )r=   indexr:   s      r*   rF   z_lazymanifest._get   sA     nnU#!899c>!~~sdQh'++r   c                     |dk\  r,| j                   || j                   j                  d|dz          S | j                  | dz
     d   S )Nr   r   r   )r#   rI   ro   )r=   r:   s     r*   _getkeyz_lazymanifest._getkey   sG    !899S499>>'37#CDD~~sdQh'**r   c                     d}t        | j                        dz
  }||k  rQ||z   dz  }| j                  |   }| j                  |      }t        ||      }|dk(  r|S |dk  r|dz
  }n|dz   }||k  rQy)Nr   r   r   r   r    rn   rv   rf   r=   keyfirstlastmidpointnextpos	candidaters           r*   bsearchz_lazymanifest.bsearch   s    4>>"Q&tm*HnnX.GW-IS)$AAvq5#a<D$qLE tm r   c                     d}t        | j                        dz
  }||k  rS||z   dz  }| j                  |   }| j                  |      }t        ||      }|dk(  r|dfS |dk  r|dz
  }n|dz   }||k  rS|dfS )Nr   r   r   TFrx   ry   s           r*   bsearch2z_lazymanifest.bsearch2   s     4>>"Q&tm*HnnX.GW-IS)$AAv $''q5#a<D$qLE tm u~r   c                 *    | j                  |      dk7  S Nr   )r   r=   rz   s     r*   __contains__z_lazymanifest.__contains__  s    ||C B&&r   c                    t        |t              st        d      | j                  |      }|dk(  rt        | j                  |      \  }}|dk(  r
|d   |d   fS |j                  d|      }|j                  d|      }d|cxk  rt        | j                        k  sJ  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  k7  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   KeyErrorrF   rI   r    rn   rY   r	   rV   r!   rW   rX   )
r=   rz   needler#   r:   rJ   rZ   r[   r)   r\   s
             r*   __getitem__z_lazymanifest.__getitem__  sd   #u%FGGc"R<NIIf%	c"9GT!W%%))GS)		%)F1c$..1111114>>"c$..&9999b=ERK57?$$%=>>w"UQY'N"AIDE1t}}$$$$%=>>D$.."8'A+tLr   c                 d   | j                  |      \  }}|st        | j                  |   }| j                  d | | j                  |dz   d  z   | _        | j                  d | | j                  |dz   d  z   | _        |dk\  r2| j                  d | dz   | j                  |dz   d  z   | _        d| _        y y )Nr   r   r   T)r   r   rn   rY   r#   rp   )r=   rz   r   foundcurs        r*   __delitem__z_lazymanifest.__delitem__+  s    c*NnnV$04>>&1*,3OO04>>&1*,3OO!8 		$3'1DIIcAgi4HHDI#D	 r   c                 `   t        |t              st        d      t        |t              rt	        |      dk7  rt        d      |d   }t        |t              rt	        |      dvrt        d      |d   }t        |t              rt	        |      dkD  rt        d|      | j                  |      \  }}|rs| j                  |   }|dk  r|||d   f| j                  | dz
  <   y | j                  j                  |||d   f       t	        | j                         | j                  |<   y | j                  j                  |||d   f       | j                  d | t	        | j                         gz   | j                  |d  z   | _        | j                  d | dgz   | j                  |d  z   | _	        y )	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   rn   ro   r.   rY   )r=   rz   valuer\   r)   r   r   r:   s           r*   __setitem__z_lazymanifest.__setitem__8  s   #u%LMM%'3u:?D  ('5)S\-ILMMa%'3u:>FNNc*..(CQw,/%(+Ctax( %%sGU1X&>?*-dnn*=)=v& NN!!3q":;w'''()..)* N w'1#-vw0GG Nr   c                     t        | j                  | j                  | j                  | j                  | j
                  | j                        S r@   )rk   rW   r#   rn   rY   ro   rp   rB   s    r*   copyz_lazymanifest.copy[  s;    MMIINNNNNN
 	
r   c                 j   t        | j                        dk(  r| j                  sy g }d}d}dgt        | j                        z  | _        |t        | j                        k  r-| j                  |   dk\  r| j                  |   }|}	 || j                  |<   |dz  }|t        | j                        k(  s| j                  |   dk  rn_| j                  r.| j
                  j                  d|| j                  |         dk7  rn%|| j                  |   |z
  z  }| j                  |   }| j
                  j                  d|      }|dk7  r|dz  }|||z
  z  }|j                  | j
                  ||        n|t        | j                        k  r| j                  |   dk  r| j                  |   }| j                  | dz
     }|j                  | j                  |             || j                  |<   d}t        |d         dkD  rd}t        |d         |kD  r!t        |d   |dz            | j                  |<   |t        |d         z  }|dz  }|t        | j                        k  r| j                  |   dk  r|t        | j                        k  r-d	j                  |      | _        d
| _        g | _        y )Nr   r   s   
 r   r   r      r   r   F)r    ro   rp   rn   rY   r#   rI   r.   _packordr0   )	r=   r%   ioffsetr   last_cutend_cuttr[   s	            r*   _compactz_lazymanifest._compactf  s   t~~!#D,<,<s4>>22#dnn%%~~a A%nnQ'
 (.DNN1%FAC//4>>!3Dq3H (( IINN9c4>>!;LM dnnQ/#55F..+C% & ))..4b=qLG'C-'8G45#dnn--$..2Ca2G..+Ctax0AHHTZZ]+(.DNN1% D1Q4y2~!1Q4y4',/!TAX,?q)c!B%j(FFA #dnn--$..2Ca2GC #dnn%%^ HHQK	 r   c                 d    |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  sB    aD1v!!!tg~A&1-55r   c                 :    | j                          | j                  S r@   )r   r#   rB   s    r*   textz_lazymanifest.text  s    yyr   c                     i }| j                         D ]2  \  }}}||vr
||fdf||<   ||   }||f|k7  r
||f|f||<   +|s.d||<   4 |j                         D ]  \  }}}|| vs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H#DH	$  ^^- 	4MBE~&U3R	4 r   c                     t        |       S r@   )rR   rB   s    r*   r   z_lazymanifest.iterentries  s    &t,,r   c                     t        |       S r@   r7   rB   s    r*   iterkeysz_lazymanifest.iterkeys      %%r   c                     t        |       S r@   r   rB   s    r*   rC   z_lazymanifest.__iter__  r   r   c                 ,    t        | j                        S r@   )r    rn   rB   s    r*   __len__z_lazymanifest.__len__  s    4>>""r   c                     t        | j                  d      }| j                         D ]  \  }}} ||      s||f||<    |S r   )rk   rW   r   )r=   filterfncr&   r'   r4   s         r*   
filtercopyz_lazymanifest.filtercopy  sK    $---((* 	HAq"{"u!	 r   )NNNFF)rM   rN   rO   __doc__r>   rm   rF   rv   r   r   r   r   r   r   r   r   r   r   r   r   r   rC   r   r   rA   r   r*   rk   rk      s{    * +.",+
$(' 4$!F	
9v6
*-&&#r   rk   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 y)!manifestdictc                 4    || _         t        ||      | _        y r@   )rW   rk   _lm)r=   r"   r#   s      r*   r>   zmanifestdict.__init__  s     $/r   c                 &    | j                   |   d   S r9   r   r   s     r*   r   zmanifestdict.__getitem__  s    xx}Qr   c                      | j                   |   S r@   r   r   s     r*   rI   zmanifestdict.find  s    xx}r   c                 ,    t        | j                        S r@   r    r   rB   s    r*   r   zmanifestdict.__len__  s    488}r   c                 2    t        | j                        dk7  S r9   r   rB   s    r*   __nonzero__zmanifestdict.__nonzero__  s     488}!!r   c                 D    || j                  |      f| j                  |<   y r@   )r)   r   )r=   rz   nodes      r*   r   zmanifestdict.__setitem__  s    djjo-r   c                 $    |y|| j                   v S NFr   r   s     r*   r   zmanifestdict.__contains__  s    ;dhhr   c                     | j                   |= y r@   r   r   s     r*   r   zmanifestdict.__delitem__  s    HHSMr   c                 6    | j                   j                         S r@   )r   rC   rB   s    r*   rC   zmanifestdict.__iter__      xx  ""r   c                 6    | j                   j                         S r@   )r   r   rB   s    r*   r   zmanifestdict.iterkeys  r   r   c                 4    t        | j                               S r@   listr   rB   s    r*   keyszmanifestdict.keys      DMMO$$r   Nc                     |Ut        j                  |d       }t        |j                  |            }| j                  |      D ch c]	  }||vs| c}S | D ch c]	  }||vs| c}S c c}w c c}w )7Set of files in this manifest that are not in the otherc                      y r@   rA   )pathmsgs     r*   <lambda>z)manifestdict.filesnotin.<locals>.<lambda>      r   )matchmodbadmatchsetwalk)r=   r   r
   sm2r&   s        r*   
filesnotinzmanifestdict.filesnotin  sm    %%e-CDEbggen%C#yy/@!1C<A@@/a1B;// A/s   	A-A-	A2&A2c                 ,    t        j                  |       S r@   r   dirsrB   s    r*   _dirszmanifestdict._dirs      }}T""r   c                     | j                   S r@   r   rB   s    r*   r   zmanifestdict.dirs      zzr   c                     || j                   v S r@   r   )r=   dirs     r*   hasdirzmanifestdict.hasdir  s    djj  r   c                      |j                         }t        |      dk  xr8 |j                         xs& |j                         xr 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  
 y wr@   rA   ).0r   r=   s     r*   	<genexpr>z.manifestdict._filesfastpath.<locals>.<genexpr>  s     &BbrTz&Bs   )r2   r    isexactprefixall)r=   r
   r2   s   `  r*   _filesfastpathzmanifestdict._filesfastpath  sN     5zC 
MMO DB3&BE&B#B	
r   c              #     K   |j                         rt        |       D ]  }|  yt        |j                               }| j	                  |      rt        |      D ]  }|| v s|  y| D ]$  }||v r|j                  |        ||      s!| & |j                  d       t        |      D ]&  }| j                  |      r|j                  |d       ( yw)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   r2   r   sortedremovediscardr   badr=   r
   r&   fsetr   s        r*   r   zmanifestdict.walk  s      <<>$Z 5;;=! u%Tl :H  	BTzBRy	 	S, 	$B;;r?		"d#	$s   A"C%)C6CCc                 p   |j                         r| j                         S | j                  |      rOt        | j                        }| j
                  }|j                         D ]  }||v s||   |j
                  |<    |S t        | j                        }| j
                  j                  |      |_        |S )z6generate a new manifest filtered by the match argument)r   r   r   r   rW   r   r2   r   )r=   r
   mr;   r   s        r*   _matcheszmanifestdict._matchesD  s    <<>99;u%T]]+ABkkm '8 "2AEE"I' H'##E*r   c                     |r5| j                  |      }|j                  |      }|j                  ||      S | j                  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.diffU  sO     u%BU#B772U7++xx}}RVVU++r   c                 R    |t         vrt        d      | |   |f| j                  |<   y )N   Invalid manifest flag set.)r!   r   r   )r=   rz   flags      r*   setflagzmanifestdict.setflagj  s+    ~%9::S	4r   c                 J    	 | j                   |   d   S # t        $ r |cY S w xY wr9   r   r   )r=   rz   defaults      r*   getzmanifestdict.geto  s.    	88C=## 	N	s    ""c                 F    	 | j                   |   d   S # t        $ r Y yw xY w)Nr   r   r  r   s     r*   r)   zmanifestdict.flagsu  s,    	88C=## 		s    	  c                 n    t        | j                        }| j                  j                         |_        |S r@   )r   rW   r   r   )r=   r   s     r*   r   zmanifestdict.copy{  s&    'r   c                 D    d | j                   j                         D        S )Nc              3   &   K   | ]	  }|d d   y wNr   rA   r   xs     r*   r   z%manifestdict.items.<locals>.<genexpr>       6!"16   r   r   rB   s    r*   itemszmanifestdict.items      6txx33566r   c                 D    d | j                   j                         D        S )Nc              3   &   K   | ]	  }|d d   y wr  rA   r  s     r*   r   z)manifestdict.iteritems.<locals>.<genexpr>  r  r  r  rB   s    r*   	iteritemszmanifestdict.iteritems  r  r   c                 6    | j                   j                         S r@   r  rB   s    r*   r   zmanifestdict.iterentries  s    xx##%%r   c                 6    | j                   j                         S r@   )r   r   rB   s    r*   r   zmanifestdict.text  s    xx}}r   c                    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|}|sp|j                  |       |#|j                  ||dj                  |      g       |}|}|g} |#|j                  ||dj                  |      g       t        ||      \  }}||fS t        | j                               }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.   r0   _addlistdelta	bytearrayr   r   textdiff)r=   basechangesdeltadstartdenddlinestartaddbufr&   todeleteendhr4   r%   	deltatext	arraytexts                    r*   	fastdeltazmanifestdict.fastdelta  s    T"w-w<66  '  8%fa7
s HHQKEAr%CFB7A|,BCaG  A%&E/demcz"Q)fdCHHUO%DE"FDCE/ 2 !fdCHHUO<=#0u#= Iy )## "$))+.ID!4;;y#9I )##r   r   r@   r   )!rM   rN   rO   r>   r   rI   r   r   __bool__r   r   r   rC   r   r   r   propertycacher   r   r   r   r   r  r   r  r  r)   r   r  r   r   r   r8  rA   r   r*   r   r     s    0 "
 H.
##%0 # #!
#$J",*(

77&5$r   r   c                 ^   	 	 fd}|s||fS t               	|s	}||k  rb||z   dz  }|}|dkD  r! |dz
  | dk7  r|dz  }|dkD  r |dz
  | dk7  r ||d      }t         ||       |k  r ||dz   d      dz   }n|}||k  rb ||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                 T    | k  r!| | dz    |k7  r| dz  } | k  r| | dz    |k7  r| S )Nr   rA   )r   r   lenmr  s     r*   advancez_msearch.<locals>.advance  sC    $h1QQ<1,FA $h1QQ<1,r   r   r   r   r   r   (   )r    r   )
r  rb   lohir?  midr1  r4  r   r>  s
   `        @r*   r&  r&    s
   
 Bxq6D
r'Bw1naiAeai%0E9QJE aiAeai%0E9eU#5" r5)A-B B r' "e
CbIEEzcBh&C!G}Bxr   c                     | D ]>  }d|v sd|v st        j                  t        d      t        j                  |      z         y)z'Check filenames for illegal characters.r      s)   '\n' and '\r' disallowed in filenames: %rN)r	   rV   r   r   bytestr)r%   r&   s     r*   r/   r/     sM     A:!$$@A""1%& r   c                     d}t               }|D ]   \  }}}|| || z  }|r|t        |      z  }|}" || |d  z  }dj                  d |D              }||fS )Nr   r   c           	   3   l   K   | ],  \  }}}t        j                  d ||t        |            |z    . yw)s   >lllN)structpackr    )r   r1  r4  contents       r*   r   z _addlistdelta.<locals>.<genexpr>  s6      E3 	GUCW6@s   24)r)  r0   )addlistr  currentposition
newaddlistr1  r4  rK  r6  s           r*   r(  r(    s     OJ  sGgoe44
)G,,J '/*++J #$ I j  r   c                 J    d| v r| j                  dd      \  }}|dz   |fS d| fS )N   /r   r   )r   )r&   r   subpaths      r*   _splittopdirrR    s5    qywwtQ'WTz7""Avr   c                      y r@   rA   )rb   s    r*   r   r     r   r   c                   T   e Zd Zd/d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d0dZd Zd Zd Zd Zd Zd Z d Z!d Z"d0dZ#e$d        Z%d  Z&d! Z'd" Z(d# Z)d$ Z*d% Z+d& Z,d1d'Z-d( Z.d) Z/d* Z0d+ Z1d, Z2d- Z3d0d.Z4y)2treemanifestc                 <   || _         || _        | j                  j                  | _        | j                  j                  | _        t        | _        t        | _        d| _	        i | _
        i | _        i | _        i | _        |rd }| j                  ||       d| _	        y y )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"   rW   _noop	_loadfunc	_copyfunc_dirtyr   	_lazydirs_files_flagsparse)r=   r\  r   r   rZ  s        r*   r>   ztreemanifest.__init__  s    	*''..
**22

 JJt[)DK r   c                      | j                   |z   S r@   r[  )r=   r   s     r*   _subpathztreemanifest._subpath6  s    yy4r   c                     | j                   }| j                  }| j                  j                         D ]>  \  }\  }}}|r! | ||      |      j	                         ||<   - | ||      |      ||<   @ i | _        y r@   )r   ri  rc  r  r   )r=   selfdirsrQ  r   r   rZ  docopys          r*   _loadalllazyztreemanifest._loadalllazy9  sy    ::--.2nn.B.B.D 	<*A*k6)'!*d;@@B)'!*d;		<
 r   c                    | j                   j                  |      }|ro|\  }}}|r4 || j                  |      |      j                         | j                  |<   n% || j                  |      |      | j                  |<   | j                   |= y y r@   )rc  r  ri  r   r   )r=   r   vr   rZ  rl  s         r*   	_loadlazyztreemanifest._loadlazyC  s|    NNq!()%D+v +DMM!,<d C H H J

1 +DMM!,<d C

1q! r   c                 ~    |sy |dk(  s|dk(  r| j                          y | j                  }|D ]  } ||dz           |S )N   all   thisrP  )rm  rp  )r=   visitloadlazyks       r*   _loadchildrensetlazyz!treemanifest._loadchildrensetlazyM  sN    F?ew.>> 	AQX	r   c                    g }|j                   j                         D ]?  \  }}|j                   j                  |      }|r|d   |d   k7  s/|j                  |       A |j                   j                         D ]%  \  }}||j                   vs|j                  |       ' |D ]$  }|j	                  |       |j	                  |       & y)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)rc  r  r  r.   rp  )r=   t1t2
toloadlazyr   v1v2s          r*   _loaddifflazyztreemanifest._loaddifflazyY  s     
\\'') 	%EAr!!!$BA"Q%!!!$	% \\'') 	%EAr$!!!$	%  	ALLOLLO	r   c                     | j                          t        | j                        }| j                          | j                  j                         D ]  }||j                         z  } |S r@   )_loadr    rd  rm  r   valuesr   )r=   sizer  s      r*   r   ztreemanifest.__len__o  sV    

4;;""$ 	 AAIIKD	 r   c                 $    | j                          S r@   _isemptyrB   s    r*   r   ztreemanifest.__nonzero__w  s    ==?""r   c                 :   | j                          | j                  s6| j                  r+t        d | j                  j	                         D              ry| j                          | j                   xs* t        d | j                  j	                         D              S )Nc              3   >   K   | ]  }|j                            y wr@   r  r   r  s     r*   r   z(treemanifest._isempty.<locals>.<genexpr>  s     MA1::</Ms   Fc              3   <   K   | ]  }|j                           y wr@   r  r  s     r*   r   z(treemanifest._isempty.<locals>.<genexpr>  s     $OaQZZ\$Os   )r  rd  r   anyr  rm  r   rB   s    r*   r  ztreemanifest._isempty}  sk    

;;JJ3M9J9J9LMM::~O$O4::;L;L;N$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   r^  boolr`  r_  rb  idrB   s    r*   __repr__ztreemanifest.__repr__  sH     K		DJJ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.rh  rB   s    r*   r   ztreemanifest.dir  s     yyr   c                 6    | 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.
        rb  r^  rB   s    r*   r   ztreemanifest.node  s     ;;zzr   c                      || _         d| _        y r   )r^  rb  r=   r   s     r*   setnodeztreemanifest.setnode  s    
r   c              #     K   | j                          | j                          t        t        j                  | j
                  j                         | j                  j                                     D ]]  \  }}|| j                  v r1| j                  |      || j                  j                  |d      f E|j                         D ]  }|  _ y wr   )r  rm  r   	itertoolschainr   r  rd  ri  re  r  r   )r=   pr'   r  s       r*   r   ztreemanifest.iterentries  s     

OODJJ,,.0A0A0CD
 	DAq DKKmmA&4;;??1c+BBB AG	s   CCc              #   ~  K   | j                          | j                          t        t        j                  | j
                  j                         | j                  j                                     D ]G  \  }}|| j                  v r| j                  |      |f *|j                         D ]  \  }}||f  I y wr@   )	r  rm  r   r  r  r   r  rd  ri  )r=   r  r'   r&   sns        r*   r  ztreemanifest.items  s     

OODJJ,,.0A0A0CD
 	 DAq DKKmmA&))WWY  EArR%K 	 s   B;B=c              #   0  K   | j                          | j                          t        t        j                  | j
                  | j                              D ]<  }|| j                  v r| j                  |       %| j
                  |   D ]  }|  > y wr@   )r  rm  r   r  r  r   rd  ri  )r=   r  r&   s      r*   r   ztreemanifest.iterkeys  sy     

	

DKK@A 	ADKKmmA&&A AG		s   BBc                 4    t        | j                               S r@   r   rB   s    r*   r   ztreemanifest.keys  r   r   c                 "    | j                         S r@   )r   rB   s    r*   rC   ztreemanifest.__iter__  s    }}r   c                     |y| j                          t        |      \  }}|r>| j                  |       || j                  vry| j                  |   j	                  |      S || j
                  v S r   )r  rR  rp  r   r   rd  r=   r&   r   rQ  s       r*   r   ztreemanifest.__contains__  sf    9

#AWNN3$**$::c?//88##r   Nc                     | j                          t        |      \  }}|r@| j                  |       || j                  vr|S | j                  |   j	                  ||      S | j
                  j	                  ||      S r@   )r  rR  rp  r   r  rd  )r=   r&   r  r   rQ  s        r*   r  ztreemanifest.get  sh    

#AWNN3$**$::c?&&w88;;??1g..r   c                     | j                          t        |      \  }}|r/| j                  |       | j                  |   j	                  |      S | j
                  |   S r@   )r  rR  rp  r   r   rd  r  s       r*   r   ztreemanifest.__getitem__  sN    

#AWNN3::c?..w77;;q>!r   c                 0   | j                          t        |      \  }}|r>| j                  |       || j                  vry| j                  |   j	                  |      S || j
                  v s|| j                  v ry| j                  j                  |d      S r   )r  rR  rp  r   r)   rc  re  r  r  s       r*   r)   ztreemanifest.flags  s}    

#AWNN3$**$::c?((11DNN"a4::o;;??1c**r   c                     | j                          t        |      \  }}|r/| j                  |       | j                  |   j	                  |      S | j
                  |   | j                  j                  |d      fS r   )r  rR  rp  r   rI   rd  re  r  r  s       r*   rI   ztreemanifest.find  sb    

#AWNN3::c?''00;;q>4;;??1c#:::r   c                 d   | j                          t        |      \  }}|ra| j                  |       | j                  |   j	                  |       | j                  |   j                         r=| j                  |= d| _        y | j                  |= || j                  v r| j                  |= d| _        y NT)	r  rR  rp  r   r   r  rd  re  rb  r  s       r*   r   ztreemanifest.__delitem__  s    

#AWNN3JJsO''0zz#'')JJsO
  ADKKKKNr   c                    |J | j                          t        |      \  }}|rx| j                  |       || j                  vr2t	        | j
                  | j                  |            | j                  |<   | j                  |   j                  ||       d| _
        y t        |      dv sJ || j                  |<   d| _
        y )Nr   T)r  rR  rp  r   rU  r\  ri  r   r    rd  rb  )r=   r&   r'   r   rQ  s        r*   r   ztreemanifest.__setitem__  s    }}

#AWNN3$**$".&&c(:#

3 JJsO''3  q6X%%%DKKNr   c                     | j                   t        ur!| j                   t        c}| _          ||        y | j                  t        ur!| j                  t        c}| _         ||        y y r@   )r`  r_  ra  )r=   lfcfs      r*   r  ztreemanifest._load.  sQ    >>&!%BtH^^5(!%BtH )r   c                    |t         vrt        d      | j                          t        |      \  }}|rx| j	                  |       || j
                  vr2t        | j                  | j                  |            | j
                  |<   | j
                  |   j                  ||       d| _        y|| j                  |<   d| _        y)z/Set the flags (symlink, executable) for path f.r  TN)r!   r   r  rR  rp  r   rU  r\  ri  r  re  rb  )r=   r&   r)   r   rQ  s        r*   r  ztreemanifest.setflag6  s    &9::

#AWNN3$**$".&&c(:#

3 JJsO##GU3  #DKKNr   c                 &    t         j                   j                        } j                  |_         j                  |_         j
                  t        u r* fd} j                  t        u r
 ||       |S ||_        |S  j
                  |_        |S )Nc           
         j                          j                  j                         D ci c]  \  }\  }}}|||df c}}}}| _        | j                  }j                  j                         D ]  \  }}|j	                         ||<    t
        j	                  j                        | _        t
        j	                  j                        | _        y c c}}}}w r  )r  rc  r  r   r   dictrd  re  )rb   r   r'   r   r   sdirsro  r=   s          r*   ra  z$treemanifest.copy.<locals>._copyfuncM  s    

8<8L8L8N (49Aq!A1d|O  JJ,,. (DAq vvxE!H(99T[[199T[[1s   C
)rU  r\  r[  r^  rb  ra  r_  r`  )r=   r   ra  s   `  r*   r   ztreemanifest.copyG  s~    D..		:ZZ
kk>>U"	2 ~~&$
  "+  "^^DNr   c                      |rC|j                         s3 j                  |      }|j                  |      }|j                  |      S t                fd  |       S )r   c                    | j                   |j                   k(  r| j                  s|j                  sy | j                          |j                          j                  | |       | j                  j                         D ]K  \  }}||j                  v r|j                  |   } ||       -j                  |j                                M | j                  D ]1  }||j                  vsj                  | j                  |             3 y r@   )r^  rb  r  r~  r   r  updater   rd  addri  )	ry  rz  r   r	  r   r   _filesnotinr2   r=   s	         r*   r  z,treemanifest.filesnotin.<locals>._filesnotini  s    xx288#BIIbiiHHJHHJr2&) 02=!BB'LL/0 ii /RYY&IIbkk"o./r   )r   r  r   r   )r=   r   r
   r	  r  r2   s   `   @@r*   r   ztreemanifest.filesnotin`  sV    u%BU#B==$$	/" 	D"r   c                 ,    t        j                  |       S r@   r   rB   s    r*   _alldirsztreemanifest._alldirs}  r   r   c                     | j                   S r@   )r  rB   s    r*   r   ztreemanifest.dirs  s    }}r   c                    | j                          t        |      \  }}|r>| j                  |       || j                  v r| j                  |   j	                  |      S y|dz   }|| j                  v xs || j
                  v S )NFrP  )r  rR  rp  r   r   rc  )r=   r   topdirrX  dirslashs        r*   r   ztreemanifest.hasdir  sw    

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

        It also reports nonexistent files by marking them bad with match.bad().
        Nr   )
r   r   r   r2   _walkr   r   r   r   r   r  s        r*   r   ztreemanifest.walk  s     
 <<>$Z 5;;=!**U# 	BTzBH		 	S, 	$B;;r?		"d#	$s   BB6!B6c              #     K   |j                  | j                  dd       }|sy| j                          | j                  |      }t	        t        | j                        t        | j                        z         D ]`  }|| j                  v r| j                  |      } ||      s+| 0|r|dd |v s:| j                  |   j                  |      D ]  }|  b yw)z5Recursively generates matching file names for walk().Nr   )
visitchildrensetr[  r  rw  r   r   r   rd  ri  r  )r=   r
   rt  r  fullpr&   s         r*   r  ztreemanifest._walk  s     &&tyy"~6 	

))%0TZZ(4+<<= 	 ADKKa(<K#2%!ZZ]007   	 s   B!C$C3*Cc                 d    |j                         r| j                         S | j                  |      S )zCrecursively generate a new manifest filtered by the match argument.)r   r   _matches_inner)r=   r
   s     r*   r  ztreemanifest._matches  s(    <<>99;""5))r   c                    |j                         r| j                         S |j                  | j                  d d       }|dk(  r| j                         S t	        | j
                  | j                        }|s|S | j                          | j                  D ]m  }|dk7  r||vr| j                  |      } ||      s'| j                  |   |j                  |<   || j                  v sR| j                  |   |j                  |<   o | j                  |      }| j                  j                         D ]@  \  }}|r|d d |vr|j                  |      }|j                         r2||j                  |<   B |j                         sd|_        |S )Nr   rr  rs  T)r   r   r  r[  rU  r\  r  rd  ri  re  rw  r   r  r  r  rb  )	r=   r
   rt  retr   r  r   rY  r  s	            r*   r  ztreemanifest._matches_inner  sc   <<>99;&&tyy"~6F?99;4--tyy9J

++ 	1B BeOMM"%E <![[_CJJrNT[[ !%R

2	1" ))%0))+ 	#ICSb.##E*A::<!"		#	# ||~CJ
r   c                     t               r@   )FastdeltaUnavailable)r=   r+  r,  s      r*   r8  ztreemanifest.fastdelta  s    "$$r   c                 6   	
 |rE|j                         s5 j                  |      }|j                  |      }|j                  |      S i 
t         j                        		
 fd}g } | ||       |r |j                         \  }} ||||       |r 
S )r  r  c                 &   | j                   |j                   k(  r| j                  s|j                  sy| j                          |j                          j                  | |       | j                  j                         D ]4  \  }}|j                  j                  |      }|j                  ||f       6 |j                  j                         D ]'  \  }}|| j                  vs|j                  |f       ) | j                  j                         D ]  \  }}| j                  j                  |d      }|j                  j                  |d      }	|j                  j                  |d      }
||	k7  s||
k7  r||f|	|
ff| j                  |      <   sd| j                  |      <    |j                  j                         D ]H  \  }}	|| j                  vs|j                  j                  |d      }
d|	|
ff|j                  |      <   J y)zicompares two tree manifests and append new tree-manifests which
            needs to be compared to stackNr   r   )r^  rb  r  r~  r   r  r  r.   rd  re  ri  )ry  rz  stackr   r	  r   r   n1fl1n2fl2r   	emptytreeresultr=   s              r*   _iterativediffz)treemanifest.diff.<locals>._iterativediff  s    xx288#BIIbiiHHJHHJr2&) '2XX\\!Y/b"X&' ) 22BHH$LL)R12 ))//+ 3BiimmB,YY]]2t,iimmB,8scz02Cy2s).DF2;;r?+.2F2;;r?+3 ))//+ GBRYY&))--C0C/:RI.FF2;;r?+Gr   )r   r  r   rU  r\  pop)r=   r   r
   r   r	  r  stacklsry  rz  r  r  s   `  `     @@r*   r   ztreemanifest.diff  s     u%BU#B772U7++ !3!34		G> tR)[[]FB2r7+  r   c                 p    | j                    xr( |j                    xr | j                  |j                  k(  S r@   r  )r=   r   s     r*   unmodifiedsinceztreemanifest.unmodifiedsince+  s+    ;;Kryy=KTZZ2885KKr   c                     | j                   }t        | j                  |      D ]Y  \  }}}|dk(  r|dz   }||df||<   d|v r|| |<   |s&| j                  ||       9|| j                  |<   |sK|| j
                  |<   [ y )Nrh   rP  F)rc  r+   rW   r  rd  re  )r=   r   rZ  selflazyr&   r'   r4   s          r*   rf  ztreemanifest.parse.  s    >>t}}d3 	(HAq"TzH  !+u5
 QLLB' "#A%'DKKN'	(r   c                 T    | j                          t        | j                               S )z3Get the full data of this manifest as a bytestring.)r  r5   r   rB   s    r*   r   ztreemanifest.textE  s    

T%%'((r   c                    | j                          | j                  }| j                  j                         D cg c]  \  }}|dd |d   df }}}| j                  D cg c]!  }|dd | j                  |   j
                  df# }}| j                  D cg c]  }|| j                  |    ||      f }}t        t        ||z   |z               S c c}}w c c}w c c}w )zGet the full data of this directory as a bytestring. Make sure that
        any submanifests have been written first, so their nodeids are correct.
        Nr   r   rh   )	r  r)   rc  r  r   r^  rd  r5   r   )r=   r)   r   ro  lazydirsr   r&   r2   s           r*   dirtextztreemanifest.dirtextJ  s     	



59^^5I5I5KLTQQsVQqT4(LL=AZZH3BA,,d3HH8<D1!T[[^U1X.DDVD5L83455 MHDs   C &CCc                 "    fd}|| _         y )Nc                 B    | j                                 d| _        y r   )rf  rb  )rb   gettextrZ  s    r*   _load_for_readz)treemanifest.read.<locals>._load_for_readV  s    GGGI{+AHr   )r`  )r=   r  rZ  r  s    `` r*   readztreemanifest.readU  s    	 (r   c                    | j                          |j                          |j                          t        | j                        fd}|j                  | j                  d d       }| j                  |      }|dk(  s|dk(  rd }| j                  j                         D ]I  \  }}|r|d d |vr |||      }	 |||      }
|	| j                  j                  k(  r|
|	}
}	 |||	|
|       K y )Nc                     | j                   j                  |      }|r|d   S | j                  j                  |      j                  S r9   )rc  r  r   r^  )r  r   ldr  s      r*   getnodez+treemanifest.writesubtrees.<locals>.getnodeb  s<    #B!u77;;q),222r   r   rs  rr  )	r  rU  r\  r  r[  rw  r   r  r]  )r=   r	  r   writesubtreer
   r  rt  r   rY  subp1subp2r  s              @r*   writesubtreesztreemanifest.writesubtrees\  s    





 !3!34		3 &&tyy"~6))%0GuEzz'') 	4GAt3Bu,BNEBNE**111$euueU3	4r   c              #   >  K   |r|j                  | j                  dd       sy|r || j                  dd       r|  | j                          | j                          | j                  j                         D ]   \  }}|j                  |      D ]  }|  " yw)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  rm  r   r  walksubtrees)r=   r  r   rY  subtrees        r*   r  ztreemanifest.walksubtreesv  s      7++DIIcrN;'$))CR.1J

zz'') 	GAt,,W,= 	s   BB)r   r   r@   r   )5rM   rN   rO   r>   ri  rm  rp  rw  r~  r   r   r:  r  r   	strmethodr  r   r   r  r   r  r   r   r   rC   r   r  r   r)   rI   r   r   r  r  r   r   r;  r  r   r   r   r  r  r  r8  r   r  rf  r   r  r  r  r  rA   r   r*   rU  rU    s   . "
,# HP 

 




  I%$
/"+; &"2: # #	D$4 &*'R%;zL(.)
	6(44r   rU  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                 V    t         t        |   |       d| _        d| _        d | _        y r   )superr  r>   rb  _read_opener)r=   max	__class__s     r*   r>   zmanifestfulltextcache.__init__  s(    #T3C8
r   c                    | j                   s| j                  y 	 | j                  | j                        5 }t        t        |   }	 |j                  d      }t        |      dk  rn\	 t        j                  d|j                  d            d   }t        |j                  |            }t        |      |k7  rn
 |||       |d d d        d| _         d| _        y # t        j                  $ r Y ,w xY w# 1 sw Y   1xY w# t        $ r Y ?w xY w)NTr      >L   r   F)r  r  _filer  r  r   r  r    rI  unpackr	   r)  IOErrorrb  )r=   fpr   r   r  r   r  s         r*   r  zmanifestfulltextcache.read  s    ::-	djj) %R14D772;D4y2~%}}UBGGAJ?B &bggdm4E5zT)e$ %( 
 "<< % %   		sL   C? 0C3((C3C3C? C0-C3/C00C33C<8C? ?	D
Dc           	      2   | j                   r| j                  y 	 | j                  | j                  ddd      5 }| j                  j                  }	 |j
                  | j                  v rn|j                  |j
                         |j                  t        j                  dt        |j                                     |j                  |j                         || j                  u rn|j                  }	 d d d        y # 1 sw Y   y xY w# t        $ r Y y w xY w)N   wT)
atomictemp
checkambigr  )rb  r  r  _headr$   rz   _cachewriterI  rJ  r    r   r  )r=   r  r   s      r*   r  zmanifestfulltextcache.write  s    {{dll2	

DTd   %zzxx4;;.*UC

O!DE,tzz)99D  % % %  		 		s/   D
 B:C>5D
 >DD
 D
 
	DDc                 `    | j                   s| j                          t        t        |          S r@   )r  r  r  r  r   r=   r  s    r*   r   zmanifestfulltextcache.__len__  s$    zzIIK*D9;;r   c                 b    | j                   s| j                          t        t        |   |      S r@   )r  r  r  r  r   r=   rv  r  s     r*   r   z"manifestfulltextcache.__contains__  s&    zzIIK*D>qAAr   c                 `    | j                   s| j                          t        t        |          S r@   )r  r  r  r  rC   r  s    r*   rC   zmanifestfulltextcache.__iter__  s$    zzIIK*D:<<r   c                     | j                   s| j                          | j                  j                  |      | j                  u}t
        t        |   |      }|rd| _        |S r  )	r  r  r   r  r  r  r  r   rb  )r=   rv  setdirtyr   r  s       r*   r   z!manifestfulltextcache.__getitem__  sO    zzIIK;;??1%TZZ7+T>qADKr   c                 t    | j                   s| j                          t        t        |   ||       d| _        y r  )r  r  r  r  r   rb  )r=   rv  ro  r  s      r*   r   z!manifestfulltextcache.__setitem__  s,    zzIIK#T6q!<r   c                 r    | j                   s| j                          t        t        |   |       d| _        y r  )r  r  r  r  r   rb  r  s     r*   r   z!manifestfulltextcache.__delitem__  s*    zzIIK#T6q9r   c                 f    | j                   s| j                          t        t        |   ||      S )N)r  )r  r  r  r  r  )r=   rv  r  r  s      r*   r  zmanifestfulltextcache.get  s+    zzIIK*D5a5IIr   c                 j    t         t        |           |rd| _        | j	                          d| _        y )NTF)r  r  clearrb  r  r  )r=   clear_persisted_datar  s     r*   r  zmanifestfulltextcache.clear  s+    #T02DKJJL
r   r@   r   )rM   rN   rO   r   r  r>   r  r  r   r   rC   r   r   r   r  r  __classcell__r  s   @r*   r  r    sM     %E88<
B
=
J
 r   r     c                       e Zd ZdZy)r  z;Exception raised when fastdelta isn't usable on a manifest.N)rM   rN   rO   r   rA   r   r*   r  r    s    Er   r  c                   L   e Zd ZdZ	 	 	 d$dZ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 Zd Zd Zd Zd Zdddej8                  ddfdZ	 	 	 	 	 d'dZd Zd Z d Z!d Z"d  Z#	 	 	 	 	 d(d!Z$ed"        Z%e%jL                  d#        Z%y))manifestrevlogznA revlog that stores manifest texts. This is responsible for caching the
    full-text manifest contents.
    NFc                 2   || _         d}d}t        |dd      }|$|j                  d|      }|j                  dd      }|xs || _        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                  j                  dd            | _        | j                  j                  | _        y)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\  getattrr  _treeondiskr  _fulltextcachetree_dirlogcacher   revlog_constantsKIND_MANIFESTLOGr  MAXCOMPRESSIONr  _revlogrt   )
r=   r\  openerr!  dirlogcacherU  	cachesizeoptiontreemanifestoptsr  s
             r*   r>   zmanifestrevlog.__init__  s   $ + 	"vy$/!5yAI!%/5!A-=3I>##AdMD,@%AA#tOe+E	  +D!$dD}}$55tyyA:~)$nn001FN	
 \\''
r   c                     | j                   S )zreturn an actual revlog instance if any

        This exist because a lot of code leverage the fact the underlying
        storage is a revlog for optimization, so giving simple way to access
        the revlog instance helps such code.
        )r&  rB   s    r*   
get_revlogzmanifestrevlog.get_revlogR  s     ||r   c                    t        |d      sy|j                  | j                  _        |j	                  |j
                        yt        j                  |      t        j                  |       fd}|j                  |       y)z1Persist the manifestfulltextcache on lock release	_wlockrefNc                     | sy         }        }||y |j                   j                  d      |ury |j                  j                          y r   )manifestlog
getstorager   r  )successrepor=   manifestrevlogrefreporefs      r*   persistmanifestcachezEmanifestrevlog._setupmanifestcachehooks.<locals>.persistmanifestcacheg  sR    9D$&D|t|**3/t;%%'r   )	hasattr	wcachevfsr   r  _currentlockr/  weakrefref
_afterlock)r=   r4  r7  r5  r6  s      @@r*   _setupmanifestcachehooksz'manifestrevlog._setupmanifestcachehooks[  sk    t[)&*nn#T^^,4++d##KK-	( 	,-r   c                     | j                   S r@   )r   rB   s    r*   fulltextcachezmanifestrevlog.fulltextcachew  s    """r   c                     | j                   j                          | j                  j                  |       | j                  | i| _        y N)r  )r&  clearcachesr   r  r!  r"  r=   r  s     r*   rC  zmanifestrevlog.clearcaches{  s;      "!!7K!L!YY-r   c                     |r| j                   sJ || j                  vrGt        | j                  | j                  || j                  | j                         }|| j                  |<   | j                  |   S )N)rU  )r  r"  r  r\  r'  )r=   r   mfrevlogs      r*   dirlogzmanifestrevlog.dirlog  st    ####D%%%%""!!!--H $,Da   ##r   c
           
         	 || j                   vr
t               t        |       t        j                  t        |      D 
cg c]  }
|
df c}
t        |      D 
cg c]  }
|
df c}
      }|j                  | j                   |   |      \  }}| j                  j                  |      |f}t        j                  |      }| j                  j                  ||||||      }| j                  j                  |      }||| j                   |<   |S c c}
w c c}
w # t        $ r | j                  rS|sJ d       |	sJ d        || j                  |      } || j                  |      }| j                  |||||||	      }d}nU|j!                         }| j                  j                  |||||      }| j                  j                  |      }t#        |      }Y w xY w)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
        FTs,   readtree must be set for treemanifest writess/   match must be specified for treemanifest writesr
   N)r@  r  r/   heapqmerger   r8  r&  revr   r$  addrevisionr   r  r!  _addtreer   r)  )r=   r  transactionlinkp1p2addedremovedreadtreer
   r  workr7  r6  
cachedeltar   rL  r'   r	  r   s                       r*   r  zmanifestrevlog.add  s   8)	,+++*,, E";;%+E]3!U3$*7O4q!T4D
 $%;;t/A/A"/Et#L Iy))"-y8J;;y)D,,**k4RC !!#&A,  $-Dq!G 44 $ 	, P!PPxPPPudii,dii,MM{D"b(% "  !	vvxll..t[$BOLL%%c*%dO	'	,s1   ?D DD D
&BD 
D B=GGc                 j     j                   dk7  r2|j                  |      s|j                  |      r|j                         S  fd}|j                  ||||       |j	                         }	d }
 j                   dk7  rG|	|j	                         k(  r|j                         }
n#|	|j	                         k(  r|j                         }
|
sV j
                  j                  |	|j                         |j                               } j
                  j                  |      }
|j                  |
       |
S )Nr   c                 x    j                  | j                               }|j                  | ||d d |	       y )NrU  r
   )rG  r   r  )	rY  r  r  r
   sublogrP  rU  r=   rO  s	        r*   r  z-manifestrevlog._addtree.<locals>.writesubtree  sC    [[,FJJ!  
r   )r!  r  r   r  r  r&  rM  r  )r=   r  rO  rP  r	  r   rU  r
   r  r   r'   rL  s   ` ``  `     r*   rN  zmanifestrevlog._addtree  s     99b!Q%6%6r%:668O	 	
Be4yy{99rzz|#GGI%GGI,,**k4BGGIC !!#&A 	
		!r   c                 ,    t        | j                        S r@   )r    r&  rB   s    r*   r   zmanifestrevlog.__len__  s    4<<  r   c                 6    | j                   j                         S r@   )r&  rC   rB   s    r*   rC   zmanifestrevlog.__iter__  s    ||$$&&r   c                 8    | j                   j                  |      S r@   )r&  rL  r  s     r*   rL  zmanifestrevlog.rev
  s    ||%%r   c                 8    | j                   j                  |      S r@   )r&  r   r=   rL  s     r*   r   zmanifestrevlog.node  s    ||  %%r   c                 8    | j                   j                  |      S r@   )r&  lookupr=   r   s     r*   rb  zmanifestrevlog.lookup  s    ||""5))r   c                 8    | j                   j                  |      S r@   )r&  
parentrevsr`  s     r*   re  zmanifestrevlog.parentrevs  s    ||&&s++r   c                 8    | j                   j                  |      S r@   )r&  parentsr  s     r*   rg  zmanifestrevlog.parents      ||##D))r   c                 8    | j                   j                  |      S r@   )r&  linkrevr`  s     r*   rj  zmanifestrevlog.linkrev      ||##C((r   c                 6    | j                   j                         S r@   )r&  	checksizerB   s    r*   rm  zmanifestrevlog.checksize  s    ||%%''r   c                 8    | j                   j                  |      S r@   )r&  revisionr  s     r*   ro  zmanifestrevlog.revision  s    ||$$T**r   c                 8    | j                   j                  |      S r@   )r&  rawdatar  s     r*   rq  zmanifestrevlog.rawdata"  rh  r   c                 :    | j                   j                  ||      S r@   )r&  revdiff)r=   rev1rev2s      r*   rs  zmanifestrevlog.revdiff%  s    ||##D$//r   c                 :    | j                   j                  ||      S r@   )r&  cmp)r=   r   r   s      r*   rw  zmanifestrevlog.cmp(  s    ||d++r   c                 8    | j                   j                  |      S r@   )r&  deltaparentr`  s     r*   ry  zmanifestrevlog.deltaparent+  s    ||'',,r   c           	      F    | j                   j                  |||||||      S )N)
nodesorderrevisiondataassumehaveparentrevisions	deltamodesidedata_helpers
debug_info)r&  emitrevisions)r=   nodesr{  r|  r}  r~  r  r  s           r*   r  zmanifestrevlog.emitrevisions.  s5     ||))!%&?-! * 
 	
r   c	           
      H    | j                   j                  ||||||||      S )N)alwayscacheaddrevisioncbduplicaterevisioncbr  delta_base_reuse_policy)r&  addgroup)	r=   deltas
linkmapperrO  r  r  r  r  r  s	            r*   r  zmanifestrevlog.addgroupB  s8     ||$$#' 3!$; % 	
 		
r   c                 8    | j                   j                  |      S r@   )r&  rawsizer`  s     r*   r  zmanifestrevlog.rawsizeX  rk  r   c                 8    | j                   j                  |      S r@   )r&  getstrippoint)r=   minlinks     r*   r  zmanifestrevlog.getstrippoint[  s    ||))'22r   c                 :    | j                   j                  ||      S r@   )r&  strip)r=   r  rO  s      r*   r  zmanifestrevlog.strip^  s    ||!!';77r   c                 6    | j                   j                         S r@   )r&  r2   rB   s    r*   r2   zmanifestrevlog.filesa  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.cloned  sB    *n5(()NOO!t||!!"j&8&8CFCCr   c                 B    | j                   j                  |||||      S )N)exclusivefilessharedfilesrevisionscounttrackedsize
storedsize)r&  storageinfo)r=   r  r  r  r  r  s         r*   r  zmanifestrevlog.storageinfoj  s/     ||'')#)#! ( 
 	
r   c                 .    | j                   j                  S r@   r&  r'  rB   s    r*   r'  zmanifestrevlog.openerz  s    ||"""r   c                 &    || j                   _        y r@   r  rc  s     r*   r'  zmanifestrevlog.opener~  s    #r   )r   NFr   )NN)FNNNN)FFFFF)'rM   rN   rO   r   r>   r-  r>  propertyr@  rC  rG  r  rN  r   rC   rL  r   rb  re  rg  rj  rm  ro  rq  rs  rw  ry  r   CG_DELTAMODE_STDr  r  r  r  r  r2   r  r  r'  setterrA   r   r*   r  r    s,    ;(z.8 # #.
$. JX(T!'&&*,*)(+*0,- "'--
2   $
,)38$D 
  # # ]]$ $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
y	)r1  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                 T   |j                   | _         d}d}t        |dd       }|$|j                  d|      }|j                  d|      }|| _        || _        | j                  j                  |       || _        i | _        t        j                  |      | j                  d<   || _
        y )NFr  r  r  r  r   )r\  r  r  _treemanifests
_rootstorer>  _narrowmatch_dirmancacher   lrucachedict
_cachesize)r=   r'  r4  	rootstorenarrowmatchusetreemanifestr)  r+  s           r*   r>   zmanifestlog.__init__  s    !//	vy$/"hhHO!5yAI-#006' !%!2!29!=##r   c                 &    | j                  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   c                 .   || j                   j                  |d      v r| j                   |   |   S | j                  j                         s5| j                  j	                  |dd       st        | j                  ||      S |rg| j                  j                  r0|r | j                  |      j                  |       t        | ||      }ndt        j                  t        d      |z        |r| j                  j                  |       | j                  rt        | d|      }nt!        | |      }|| j                  j"                  k7  rP| j                   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
        rA   Nr   s9   cannot ask for manifest directory '%s' in a flat manifestr   )r  r  r  r   r  excludeddirmanifestctxr\  r  r  r2  rL  treemanifestctxr	   Abortr   r  manifestctxr]  r   r  r  )r=   r!  r   verifyr  mancaches         r*   r  zmanifestlog.get  sq    4$$((r22$$T*400  '')$$--d3Bi8-d.@.@$MM** OOD)--d3#D$5kk$ 	  ##D)""#D#t4d+4%%,,,((,,T2H,,T__=*2!!$'HTNr   c                 8    | j                   j                  |      S r@   )r  rG  )r=   r!  s     r*   r2  zmanifestlog.getstorage  s    %%d++r   c                 p    | j                   j                          | j                  j                  |       y rB  )r  r  r  rC  rD  s     r*   rC  zmanifestlog.clearcaches  s*    !##9M#Nr   c                 8    | j                   j                  |      S r@   )r  rL  r  s     r*   rL  zmanifestlog.rev  s    ""4((r   c                 N    | j                   j                  j                  |      S )N)rO  )r  r&  update_caches)r=   rO  s     r*   r  zmanifestlog.update_caches  s     &&444MMr   N)Tr   )rM   rN   rO   r   r>   r   r  r2  rC  rL  r  rA   r   r*   r1  r1    s-    ?$,#-^,O)Nr   r1  c                   ,    e Zd Zd Zd Zd Zd ZddZy)memmanifestctxc                 Z    || _         t        |j                  j                        | _        y r@   )_manifestlogr   r\  r"   _manifestdict)r=   r1  s     r*   r>   zmemmanifestctx.__init__  s#    ')+*C*C*K*KLr   c                 8    | j                   j                  d      S r   r  r2  rB   s    r*   _storagezmemmanifestctx._storage        ++C00r   c                 v    t        | j                        }| j                         j                         |_        |S r@   r  r  r  r   r  r=   memmfs     r*   r   zmemmanifestctx.copy  .    t001"iik..0r   c                     | j                   S r@   )r  rB   s    r*   r  zmemmanifestctx.read      !!!r   Nc           
      d    | j                         j                  | j                  |||||||      S )NrI  )r  r  r  )r=   rO  rP  rQ  rR  rS  rT  r
   s           r*   r  zmemmanifestctx.write  s>    }}"" # 	
 		
r   r@   rM   rN   rO   r>   r  r   r  r  rA   r   r*   r  r    s    M1
"

r   r  c                   T    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y)r  zxA class representing a single revision of a manifest, including its
    contents, its parent revs, and its linkrev.
    c                 .    || _         d | _        || _        y r@   )r  _datar^  )r=   r1  r   s      r*   r>   zmanifestctx.__init__
  s    '

r   c                 8    | j                   j                  d      S r   r  rB   s    r*   r  zmanifestctx._storage  r  r   c                     | j                   S r@   r^  rB   s    r*   r   zmanifestctx.node  r   r   c                 v    t        | j                        }| j                         j                         |_        |S r@   r  r  s     r*   r   zmanifestctx.copy  r  r   c                 T    | j                         j                  | j                        S r@   r  rg  r^  rB   s    r*   rg  zmanifestctx.parents"      }}&&tzz22r   c                 <   | j                   | j                  j                  }| j                  |j                  k(  r&t        |j                        | _         | j                   S | j                         }| j                  |j                  v r-t        j                  |j                  | j                           }n?|j                  | j                        }t        |      }||j                  | j                  <   t        |j                  |      | _         | j                   S r@   )r  r  r\  r^  r]  r   r"   r  r@  r   rF  ro  r)  )r=   ncstorer   r7  s        r*   r  zmanifestctx.read&  s    ::""00BzzRYY&)"**5
 zz ::!4!44#++E,?,?

,KLD >>$**5D )$I6?E''

3)"**d;
zzr   c                     | j                         }|j                  | j                        }|j                  |      }|t        k7  r#||j                  |      v r| j                         S | j                         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  rL  r^  ry  r   re  	readdeltar  r=   shallowr  r   ry  s        r*   readfastzmanifestctx.readfast6  sd     IIdjj!''*'!kU5E5Ea5H&H>>##yy{r   c                     | j                         }|j                  | j                        }t        j                  |j                  |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  rL  r^  r   	patchtextrs  ry  r   r\  r"   )r=   r  r  r   r   s        r*   r  zmanifestctx.readdeltaD  s^     IIdjj!OOEMM%*;*;A*>BCE//77;;r   c                 @    | j                         j                  |      S r@   r  rI   r   s     r*   rI   zmanifestctx.findP      yy{$$r   Nr   )rM   rN   rO   r   r>   r  r   r   r;  rg  r  r  r  rI   rA   r   r*   r  r    sC    1
 3 3 
<%r   r  c                   .    e Zd ZddZd Zd Zd ZddZy)	memtreemanifestctxc                 T    || _         || _        t        |j                        | _        y r@   )r  r[  rU  r\  _treemanifest)r=   r1  r   s      r*   r>   zmemtreemanifestctx.__init__V  s$    '	)+*C*CDr   c                 8    | j                   j                  d      S r   r  rB   s    r*   r  zmemtreemanifestctx._storage[  r  r   c                     t        | j                  | j                        }| j                  j	                         |_        |S Nr   )r  r  r[  r  r   r  s     r*   r   zmemtreemanifestctx.copy^  s4    "4#4#4$))D"00557r   c                     | j                   S r@   )r  rB   s    r*   r  zmemtreemanifestctx.readc  r  r   Nc                 r      fd} j                         j                   j                  ||||||||	      S )Nc                 X    j                   j                  | |      j                         S r@   r  r  r  )r   r   r=   s     r*   rU  z*memtreemanifestctx.write.<locals>.readtreeg  s%    $$((d388::r   rZ  )r  r  r  )	r=   rO  rP  rQ  rR  rS  rT  r
   rU  s	   `        r*   r  zmemtreemanifestctx.writef  sI    	; }}"" # 

 
	
r   r9  r@   r  rA   r   r*   r  r  T  s    E
1
"
r   r  c                   P    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y
)r  c                 <    || _         || _        d | _        || _        y r@   )r  r[  r  r^  )r=   r1  r   r   s       r*   r>   ztreemanifestctx.__init__y  s    '	

r   c                 (   | j                   j                  }|j                         sH|j                  | j                  d d       s*t        | j                   j                  | j                        S | j                   j                  | j                        S r   )r  r  r   r  r[  excludedmanifestrevlogr\  r2  )r=   r  s     r*   r  ztreemanifestctx._storage  sv    ''44!!#''		#27-%%33TYY    ++DII66r   c                      j                    j                          j                   j                  j                  j
                  k(  r0t         j                  j                         _          j                   S j                  rvt         j                  j                   j                        } fd} fd}|j                  ||       |j                   j                         | _          j                   S  j                  j                  v r-t        j                  j                   j                           }n?j                   j                        }t        |      }|j                   j                  <   t         j                  j                   j                  |       _          j                   S )Nr  c                  :    j                   j                        S r@   )ro  r^  )r=   r  s   r*   r  z%treemanifestctx.read.<locals>.gettext  s     >>$**55r   c                 \    j                   j                  | |d      j                         S )NF)r  r  )r   rY  r=   s     r*   rZ  z)treemanifestctx.read.<locals>.readsubtree  s,      ,,00d50INNPPr   )r   r   )r  r  r^  r  r\  r]  rU  r  r[  r  r  r@  r   rF  ro  r)  )r=   r  r  rZ  r   r7  r  s   `     @r*   r  ztreemanifestctx.read  sP   ::MMOEzzT..<<CCC)$*;*;*I*IJ
6 zz3 "" !2!2!@!@diiP6Q
 w,		$**%
 zz ::!4!44#++E,?,?

,KLD >>$**5D )$I6?E''

3)%%33
 zzr   c                     | j                   S r@   r  rB   s    r*   r   ztreemanifestctx.node  r   r   c                     t        | j                  | j                        }| j                         j	                         |_        |S r  )r  r  r[  r  r   r  r  s     r*   r   ztreemanifestctx.copy  s4    "4#4#4$))D"iik..0r   c                 T    | j                         j                  | j                        S r@   r  rB   s    r*   rg  ztreemanifestctx.parents  r  r   c                    | j                         }|ro|j                  | j                        }t        j                  |j                  |j                  |      |            }t        |j                  j                  |      S |j                  |j                  | j                              }| j                  j                  | j                  |j                  |            j                         }| j                         }t        | j                  j                  | j                        }|j!                  |      j#                         D ]+  \  }	\  \  }
}\  }}|s|||	<   |s|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.

        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  rL  r^  r   r  rs  ry  r   r\  r"   r  r  r[  r   r  rU  r   r  r  )r=   r  r  r   r   r0m0r	  mdr&   n0fl0r  r  s                 r*   r  ztreemanifestctx.readdelta  s*    		$**%Ae.?.?.BA FGA 3 3 ; ;Q?? ""599TZZ#89B""&&tyy%**R.AFFHBBd//==499MB-/WWR[->->-@ +))IRyCBqE

1c*	+
 Ir   c                 l   | j                         }|j                  | j                        }|j                  |      }|t        k7  r%||j                  |      v r| j                  |      S |r9t        |j                  j                  |j                  | j                              S | j                         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  rL  r^  ry  r   re  r  r   r\  r"   ro  r  r  s        r*   r  ztreemanifestctx.readfast  s     IIdjj!''*'!kU5E5Ea5H&H>>'>22##++U^^DJJ-G  99;r   c                 @    | j                         j                  |      S r@   r  r   s     r*   rI   ztreemanifestctx.find  r  r   Nr   )rM   rN   rO   r>   r  r  r   r   r;  rg  r  r  rI   rA   r   r*   r  r  w  s?    7B
 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                 x    t         t        |   ||       || _        || j                  d<   d| j
                  d<   y )Nr   rh   )r  r  r>   r^  rd  re  )r=   r\  r   r   r  s       r*   r>   zexcludeddir.__init__  s9    k4)-=
  CCr   c                     | S r@   rA   rB   s    r*   r   zexcludeddir.copy	  rD   r   )rM   rN   rO   r   r>   r   r  r  s   @r*   r  r    s    	 r   r  c                   *    e Zd ZdZd Zd ZddZd Zy)r  zBcontext wrapper for excludeddir - see that docstring for rationalec                 .    || _         || _        || _        y r@   )r\  r[  r^  )r=   r\  r   r   s       r*   r>   zexcludeddirmanifestctx.__init__	  s    *	
r   c                 X    t        | j                  | j                  | j                        S r@   )r  r\  r[  r^  rB   s    r*   r  zexcludeddirmanifestctx.read	  s    4--tyy$**EEr   c                 "    | j                         S r@   )r  )r=   r  s     r*   r  zexcludeddirmanifestctx.readfast	  s    yy{r   c                 F    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   )rM   rN   rO   r   r>   r  r  r  rA   r   r*   r  r  	  s    L
F
r   r  c                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	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                      || _         || _        y r@   )r\  r[  )r=   r\  r   s      r*   r>   zexcludedmanifestrevlog.__init__/	  s    *	r   c                 F    t        j                  d| j                  z        )Ns(   attempt to get length of excluded dir %sr  rB   s    r*   r   zexcludedmanifestrevlog.__len__3	  !    $$7$))C
 	
r   c                 F    t        j                  d| j                  z        )Ns'   attempt to get rev from excluded dir %sr  r  s     r*   rL  zexcludedmanifestrevlog.rev8	  s!    $$6B
 	
r   c                 F    t        j                  d| j                  z        )Ns+   attempt to get linkrev from excluded dir %sr  r  s     r*   rj  zexcludedmanifestrevlog.linkrev=	  s!    $$:TYYF
 	
r   c                 F    t        j                  d| j                  z        )Ns(   attempt to get node from excluded dir %sr  r`  s     r*   r   zexcludedmanifestrevlog.nodeB	  r  r   c                      y r@   rA   )r=   r  r  s      r*   r  zexcludedmanifestrevlog.addG	  s     	r   N)
rM   rN   rO   r   r>   r   rL  rj  r   r  rA   r   r*   r  r  %	  s%    







r   r  )r   N)DrJ  r  rI  r;  i18nr   r   r   r   r    r   r	   r
   r   r   r   r   r   r   r   
interfacesr   interfaceutilrevlogutilsr   r#  	importmodr   r;  r%  r+   r5   r7   rR   rX   rf   r!   rk   lazymanifestAttributeErrorimplementerimanifestdictr   r&  r/   r(  rR  r_  rU  r  r  r%  	Exceptionr  imanifeststorager  imanifestlogr1  imanifestrevisionwritabler  imanifestrevisionstoredr  r  r  r  r  r  rA   r   r*   <module>r'     s        

 
 
 &

9
%""  $ 6
 ." "J )q qh		((M
 :334g$ g$ 5g$T(V!, 	 :334h	 h	 5h	VzD-- z~ F9 F :667p$ p$ 8p$f :223_N _N 4_ND :??@
 
 A
: :==>L% L% ?L%^ :??@
 
 A
D :==>x% x% ?x%v, :
_ 
*(^ (_:  		s   H< <II