
    Zj                     R   d Z ddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZmZmZmZmZ erddlmZ ddlmZ ddlmZmZmZmZmZmZ ddlmZmZ  ej>                  dg d	      Z d
Z!dZ"dZ#dZ$d Z%d Z&d Z'd Z(d Z)d Z*defdZ+d Z,dBdedee   dee-   fdZ.	 dBdede
e/e f   dee-   ddfdZ0de-de-fdZ1 G d de2      Z3d d!d"eee/e/e-f      de/fd#Z4d d!d$e3de/fd%Z5	 dCd&ee/   d'e	e/gee/e-f   f   d d!d(ee/   deeeee/   ee/   f   eee-   ee-   f   eee/   ee/   f   f      f
d)Z6	 dBd*e/d+e-dee-   fd,Z7	 dDd.Z8d/Z9d0 Z:d1 Z;e:fd2Z<d-e:fd3Z=dEd4Z>dEd5Z?d6 Z@d7 ZAdBd$e3fd8ZBej                  j                  d9      ZEd:e/fd;ZFd< ZGdBd=ZH	 dBd ed!   fd>ZId? ZJdFd@ZKdA ZLy)Gz%Parser for the git index file format.    N)
AnyBinaryIOCallableDictListOptionalTYPE_CHECKINGIterableIteratorTuple)BaseObjectStore)GitFile)BlobS_IFGITLINKS_ISGITLINKTree
hex_to_sha
sha_to_hex)
SHA1Reader
SHA1Writer
IndexEntry)
ctimemtimedevinomodeuidgidsizeshaflagsi 0  i   i @     c                 \    	 | j                  dd      \  }}||fS # t        $ r d| fcY S w xY w)zSplit a /-delimited path into a directory part and a basename.

    Args:
      path: The path to split.
    Returns:
      Tuple with directory name and basename
       /       )rsplit
ValueError)pathdirnamebasenames       lib/third_party/dulwich/index.py	pathsplitr-   T   sD    #"kk$2( ""  T{s    ++c                  P    dj                  | D cg c]  }|s|	 c}      S c c}w )zJoin a /-delimited path.r$   )join)argsps     r,   pathjoinr2   d   s%    99+Aa+,,+s   ##c                 L    t        j                  d| j                  d            S )zRead a cache time.

    Args:
      f: File-like object to read from
    Returns:
      Tuple with seconds and nanoseconds
    >LL   )structunpackread)fs    r,   read_cache_timer:   i   s     ==q	**r&   c                     t        |t              r|df}nTt        |t              r)t        |d      \  }}t        |      t        |dz        f}nt        |t              st        |      | j                  t        j                  dg|        y)zWrite a cache time.

    Args:
      f: File-like object to write to
      t: Time to write (as int, float or tuple with secs and nsecs)
    r   g      ?i ʚ;r4   N)	
isinstanceintfloatdivmodtuple	TypeErrorwriter6   pack)r9   tsecsnsecss       r,   write_cache_timerG   t   sv     !SF	Au	q#uYEJ./05!lGGFKK""#r&   c                    | j                         }t        |       }t        |       }t        j                  d| j	                  d            \  }}}}}}	}
}| j	                  |dz        }| j                         |z
  dz   dz  }| j	                  ||z   | j                         z
         |||||||||	t        |
      |dz  fS )zRead an entry from a cache file.

    Args:
      f: File-like object to read from
    Returns:
      tuple with: device, inode, mode, uid, gid, size, sha, flags
    z>LLLLLL20sH.   i  r5    )tellr:   r6   r7   r8   r   )r9   beginoffsetr   r   r   r   r   r   r   r   r    r!   name	real_sizes                 r,   read_cache_entryrP      s     &&(KAEAE 	mQVVN%;<	6656>#DK'!+r1IFFK)#qvvx/03 r&   c                    | j                         }|\  }}}}}}}	}
}}}t        | |       t        | |       t        |      |dz  z  }| j                  t	        j
                  d|dz  |dz  ||	|
|t        |      |	             | j                  |       | j                         |z
  dz   dz  }| j                  d||z   | j                         z
  z         y)zWrite an index entry to a file.

    Args:
      f: File object
      entry: Entry to write, tuple with:
        (name, ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags)
    rK   s   >LLLLLL20sHl    r5   rJ       N)rL   rG   lenrB   r6   rC   r   )r9   entryrM   rN   r   r   r   r   r   r   r   r   r    r!   rO   s                  r,   write_cache_entryrU      s     &&(KGLDT5%c4c4eQQI)EGG**sO
	
 GGDMK'!+r1IGGEkI-9:;r&   r9   c              #      K   | j                  d      }|dk7  rt        d|z        t        j                  d| j                  d            \  }}|dv sJ t	        |      D ]  }t        |         yw)z4Read an index file, yielding the individual entries.      DIRCzInvalid index file header: %r   >LLr5   )r%   r"   N)r8   AssertionErrorr6   r7   rangerP   )r9   headerversionnum_entriesis        r,   
read_indexr`      sq     VVAYF<vEFF#]]6166%=AWkf;q!!  s   A1A3c                 L    i }t        |       D ]  }t        |dd  ||d   <    |S )zcRead an index file and return it as a dictionary.

    Args:
      f: File object to read from
    r%   Nr   )r`   r   )r9   retxs      r,   read_index_dictrd      s4     C]!"&AaD	 Jr&   entriesr]   c           	          |t         }| j                  d       | j                  t        j                  d|t	        |                   |D ]  }t        | |        y)zWrite an index file.

    Args:
      f: File-like object to write to
      version: Version number to write
      entries: Iterable over the entries to write
    NrX   rY   )DEFAULT_VERSIONrB   r6   rC   rS   rU   )r9   re   r]   rc   s       r,   write_indexrh      sK     !GGGGGFKKW67!Q r&   returnc                     g }t        |      D ]#  }|j                  |ft        ||         z          % t        | ||       y)z:Write an index file based on the contents of a dictionary.r]   N)sortedappendr@   rh   )r9   re   r]   entries_listrN   s        r,   write_index_dictro      sA     LwTGeGDM&::;  <1r&   r   c                     t        j                  |       rt         j                  S t        j                  |       rt         j                  S t        |       rt        S t         j                  dz  }| dz  r|dz  }|S )zCleanup a mode value.

    This will return a mode that can be stored in a tree object.

    Args:
      mode: Mode to clean up.
    Returns:
      mode
    i  @   I   )statS_ISLNKS_IFLNKS_ISDIRS_IFDIRr   r   S_IFREG)r   rb   s     r,   cleanup_modery      sa     ||D||	d	||	T	
,,
Ce|uJr&   c                       e Zd ZdZd Zed        Zd ZddZd Z	de
fd	Zd
edefdZdee   fdZdedefdZdede
fdZdeeeee
f      fdZd Zd Zd Zd Zd Zd Zd ZddZd Zy)IndexzA Git Index file.c                 `    || _         d| _        | j                          | j                          y)zVOpen an index file.

        Args:
          filename: Path to the index file
        N)	_filename_versionclearr8   )selffilenames     r,   __init__zIndex.__init__  s$     "

		r&   c                     | j                   S N)r}   r   s    r,   r)   z
Index.path$  s    ~~r&   c                 N    | j                   j                  d| j                  dS )N())	__class____name__r}   r   s    r,   __repr__zIndex.__repr__(  s    >>22DNNCCr&   ri   Nc                     t        | j                  d      }	 t        |      }t        || j                  | j
                         |j                          y# |j                          w xY w)z(Write current contents of index to disk.wbrk   N)r   r}   r   ro   _bynamer~   close)r   r9   s     r,   rB   zIndex.write+  sG    DNND)	1AQdmmDGGIAGGIs   -A A(c                    t         j                  j                  | j                        syt	        | j                  d      }	 t        |      }t        |      D ]  }t        |dd  | |d   <    |j                  t         j                  j                  | j                        |j                         z
  dz
         |j                          |j                          y# |j                          w xY w)z)Read current contents of index from disk.Nrbr%   r      )osr)   existsr}   r   r   r`   r   r8   getsizerL   	check_shar   )r   r9   rc   s      r,   r8   z
Index.read4  s    ww~~dnn-DNND)	1A]'12/QqT
 # FF277??4>>2QVVX=BCKKMGGIAGGIs   BC C-c                 ,    t        | j                        S )z%Number of entries in this index file.)rS   r   r   s    r,   __len__zIndex.__len__C  s    4<<  r&   rN   c                      | j                   |   S )zRetrieve entry by relative path.

        Returns: tuple with (ctime, mtime, dev, ino, mode, uid, gid, size, sha,
            flags)
        r   r   rN   s     r,   __getitem__zIndex.__getitem__G  s     ||D!!r&   c                 ,    t        | j                        S )z%Iterate over the paths in this index.)iterr   r   s    r,   __iter__zIndex.__iter__O  s    DLL!!r&   r)   c                      | |   j                   S )z6Return the (git object) SHA1 for the object at a path.)r    r   r)   s     r,   get_sha1zIndex.get_sha1S  s    Dz~~r&   c                      | |   j                   S )z4Return the POSIX file mode for the object at a path.r   r   s     r,   get_modezIndex.get_modeW  s    Dzr&   c              #   l   K   | D ]+  }| |   }||j                   t        |j                        f - yw)z=Iterate over path, sha, mode tuples for use with commit_tree.Nr    ry   r   )r   r)   rT   s      r,   iterobjectszIndex.iterobjects[  s3     DJE		<

#;;; s   24c                 V    dd l }|j                  dt               | j                         S )Nr   zUse iterobjects() instead.)warningswarnPendingDeprecationWarningr   )r   r   s     r,   	iterblobszIndex.iterblobsa  s$    24MN!!r&   c                     i | _         y)z$Remove all contents from this index.Nr   r   s    r,   r   zIndex.clearg  s	    r&   c                 r    t        |t              sJ t        |      dk(  sJ t        | | j                  |<   y )N
   )r<   bytesrS   r   r   )r   rN   rc   s      r,   __setitem__zIndex.__setitem__k  s4    $&&&1v||'^Tr&   c                 B    t        |t              sJ | j                  |= y r   )r<   r   r   r   s     r,   __delitem__zIndex.__delitem__q  s    $&&&LLr&   c                 6    | j                   j                         S r   r   itemsr   s    r,   	iteritemszIndex.iteritemsu      ||!!##r&   c                 6    | j                   j                         S r   r   r   s    r,   r   zIndex.itemsx  r   r&   c                 >    |j                         D ]
  \  }}|| |<    y r   )r   )r   re   rN   values       r,   updatezIndex.update{  s    "==?KD%DJ +r&   c              #       K    fd}t         j                  j                         ||||      D ]  \  }}}|||f  yw)a  Find the differences between the contents of this index and a tree.

        Args:
          object_store: Object store to use for retrieving tree contents
          tree: SHA1 of the root tree
          want_unchanged: Whether unchanged files should be reported
        Returns: Iterator over tuples with (oldpath, newpath), (oldmode,
            newmode), (oldsha, newsha)
        c                 P    |    }|j                   t        |j                        fS r   r   )r)   rT   r   s     r,   lookup_entryz-Index.changes_from_tree.<locals>.lookup_entry  s$    JE99l5::666r&   )want_unchangedN)changes_from_treer   keys)r   object_storetreer   r   rN   r   r    s   `       r,   r   zIndex.changes_from_tree  sO     	7 "3LL)"
T4 s##"
s   ?Ac                 6    t        || j                               S )zCreate a new tree from an index.

        Args:
          object_store: Object store to save the tree in
        Returns:
          Root tree SHA
        commit_treer   )r   r   s     r,   commitzIndex.commit  s     <)9)9);<<r&   )ri   NF)r   
__module____qualname____doc__r   propertyr)   r   rB   r8   r=   r   r   r   r   r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   r    r&   r,   r{   r{     s    
  D! !" "* ""(5/ "U u U s <XeE5#,=&>? <",$$$0=r&   r{   r   r   blobsc                     	
 di i

fd|D ]#  \  }}}t        |      \  }} |      }||f||<   % 	 
fd	 	d      S )zCommit a new tree.

    Args:
      object_store: Object store to add trees to
      blobs: Iterable over blob path, sha, mode entries
    Returns:
      SHA1 of the created tree.
    r&   c                     | v r|    S t        |       \  }} |      }t        |t              sJ i }|||<   || <   |S r   )r-   r<   r   )r)   r*   r+   rD   newtreeadd_treetreess        r,   r   zcommit_tree.<locals>.add_tree  sX    5=;%dOW(E***(dr&   c                    t               }|    j                         D ]P  \  }}t        |t              r#t        j
                  } t        | |            }n|\  }}|j                  |||       R j                  |       |j                  S r   )
r   r   r<   dictrs   rw   r2   add
add_objectid)	r)   r   r+   rT   r   r    
build_treer   r   s	         r,   r   zcommit_tree.<locals>.build_tree  s{    v$T{002OHe%&|| $!9:#sHHXtS)  3 	%wwr&   )r-   )r   r   r)   r    r   	tree_pathr+   r   r   r   r   s   `       @@@r,   r   r     s[     "IE	 !c4'o	8	"X !

 c?r&   indexc                 6    t        | |j                               S )zCreate a new tree from an index.

    Args:
      object_store: Object store to save the tree in
      index: Index file
    Note: This function is deprecated, use index.commit() instead.
    Returns: Root tree sha.
    r   )r   r   s     r,   commit_indexr     s     |U%6%6%899r&   namesr   r   c              #   ^  K   t        |       }|Q|j                  |      D ]=  \  }}}	  ||      \  }	}
|j                  |       |s|	|k7  s|
|k7  s1||f||
f||	ff ? |D ]  }	  ||      \  }	}
d|fd|
fd|	ff  y# t        $ r |df|df|dff Y yw xY w# t        $ r Y Fw xY ww)a  Find the differences between the contents of a tree and
    a working copy.

    Args:
      names: Iterable of names in the working copy
      lookup_entry: Function to lookup an entry in the working copy
      object_store: Object store to use for retrieving tree contents
      tree: SHA1 of the root tree, or None for an empty tree
      want_unchanged: Whether unchanged files should be reported
    Returns: Iterator over tuples with (oldpath, newpath), (oldmode, newmode),
        (oldsha, newsha)
    N)setiter_tree_contentsremoveKeyError)r   r   r   r   r   other_namesrN   r   r    	other_sha
other_modes              r,   r   r     s    4 e*K!-!@!@!FT4O*6t*<'J
 ""4(!Y#%5t9K $<$
);c9=MNN "G 	H&24&8#Y
 $<$
!3dI5FGG   @d|dD\C;??@  		sQ   &B-BB-B-'B2B-BB-BB-	B*'B-)B**B-hex_shar!   c                     |t        | j                        }t        | j                  | j                  | j
                  | j                  || j                  | j                  | j                  ||
      S )zCreate a new index entry from a stat value.

    Args:
      stat_val: POSIX stat_result instance
      hex_sha: Hex sha of the object
      flags: Index flags
    )
ry   st_moder   st_ctimest_mtimest_devst_inost_uidst_gidst_size)stat_valr   r!   r   s       r,   index_entry_from_statr     sf     |H,,- r&   Tc                    	 t        j                  |      }| j                         }t	        j
                  |      rc|rt        j                  |       t        j                  dk(  r"|j                  |      }|j                  |      }t        j                  ||       n|L|j                  t        |      k(  r4t        |d      5 }|j                         |k(  r|cddd       S 	 ddd       t        |d      5 }|j                  |       ddd       |rt        j                   ||       t        j                  |      S # t        $ r d}Y 7w xY w# 1 sw Y   nxY w# 1 sw Y   TxY w)aS  Build a file or symlink on disk based on a Git object.

    Args:
      obj: The git object
      mode: File mode
      target_path: Path to write to
      honor_filemode: An optional flag to honor core.filemode setting in
        config file, default is core.filemode=True, change executable bit
    Returns: stat object for the file
    Nwin32r   r   )r   lstatFileNotFoundErroras_raw_stringrs   rt   unlinksysplatformdecodesymlinkr   rS   openr8   rB   chmod)blobr   target_pathhonor_filemodetree_encodingoldstatcontentsr9   s           r,   build_file_from_blobr  '  s#   ((;' !!#H||DIIk"<<7"}5H%,,];K


8[)7??c(m#Ck4(A668x'" )(' ) +t$GGH % HH[$'88K  3   )( %$s)   E  E9E EEEE')   .git   .s   ..r&   c                 .    | j                         t        vS r   )lowerINVALID_DOTNAMES)elements    r,   validate_path_element_defaultr  U  s    ==?"222r&   c                 `    | j                  d      j                         }|t        v ry|dk(  ryy)Ns   . Fs   git~1T)rstripr  r  )r  strippeds     r,   validate_path_element_ntfsr  Y  s3    ~~e$**,H##8r&   c                 H    | j                  d      }|D ]  } ||      r y y)z2Default path validator that just checks for .git/.r$   FT)split)r)   element_validatorpartsr1   s       r,   validate_pathr  b  s*    JJtE #  r&   c                 p   t        |      }t        | t              st        j                  |       } |j                  |      D ]  }t        |j                  |      st        | |j                        }t        j                  j                  t        j                  j                  |            s2t        j                  t        j                  j                  |             t        |j                        rJt        j                  j                  |      st        j                  |       t        j                   |      }	n(||j"                     }
t%        |
|j                  ||      }	|rt        |j                        r|j                  |	j&                  |	j(                  |	j*                  |	j,                  |	j.                  |	j0                  |	j2                  |	j4                  |	j6                  f
}|	j9                  |      }	t;        |	|j"                  d      ||j                  <    |j=                          y)a  Generate and materialize index from a tree

    Args:
      tree_id: Tree to materialize
      root_path: Target dir for materialized index files
      index_path: Target path for generated index
      object_store: Non-empty object store holding tree contents
      honor_filemode: An optional flag to honor core.filemode setting in
        config file, default is core.filemode=True, change executable bit
      validate_path_element: Function to validate path elements to check
        out; default just refuses .git and .. directories.

    Note: existing index is wiped and contents are not merged
        in a working dir. Suitable only for fresh clones.
    )r  r   N)r{   r<   r   r   fsencoder   r  r)   _tree_to_fs_pathr   r*   makedirsr   r   isdirmkdirr   r    r  r   r   st_nlinkr   r   r   st_atimer   r   r   r   rB   )	root_path
index_pathr   tree_idr  validate_path_elementr   rT   	full_pathstobjst_tuples               r,   build_index_from_treer(  l  s   0 *Ei'KK	*	009UZZ)>?$Y

;	ww~~bggooi89KK	23 uzz"77==+#)$B uyy)C%UZZ>B
 UZZ!8
 

								

H h'B1"eiiCejjM :P 
KKMr&   c                    t        | t              sJ t               }t        j                  |      rot
        j                  dk(  r@t        j                  |       } t        j                  |       j                  |      |_        |S t        j                  |       |_        |S t        | d      5 }|j                         |_        ddd       |S # 1 sw Y   |S xY w)Create a blob from a path and a stat object.

    Args:
      fs_path: Full file system path to file
      st: A stat object
    Returns: A `Blob` object
    r   r   N)r<   r   r   rs   rt   r   r   r   fsdecodereadlinkencodedatar   r8   )fs_pathr   r  r  r9   s        r,   blob_from_path_and_moder0    s     gu%%%6D||D<<7"kk'*GG,33MBDI K	 G,DI K '4 ADI !K !Ks   -CCc                 0    t        | |j                  |      S )r*  )r0  r   )r/  r%  r  s      r,   blob_from_path_and_statr2    s     #7BJJFFr&   c                     ddl m} ddlm} t	        | t
              st        j                  |       } 	  ||       }	 |j                         S # |$ r Y yw xY w# t        $ r Y yw xY w)zRead the head commit of a submodule.

    Args:
      path: path to the submodule
    Returns: HEAD sha, None if not a valid head/repository
    r   )NotGitRepository)RepoN)
dulwich.errorsr4  dulwich.repor5  r<   strr   r+  headr   )r)   r4  r5  repos       r,   read_submodule_headr;    sj     0! dC {{4 Dzyy{    s"   A A AA	A#"A#c                     t         j                  j                  t         j                  j                  | d            rt	        |       }|j
                  |k7  ryyy)a  Check if a directory has changed after getting an error.

    When handling an error trying to create a blob from a path, call this
    function. It will check if the path is a directory. If it's a directory
    and a submodule, check the submodule head to see if it's has changed. If
    not, consider the file as changed as Git tracked a file and not a
    directory.

    Return true if the given path should be considered as changed and False
    otherwise or if the path is not a directory.
    r  TF)r   r)   r   r/   r;  r    )r   rT   r9  s      r,   _has_directory_changedr=    sF     
ww~~bggll9g67"9-99
  r&   c              #   8  K   t        |t              st        j                  |      }| j	                         D ]  \  }}t        ||      }	 t        j                  |      }t        j                  |j                        rt        ||      r| Xt        j                  |j                        s t        j                  |j                        st        ||      }|	 |||      }|j                  |j                  k7  s|  y# t         $ r | Y w xY ww)zWalk through an index and check for differences against working tree.

    Args:
      index: index to check
      root_path: path in which to find files
    Returns: iterator over paths with unstaged changes
    N)r<   r   r   r  r   r  r   rs   rv   r   r=  S_ISREGrt   r2  r   r    r   )r   r   filter_blob_callbackr   rT   r$  r%  r  s           r,   get_unstaged_changesrA    s      i'KK	*	!OO-	5$Y	:		 )$B||BJJ'))U;#O<<

+DLL4L*9b9D#/+D)< ww%))#- .  ! 	 O	sI   ADADD>DDD&D DDDDDasciir   c                     t        |t              sJ t        dk7  r|j                  dt              }n|}t        j
                  j                  | |      S )zConvert a git tree path to a file system path.

    Args:
      root_path: Root filesystem path
      tree_path: Git tree path as bytes

    Returns: File system path.
    r$   )r<   r   os_sep_bytesreplacer   r)   r/   )r   r   sep_corrected_paths      r,   r  r  .  sK     i'''t&..t\B&77<<	#566r&   c                     t        | t              st        j                  |       }n| }t        dk7  r|j                  t        d      }|S |}|S )zConvert a file system path to a git tree path.

    Args:
      fs_path: File system path.

    Returns:  Git tree path as bytes
    r$   )r<   r   r   r  rD  rE  )r/  fs_path_bytesr   s      r,   _fs_to_tree_pathrI  ?  sP     gu%G,t!)),=	  "	r&   c                 6   t        | t              sJ t        j                  |       }t	        j
                  |j                        r_t        j                  j                  t        j                  j                  | d            r!t        |       }|yt        ||dt              S yt	        j                  |j                        st	        j                  |j                        r6t        | |      }||j!                  |       t        ||j"                  d      S y)ag  Create an index from a filesystem path.

    This returns an index value for files, symlinks
    and tree references. for directories and
    non-existant files it returns None

    Args:
      path: Path to create an index entry for
      object_store: Optional object store to
        save new blobs in
    Returns: An index entry; None for directories
    r  Nr   r   )r<   r   r   r   rs   rv   r   r)   r   r/   r;  r   r   r?  rt   r2  r   r   )r)   r   r%  r9  r  s        r,   index_entry_from_pathrK  R  s     dE"""	$B||BJJ77>>"'',,tW56&t,D|(T1;GG||BJJ4<<

#;&tR0###D)$R!44r&   c              #      K   | D ]"  }t        ||      }	 t        ||      }||f $ y# t        t        f$ r d}Y w xY ww)zIterate over current versions of index entries on disk.

    Args:
      paths: Paths to iterate over
      root_path: Root path to access from
      store: Optional store to save new blobs in
    Returns: Iterator over path, index_entry
    r   N)r  rK  r   IsADirectoryError)pathsr   r   r)   r1   rT   s         r,   iter_fresh_entriesrP  r  sV      Y-	)!,GE Ek  "#45 	E	s    A+	A?A?Ac              #      K   ddl }|j                  t        d       t        | |d      D ]  }|d   | |d   = |  yw)aR  Iterate over versions of blobs on disk referenced by index.

    Don't use this function; it removes missing entries from index.

    Args:
      index: Index file
      root_path: Root path to access from
      include_deleted: Include deleted entries with sha and
        mode set to None
    Returns: Iterator over path, sha, mode
    r   NzUse iter_fresh_objects instead.T)include_deletedr%   )r   r   r   iter_fresh_objects)r   r   r   rT   s       r,   iter_fresh_blobsrT    sI      MM+-NO#E9dK8eAhK	 Ls   ?Ac              #      K   t        | ||      D ]>  \  }}||s|ddf t        | }||j                  t        |j                        f @ yw)a7  Iterate over versions of objecs on disk referenced by index.

    Args:
      root_path: Root path to access from
      include_deleted: Include deleted entries with sha and
        mode set to None
      object_store: Optional object store to report new items to
    Returns: Iterator over path, sha, mode
    rM  N)rP  r   r    ry   r   )rO  r   rR  r   r)   rT   s         r,   rS  rS    sY      *%Ve=D$&&&E		<

#;;; Ws
   A7Ac                 6    t        | |      D ]
  \  }}|| |<    y)zRefresh the contents of an index.

    This is the equivalent to running 'git commit -a'.

    Args:
      index: Index to update
      root_path: Root filesystem path
    N)rP  )r   r   r)   rT   s       r,   refresh_indexrW    s"     *%;ed <r&   r   r   )Tutf-8)rX  )FN)Mr   collectionsr   rs   r6   r   typingr   r   r   r   r   r   r	   r
   r   r   dulwich.object_storer   dulwich.filer   dulwich.objectsr   r   r   r   r   r   dulwich.packr   r   
namedtupler   FLAG_STAGEMASK
FLAG_VALIDFLAG_EXTENDEDrg   r-   r2   r:   rG   rP   rU   r`   rd   r=   rh   r   ro   ry   objectr{   r   r   r   r   r  r  r  r  r  r(  r0  r2  r;  r=  rA  sepr-  rD  r  rI  rK  rP  rT  rS  rW  r   r&   r,   <module>re     s  * ,  	   
   4    $[##
" 
 # -
+$"%P<>"( "	 8  d3i  (3-  & "	2	2%#$	2 c]	2 
		2s s ,J=F J=Z)#),4U5%;L5M,N)
)X	:0 	: 	:5 	:" /HE?/HE7E%*$556/H $/H 5/	/H 	huox./hsmXc]*+huox./	1/Hf AE%(088 AH(!V / 3 +H  7DN.G02"  " J vv}}W%75 7"&B CG$,->$?(,<&
r&   