
    dg                     $   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ZddlmZ ddl	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mZmZmZmZmZmZmZ ddlmZ ddlm Z m!Z!m"Z"m#Z# dd	l$m%Z% d
 Z& G d de
          Z' G d de'          Z( G d de'          Z) G d de'          Z* G d de
          Z+ G d de
          Z, G d de
          Z- G d de
          Z. G d de
          Z/ G d de
          Z0 G d d e
          Z1 G d! d"e
          Z2dS )#zTests for the index.    N)BytesIO)TestCaseskipIf   )Index
IndexEntry_fs_to_tree_path_tree_to_fs_pathbuild_index_from_treecleanup_modecommit_treeget_unstaged_changesindex_entry_from_stat
read_indexread_index_dictvalidate_path_element_defaultvalidate_path_element_ntfswrite_cache_timewrite_indexwrite_index_dict)MemoryObjectStore)S_IFGITLINKBlobCommitTree)Repoc                      t           j        dk    rdS t          j                    } | dz   }	 t	          j        | |           n# t          t          f$ r Y dS w xY wdS )z3Return whether running process can create symlinks.win32Tcan_symlinkF)sysplatformtempfilemkdtempossymlinkNotImplementedErrorOSError)test_sourcetest_targets     \/home/feoh/.local/pipx/venvs/poetry/lib/python3.11/site-packages/dulwich/tests/test_index.pyr   r   .   sr    
|wt"$$K-K

;,,,,)   uu4s   A AAc                   z    e Zd Zej                            ej                            e          d          Zd Z	dS )IndexTestCasez../../testdata/indexesc                 f    t          t          j                            | j        |                    S N)r   r$   pathjoindatadir)selfnames     r*   get_simple_indexzIndexTestCase.get_simple_indexA   s"    RW\\$,55666    N)
__name__
__module____qualname__r$   r/   r0   dirname__file__r1   r4    r5   r*   r,   r,   =   sG        gll27??8446NOOG7 7 7 7 7r5   r,   c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )SimpleIndexTestCasec                 r    |                      dt          |                     d                               d S )N   index)assertEquallenr4   r2   s    r*   test_lenzSimpleIndexTestCase.test_lenF   s4    C 5 5g > >??@@@@@r5   c                 t    |                      dgt          |                     d                               d S )N   blar@   )rA   listr4   rC   s    r*   	test_iterzSimpleIndexTestCase.test_iterI   s6    &4(=(=g(F(F#G#GHHHHHr5   c                     |                      dgt          |                     d                                                               d S )N)rF   (   e69de29bb2d1d6434b8b29ae775ad8c2e48c5391餁  r@   )rA   rG   r4   iterobjectsrC   s    r*   test_iterobjectsz$SimpleIndexTestCase.test_iterobjectsL   sO    IJ&&w//;;==>>	
 	
 	
 	
 	
r5   c                 d    |                      d|                     d          d                    d S )N)iZIr   rO     |c9 rK     rR   r   rJ   r   r   r@   rF   )rA   r4   rC   s    r*   test_getitemz SimpleIndexTestCase.test_getitemR   sA     !!'**62	
 	
 	
 	
 	
r5   c                     |                      d          }|                     dt          |                     |                     t          j                            |j                             d S )N
notanindexr   )r4   rA   rB   assertFalser$   r/   exists	_filename)r2   is     r*   
test_emptyzSimpleIndexTestCase.test_emptyd   s[    !!,//CFF###4455555r5   c                 V   |                      d          }t          |                    t                      d                     }|                     dt          |                     |d         \  \  }}\  }}\  }}|                     d|           |                     d|           d S )Nr@   r?   r   rF   rJ   )r4   rG   changes_from_treer   rA   rB   )	r2   rY   changesoldnamenewnameoldmodenewmodeoldshanewshas	            r*   test_against_empty_treez+SimpleIndexTestCase.test_against_empty_treei   s    !!'**q**+<+>+>EEFFCLL)))CJ1:@'.Wg0@)))DfMMMMMr5   N)	r6   r7   r8   rD   rH   rM   rS   rZ   rd   r;   r5   r*   r=   r=   E   sy        A A AI I I
 
 

 
 
$6 6 6
N N N N Nr5   r=   c                        e Zd Zd Zd Zd ZdS )SimpleIndexWriterTestCasec                 j    t                               |            t          j                    | _        d S r.   r,   setUpr"   r#   tempdirrC   s    r*   ri   zSimpleIndexWriterTestCase.setUps   *    D!!!'))r5   c                 l    t                               |            t          j        | j                   d S r.   r,   tearDownshutilrmtreerj   rC   s    r*   rn   z"SimpleIndexWriterTestCase.tearDownw   .    t$$$dl#####r5   c                    dt          ddddddddddd          fg}t          j                            | j        d	          }t          |d
          5 }t          ||           d d d            n# 1 swxY w Y   t          |d          5 }|                     |t          t          |                               d d d            d S # 1 swxY w Y   d S Ns   barblarO   rP   rQ   rK   rR   r   rJ   ztest-simple-write-indexzwb+rb)
r   r$   r/   r0   rj   openr   rA   rG   r   r2   entriesfilenamexs       r*   test_simple_writez+SimpleIndexWriterTestCase.test_simple_write{   sd    ##? 
" 7<<.GHH(E"" 	$a7###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ (D!! 	;QWd:a==&9&9:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s$   A//A36A3
1CCCNr6   r7   r8   ri   rn   rz   r;   r5   r*   rf   rf   r   sA        * * *$ $ $; ; ; ; ;r5   rf   c                        e Zd Zd Zd Zd ZdS )ReadIndexDictTestsc                 j    t                               |            t          j                    | _        d S r.   rh   rC   s    r*   ri   zReadIndexDictTests.setUp   rk   r5   c                 l    t                               |            t          j        | j                   d S r.   rm   rC   s    r*   rn   zReadIndexDictTests.tearDown   rq   r5   c                    dt          ddddddddddd          i}t          j                            | j        d	          }t          |d
          5 }t          ||           d d d            n# 1 swxY w Y   t          |d          5 }|                     |t          |                     d d d            d S # 1 swxY w Y   d S rs   )	r   r$   r/   r0   rj   ru   r   rA   r   rv   s       r*   rz   z$ReadIndexDictTests.test_simple_write   sV   z; 
 7<<.GHH(E"" 	)aQ(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) (D!! 	:QWoa&8&8999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s$   A..A25A2	$B::B>B>Nr{   r;   r5   r*   r}   r}      sA        * * *$ $ $: : : : :r5   r}   c                   *     e Zd Z fdZd Zd Z xZS )CommitTreeTestsc                 n    t                                                       t                      | _        d S r.   )superri   r   store)r2   	__class__s    r*   ri   zCommitTreeTests.setUp   s%    &((


r5   c                    t                      }d|_        | j                            |           d|j        t
          j        fg}t          | j        |          }|                     |d           |                     t
          j        |j        f| j        |         d                    |                     ||j        ht          | j        j
                                                             d S )N   foorF   s(   1a1e80437220f9312e855c37ac4398b68e5c1d50)r   datar   
add_objectidstatS_IFREGr   rA   set_datakeys)r2   blobblobsrootids       r*   test_single_blobz CommitTreeTests.test_single_blob   s    vv	
d###$'4<01TZ//!LMMM$,0$*V2DV2LMMM&$'*C
0@0E0E0G0G,H,HIIIIIr5   c                    t                      }d|_        | j                            |           d|j        t
          j        fg}t          | j        |          }|                     |d           | j        |         d         d         }|                     |d           |                     t
          j	        |f| j        |         d                    |                     t
          j        |j        f| j        |         d                    |                     |||j        ht          | j        j                                                             d S )Nr   s   bla/bars(   d92b959b216ad0d044671981196781b3258fa537rF   r?   s(   c1a1deb9788150829579a8b4efa6311e7b638650s   bar)r   r   r   r   r   r   r   r   rA   S_IFDIRr   r   r   )r2   r   r   r   dirids        r*   test_nestedzCommitTreeTests.test_nested   s"   vv	
d###dgt|45TZ//!LMMM
6"6*1- KLLL$,.
60B60JKKK$,0$*U2CF2KLLL&%13tz7G7L7L7N7N3O3OPPPPPr5   )r6   r7   r8   ri   r   r   __classcell__)r   s   @r*   r   r      s`        ) ) ) ) )J J JQ Q Q Q Q Q Qr5   r   c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )CleanupModeTestsc                 \    |                      ||d                    ||                     d S )Nz{:o} != {:o})rA   format)r2   expectedgots      r*   assertModeEqualz CleanupModeTests.assertModeEqual   s0    3(=(=h(L(LMMMMMr5   c                 L    |                      dt          d                     d S )NrK   i   r   r   rC   s    r*   	test_filezCleanupModeTests.test_file   &    X|H'='=>>>>>r5   c                     |                      dt          d                     |                      dt          d                     d S )N  iɁ  i  r   rC   s    r*   test_executablez CleanupModeTests.test_executable   sD    X|H'='=>>>X|H'='=>>>>>r5   c                 L    |                      dt          d                     d S )Ni   iɡ  r   rC   s    r*   test_symlinkzCleanupModeTests.test_symlink   r   r5   c                 L    |                      dt          d                     d S )N @  iYA  r   rC   s    r*   test_dirzCleanupModeTests.test_dir   s&    X|G'<'<=====r5   c                 L    |                      dt          d                     d S )Ni   i  r   rC   s    r*   test_submodulezCleanupModeTests.test_submodule   r   r5   N)	r6   r7   r8   r   r   r   r   r   r   r;   r5   r*   r   r      sq        N N N? ? ?? ? ?? ? ?> > >? ? ? ? ?r5   r   c                   &    e Zd Zd Zd Zd Zd ZdS )WriteCacheTimeTestsc                 f    t                      }|                     t          t          |d           d S )Nfoo)r   assertRaises	TypeErrorr   r2   fs     r*   test_write_stringz%WriteCacheTimeTests.test_write_string   s,    II)%5q%@@@@@r5   c                     t                      }t          |d           |                     t          j        ddd          |                                           d S )N駠 >LLr   r   r   rA   structpackgetvaluer   s     r*   test_write_intz"WriteCacheTimeTests.test_write_int   sM    IIF###UFA66

EEEEEr5   c                     t                      }t          |d           |                     t          j        ddd          |                                           d S )N)r      r   r   r   r   r   s     r*   test_write_tuplez$WriteCacheTimeTests.test_write_tuple   sM    IIL)))UFB77FFFFFr5   c                     t                      }t          |d           |                     t          j        ddd          |                                           d S )Ngi  Ar   r   r   r   r   s     r*   test_write_floatz$WriteCacheTimeTests.test_write_float   sN    II,---UFB77FFFFFr5   N)r6   r7   r8   r   r   r   r   r;   r5   r*   r   r      s^        A A AF F F
G G G
G G G G Gr5   r   c                       e Zd Zd Zd ZdS )IndexEntryFromStatTestsc                     t          j        d          }t          |dd          }|                     |t	          dddddddd	ddd                      d S )
N)
iA         rR   rR    0  NdNr   (2222222222222222222222222222222222222222r   r   r   r   r   rR   r   )r$   stat_resultr   rA   r   r2   stentrys      r*   test_simplez#IndexEntryFromStatTests.test_simple   s~    ^
 
 &b)Q77: 	
 	
 	
 	
 	
r5   c                     t          j        t          j        dz   dddddddddf
          }t	          |d	d
t          j        dz             }|                     |t          ddddddddd	d
d                      d S )N  r   r   r   rR   r   r   r   r   r   i  )moder   )r$   r   r   r   r   rA   r   r   s      r*   test_override_modez*IndexEntryFromStatTests.test_override_mode  s    ^u$
 
 &b)QT\E=QRRR: 	
 	
 	
 	
 	
r5   N)r6   r7   r8   r   r   r;   r5   r*   r   r      s3        
 
 
B
 
 
 
 
r5   r   c                       e Zd Zd ZddZd Zd Zd Z e e	e
dd           d	          d
             Z e e             d          d             Zd Zd Zd ZdS )BuildIndexTestsc                     |                      |d         |           |                      |d         |           |                      |d         |           d S )N         )rA   )r2   index_entryr   filesizeshas        r*   assertReasonableIndexEntryz*BuildIndexTests.assertReasonableIndexEntryB  sV    Q...Q222Q-----r5   Fc                     |r*|                      t          j        |          |           d S t          |d          5 }|                      |                                |           d d d            d S # 1 swxY w Y   d S )Nrt   )rA   r$   readlinkru   read)r2   r/   contentsr%   r   s        r*   assertFileContentsz"BuildIndexTests.assertFileContentsG  s     	5R[..99999dD!! 5Q  84445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s   )A33A7:A7c                 F   t          j                    }|                     t          j        |           t          j        |          5 }t                      }|j        	                    |           t          |j        |                                |j        |j                   |                                }|                     t!          |          d           |                     dgt#          j        |j                             d d d            d S # 1 swxY w Y   d S )Nr   .git)r"   r#   
addCleanupro   rp   r   initr   object_storer   r   r/   
index_pathr   
open_indexrA   rB   r$   listdir)r2   repo_dirrepotreer@   s        r*   rZ   zBuildIndexTests.test_emptyN  s6   #%%x000Yx   	>D66D((...!	4??,,d.?  
 OO%%ESZZ+++ fXrz$)'<'<===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s   CDDDc                    t          j                    }|                     t          j        |           t          j        |          5 }t          j        d          }t          j        d          }t                      }t          j        dz  |j        f|d<   t          j        dz  |j        f|d<   |j                            d |||fD                        t          |j        |                                |j        |j                   |                                }|                     t)          |          d           t*          j                            |j        dd	          }|                     t*          j                            |                     t*          j                            |j        d
d          }|                     t*          j                            |                     |                     |d         t          j        dz  d|j                   |                     |d           d d d            d S # 1 swxY w Y   d S )N   file a   dr   s   .git/a   c/ec                     g | ]}|d fS r.   r;   .0os     r*   
<listcomp>z0BuildIndexTests.test_git_dir.<locals>.<listcomp>m      *S*S*SAt9*S*S*Sr5   r?   r   ace)r"   r#   r   ro   rp   r   r   r   from_stringr   r   r   r   r   add_objectsr   r/   r   r   rA   rB   r$   r0   rV   rW   
assertTruer   r   )	r2   r   r   fileafileer   r@   apathepaths	            r*   test_git_dirzBuildIndexTests.test_git_dir`  s4   #%%x000Yx   	1D $Y//E$T**E66D#|e3UX>DO L50%(;DL))*S*SueT>R*S*S*STTT!	4??,,d.?  
 OO%%ESZZ+++ GLLFC88ERW^^E22333 GLLC55EOOBGNN511222++ft|e3Q   ##E4000=	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   G0II	I	c                    t          j                    }|                     t          j        |           t          j        |          5 }t          j        d          }t          j        d          }t          j        d          }t                      }t          j        dz  |j        f|d<   t          j        dz  |j        f|d<   t          j        dz  |j        f|d<   |j                            d ||||fD                        t          |j        |                                |j        |j                   |                                }|                     t)          |          d	           t*          j                            |j        d
          }|                     t*          j                            |                     |                     |d         t          j        dz  d|j                   |                     |d           t*          j                            |j        d          }	|                     t*          j                            |	                     |                     |d         t          j        dz  d|j                   |                     |	d           t*          j                            |j        dd          }
|                     t*          j                            |
                     |                     |d         t          j        dz  d|j                   |                     |
d           |                     g dt7          t+          j        |j                                       |                     dgt7          t+          j        t*          j                            |j        d                                         d d d            d S # 1 swxY w Y   d S )Nr   s   file b   file dr      a   b   c/dc                     g | ]}|d fS r.   r;   r   s     r*   r   z1BuildIndexTests.test_nonempty.<locals>.<listcomp>  s    @@@q!T@@@r5      r      br   d)r   r   r  r   )r"   r#   r   ro   rp   r   r   r   r   r   r   r   r   r   r   r   r/   r   r   rA   rB   r$   r0   r  rW   r   r   sortedr   )r2   r   r   r  filebfiledr   r@   r  bpathdpaths              r*   test_nonemptyzBuildIndexTests.test_nonempty  s   #%%x000Yx   2	VD $Y//E$Y//E$Y//E66D,.9DJ,.9DJ L50%(;DL))@@UE5$$?@@@   "	4??,,d.?  
 OO%%ESZZ+++ GLLC00EOOBGNN511222++dT\E11eh   ##E9555 GLLC00EOOBGNN511222++dT\E11eh   ##E9555 GLLC55EOOBGNN511222++ft|e3Q   ##E9555 444fRZ	=R=R6S6STTTcUF2:bgll49c6R6R+S+S$T$TUUUe2	V 2	V 2	V 2	V 2	V 2	V 2	V 2	V 2	V 2	V 2	V 2	V 2	V 2	V 2	V 2	V 2	V 2	Vs   NO**O.1O.syncNzRequires sync supportc                 j   t          j                    }|                     t          j        |           t          j        |          5 }t          j        d          }t          j
                            |d          }t                      }t          j        dz  |j        f|d<   |j                            d ||fD                        t%          |j
        |                                |j        |j                   t          j                     t          j        |          j        }t%          |j
        |                                |j        |j                   t          j                     |                     |t          j        |          j                   t/          |d          5 }|                    d           d d d            n# 1 swxY w Y   t          j                     t          j        |          j        }t%          |j
        |                                |j        |j                   t          j                     t/          |d          5 }|                     d|                                           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )	Nr   r   r   r	  c                     g | ]}|d fS r.   r;   r   s     r*   r   z2BuildIndexTests.test_norewrite.<locals>.<listcomp>  s    *L*L*LAt9*L*L*Lr5   wbs   test art   )r"   r#   r   ro   rp   r   r   r   r   r$   r/   r0   r   r   r   r   r   r   r   r   r  st_mtimerA   ru   writer   )r2   r   r   r  
filea_pathr   mtimefhs           r*   test_norewritezBuildIndexTests.test_norewrite  s    #%%x000Yx   $	7D$Y//Eh44J66D,.9DJ))*L*Ludm*L*L*LMMM "	4??,,d.?   GIIIGJ''0E "	4??,,d.?   GIIIUBGJ$7$7$@AAA j$'' $2###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $GIIIGJ''0E "	4??,,d.?   GIIIj$'' 72  BGGII6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7G$	7 $	7 $	7 $	7 $	7 $	7 $	7 $	7 $	7 $	7 $	7 $	7 $	7 $	7 $	7 $	7 $	7 $	7s\   E$J(,GJ(G	J(G	BJ()JJ(J	J(J	J((J,/J,Requires symlink supportc                    t          j                    }|                     t          j        |           t          j        |          5 }t          j        d          }t          j        d          }t                      }t          j        dz  |j        f|d<   t          j        |j        f|d<   |j                            d |||fD                        t!          |j        |                                |j        |j                   |                                }t(          j                            |j        dd          }|                     t(          j                            |                     |                     |d         t          j        t2          j        d	k    rd
nd|j                   |                     |dd           d d d            d S # 1 swxY w Y   d S )Nr  r   r   r  r   c                     g | ]}|d fS r.   r;   r   s     r*   r   z0BuildIndexTests.test_symlink.<locals>.<listcomp>  r   r5   r   r   r   r   r?   r  T)r%   )r"   r#   r   ro   rp   r   r   r   r   r   r   r   r   S_IFLNKr   r   r   r/   r   r   r$   r0   r  rW   r   r    r!   r   )r2   r   r   r  r  r   r@   r  s           r*   r   zBuildIndexTests.test_symlink  s   #%%x000Yx   	>D $Y//E$T**E66D L50%(;DL L%(3DL))*S*SueT>R*S*S*STTT!	4??,,d.?  
 OO%%E GLLC55EOOBGNN511222++f\W,,!	   ##E3#===9	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s   FGGGc                 H   t          j                    }t          j        |          }|                     t
          j        |           t          j        |          5 }t          j
        d          }t                      }d                    d          }t          j                            ||          }d                                }t          j                            ||          }	t          j        dz  |j        f||<   t          j        dz  |j        f||<   |j                            d ||fD                        	 t)          |j        |                                |j        |j                   nq# t,          $ rD}
|
j        dk    r.t0          j        dk    r|                     d|
j        z             n Y d }
~
n(d }
~
wt8          $ r |                     d	           Y nw xY w|                                }|                     ||           |                     ||           |                     t          j                             |                     |                     t          j                             |	                     d d d            d S # 1 swxY w Y   d S )
Nr      Àlatin1r   c                     g | ]}|d fS r.   r;   r   s     r*   r   z9BuildIndexTests.test_no_decode_encode.<locals>.<listcomp>  s    *K*K*KAt9*K*K*Kr5   \   darwinzcan not write filename %rz"can not implicitly convert as utf8)!r"   r#   r$   fsencoder   ro   rp   r   r   r   r   r   encoder/   r0   r   r   r   r   r   r   r   r'   errnor    r!   skipTestrx   UnicodeDecodeErrorr   assertInr  rW   )r2   r   repo_dir_bytesr   filer   latin1_namelatin1_path	utf8_name	utf8_pathr   r@   s               r*   test_no_decode_encodez%BuildIndexTests.test_no_decode_encode  s   #%%X..x000Yx   %	7D #F++D66D++h//K',,~{CCKI^Y??I!%!5tw ?D#|e3TW=DO))*K*KtTl*K*K*KLLLD%It00$2CTW       7b==S\X%=%=MM"=
"JKKKK LKKKK & D D D BCCCCCD OO%%EMM+u---MM)U+++OOBGNN;77888OOBGNN955666K%	7 %	7 %	7 %	7 %	7 %	7 %	7 %	7 %	7 %	7 %	7 %	7 %	7 %	7 %	7 %	7 %	7 %	7sJ   C$J3E54J5
G#?:F>9J>"G# J"G##B'JJJc                 4   t          j                    }|                     t          j        |           t          j        |          5 }t          j        d          }t                      }t          j        dz  |j        f|d<   t                      }|j        |_        dx|_        |_        dx|_        |_        dx|_        |_        g |_        d|_        t                      }t.          |j        f|d<   |j                            d	 |fD                        t5          |j        |                                |j        |j                   |                                }|                     t?          |          d
           t@          j        !                    |j        d          }| "                    t@          j        #                    |                     t@          j        !                    |j        d          }	| $                    t@          j        %                    |	                     |                     |d         d         t.                     |                     |d         d         |j                   d d d            d S # 1 swxY w Y   d S )N   file alalalar   r	     Somebody <somebody@example.com>f  r   	   Subcommit   cc                     g | ]}|d fS r.   r;   r   s     r*   r   z6BuildIndexTests.test_git_submodule.<locals>.<listcomp>E      *E*E*EAt9*E*E*Er5   r?   c/ar   r   r   )&r"   r#   r   ro   rp   r   r   r   r   r   r   r   r   r   r   	committerauthorcommit_timeauthor_timecommit_timezoneauthor_timezoneparentsmessager   r   r   r   r/   r   r   rA   rB   r$   r0   rV   rW   r  isdir
r2   r   r   r  subtreer   r   r@   r  cpaths
             r*   test_git_submodulez"BuildIndexTests.test_git_submodule1  s`   #%%x000Yx   #	3D$_55EffG!\E158<GDMAZAF%GGAK!(,11AMAM455A 1AI$AI66D%qt,DJ))*E*Etf*E*E*EFFF!	4??,,d.?  
 OO%%ESZZ+++ GLLE22ERW^^E22333 GLLC00EOOBGMM%00111U4[^[999U4[^QT222G#	3 #	3 #	3 #	3 #	3 #	3 #	3 #	3 #	3 #	3 #	3 #	3 #	3 #	3 #	3 #	3 #	3 #	3s   H8JJJc                    t          j                    }|                     t          j        |           t          j        |          5 }t          j        d          }t                      }t          j        dz  |j        f|d<   t                      }|j        |_        dx|_        |_        dx|_        |_        dx|_        |_        g |_        d|_        t                      }t.          |j        f|d<   t1          j        t0          j                            |d	                     |j                            d
 |fD                        t=          |j        |                                |j        |j                   |                                 }| !                    tE          |          d           t0          j                            |j        d          }| #                    t0          j        $                    |                     t0          j                            |j        d	          }	| %                    t0          j        &                    |	                     | !                    |d         d         t.                     | !                    |d         d         |j                   d d d            d S # 1 swxY w Y   d S )Nr9  r   r	  r:  r;  r   r<  r=  r   c                     g | ]}|d fS r.   r;   r   s     r*   r   z=BuildIndexTests.test_git_submodule_exists.<locals>.<listcomp>n  r?  r5   r?   r@  r   r   )'r"   r#   r   ro   rp   r   r   r   r   r   r   r   r   r   r   rA  rB  rC  rD  rE  rF  rG  rH  r   r$   mkdirr/   r0   r   r   r   r   r   rA   rB   rV   rW   r  rI  rJ  s
             r*   test_git_submodule_existsz)BuildIndexTests.test_git_submodule_existsY  s   #%%x000Yx   $	3D$_55EffG!\E158<GDMAZAF%GGAK!(,11AMAM455A 1AI$AI66D%qt,DJHRW\\(C00111))*E*Etf*E*E*EFFF!	4??,,d.?  
 OO%%ESZZ+++ GLLE22ERW^^E22333 GLLC00EOOBGMM%00111U4[^[999U4[^QT222I$	3 $	3 $	3 $	3 $	3 $	3 $	3 $	3 $	3 $	3 $	3 $	3 $	3 $	3 $	3 $	3 $	3 $	3s   I*J??KK)F)r6   r7   r8   r   r   rZ   r  r  r   getattrr$   r   r   r   r7  rM  rQ  r;   r5   r*   r   r   A  s       . . .
5 5 5 5> > >$!1 !1 !1F5V 5V 5Vn VFD)))+BCC'7 '7 DC'7R V9::> > ;:>B)7 )7 )7V&3 &3 &3P'3 '3 '3 '3 '3r5   r   c                   \    e Zd Zd Zd Zd Z e e             d          d             ZdS )GetUnstagedChangesTestsc                    t          j                    }|                     t          j        |           t          j        |          5 }t          j        	                    |d          }t          |d          5 }|                    d           ddd           n# 1 swxY w Y   t          j        	                    |d          }t          |d          5 }|                    d           ddd           n# 1 swxY w Y   |                    ddg           |                    ddd	           t          |d          5 }|                    d
           ddd           n# 1 swxY w Y   t          j        |d           t          |                                |          }|                     t%          |          dg           ddd           dS # 1 swxY w Y   dS )#Unit test for get_unstaged_changes.foo1r  	   origstuffNfoo2   test status   author <email>   committer <email>rB  rA  s   newstuff)r   r      foo1)r"   r#   r   ro   rp   r   r   r$   r/   r0   ru   r  stage	do_commitutimer   r   rA   rG   )r2   r   r   foo1_fullpathr   foo2_fullpathr]   s          r*   test_get_unstaged_changesz1GetUnstagedChangesTests.test_get_unstaged_changes  s    #%%x000Yx   	7D GLL6::MmT** &a%%%& & & & & & & & & & & & & & & GLL6::MmT** &a%%%& & & & & & & & & & & & & & & JJ'(((NN(.     mT** %a$$$% % % % % % % % % % % % % % % H]F+++*4??+<+<hGGGT']]WI6665	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s   1G9BGB	G"B	#3GC8,G8C<	<G?C<	 AGE$G$E(	(G+E(	,AGGGc                    t          j                    }|                     t          j        |           t          j        |          5 }t          j        	                    |d          }t          |d          5 }|                    d           ddd           n# 1 swxY w Y   |                    dg           |                    ddd           t          j        |           t          |                                |          }|                     t%          |          d	g           ddd           dS # 1 swxY w Y   dS 
rV  rW  r  rX  NrZ  r[  r\  r]  r^  )r"   r#   r   ro   rp   r   r   r$   r/   r0   ru   r  r_  r`  unlinkr   r   rA   rG   r2   r   r   rb  r   r]   s         r*   !test_get_unstaged_deleted_changesz9GetUnstagedChangesTests.test_get_unstaged_deleted_changes  s    #%%x000Yx   	7D GLL6::MmT** &a%%%& & & & & & & & & & & & & & & JJx   NN(.     Im$$$*4??+<+<hGGGT']]WI666%	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s7   1D;9BD;B	D;"B	#BD;;D?D?c                    t          j                    }|                     t          j        |           t          j        |          5 }t          j        	                    |d          }t          |d          5 }|                    d           ddd           n# 1 swxY w Y   |                    dg           |                    ddd           t          j        |           t          j        |           t!          |                                |          }|                     t'          |          d	g           ddd           dS # 1 swxY w Y   dS rf  )r"   r#   r   ro   rp   r   r   r$   r/   r0   ru   r  r_  r`  removerP  r   r   rA   rG   rh  s         r*   7test_get_unstaged_changes_removed_replaced_by_directoryzOGetUnstagedChangesTests.test_get_unstaged_changes_removed_replaced_by_directory  s    #%%x000Yx   	7D GLL6::MmT** &a%%%& & & & & & & & & & & & & & & JJx   NN(.     Im$$$H]###*4??+<+<hGGGT']]WI666'	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s7   1E9BEB	E"B	#BEEEr!  c                    t          j                    }|                     t          j        |           t          j        |          5 }t          j        	                    |d          }t          |d          5 }|                    d           ddd           n# 1 swxY w Y   |                    dg           |                    ddd           t          j        |           t          j        t          j                            |          |           t#          |                                |          }|                     t)          |          d	g           ddd           dS # 1 swxY w Y   dS rf  )r"   r#   r   ro   rp   r   r   r$   r/   r0   ru   r  r_  r`  rk  r%   r9   r   r   rA   rG   rh  s         r*   2test_get_unstaged_changes_removed_replaced_by_linkzJGetUnstagedChangesTests.test_get_unstaged_changes_removed_replaced_by_link  s    #%%x000Yx   	7D GLL6::MmT** &a%%%& & & & & & & & & & & & & & & JJx   NN(.     Im$$$Jrw}55}EEE*4??+<+<hGGGT']]WI666'	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s7   1E-9BE-B	E-"B	#B=E--E14E1N)	r6   r7   r8   rd  ri  rl  r   r   rn  r;   r5   r*   rT  rT    st        7 7 7B7 7 727 7 74 V9::7 7 ;:7 7 7r5   rT  c                       e Zd Zd Zd ZdS )TestValidatePathElementc                    |                      t          d                     |                      t          d                     |                     t          d                     |                     t          d                     |                     t          d                     |                      t          d                     d S NrF   s   .blas   .gits   .giTs   ..s   git~1)r  r   rV   rC   s    r*   test_defaultz$TestValidatePathElement.test_default  s    5f==>>>5g>>???6w??@@@6w??@@@6u==>>>5h??@@@@@r5   c                    |                      t          d                     |                      t          d                     |                     t          d                     |                     t          d                     |                     t          d                     |                     t          d                     d S rr  )r  r   rV   rC   s    r*   	test_ntfsz!TestValidatePathElement.test_ntfs  s    26::;;;27;;<<<3G<<===3G<<===3E::;;;3H==>>>>>r5   N)r6   r7   r8   rs  ru  r;   r5   r*   rp  rp    s5        A A A? ? ? ? ?r5   rp  c                        e Zd Zd Zd Zd ZdS )TestTreeFSPathConversionc           
          d                                 }t          d|          }|                     |t          j        t          j                            ddd                               d S )N   délwíçh/foos   /prefix/pathz/prefix/path
   délwíçhr   )r,  r
   rA   r$   r+  r/   r0   )r2   	tree_pathfs_paths      r*   test_tree_to_fs_pathz-TestTreeFSPathConversion.test_tree_to_fs_path  sf    $++--	"?I>>K^\5IIJJ	
 	
 	
 	
 	
r5   c                     t           j                            t           j                            dd                    }t          |          }|                     |d                                           d S Nrz  r   ry  )r$   r/   r0   r	   rA   r,  r2   r|  r{  s      r*   test_fs_to_tree_path_strz1TestTreeFSPathConversion.test_fs_to_tree_path_str  s[    ',,rw||L%@@AA$W--	$4$;$;$=$=>>>>>r5   c                    t           j                            t          j        t           j                            dd                              }t	          |          }|                     |d                                           d S r  )r$   r/   r0   r+  r	   rA   r,  r  s      r*   test_fs_to_tree_path_bytesz3TestTreeFSPathConversion.test_fs_to_tree_path_bytes  se    ',,r{27<<e+L+LMMNN$W--	$4$;$;$=$=>>>>>r5   N)r6   r7   r8   r}  r  r  r;   r5   r*   rw  rw    sA        
 
 
? ? ?
? ? ? ? ?r5   rw  )3__doc__r$   ro   r   r   r    r"   ior   dulwich.testsr   r   r@   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   objectsr   r   r   r   r   r   r   r,   r=   rf   r}   r   r   r   r   r   rT  rp  rw  r;   r5   r*   <module>r     s  ,   
			    



        * * * * * * * *' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' - , , , , , 5 5 5 5 5 5 5 5 5 5 5 5        7 7 7 7 7H 7 7 7*N *N *N *N *N- *N *N *NZ ;  ;  ;  ;  ;  ;  ;  ;F: : : : : : : :BQ Q Q Q Qh Q Q Q:? ? ? ? ?x ? ? ?*G G G G G( G G G*A
 A
 A
 A
 A
h A
 A
 A
H3 3 3 3 3h 3 3 3D
n7 n7 n7 n7 n7h n7 n7 n7b? ? ? ? ?h ? ? ?$? ? ? ? ?x ? ? ? ? ?r5   