
                            S r SSKJr  SSKJrJr  SSKJrJr  SSK	r	SSK
r
SSKJr  SSKrSSKrSSKrSSKrSSKrSSKJrJrJrJr  SSKJr  SS	KJr  SS
KJr  SSKJrJrJ r J!r!J"r"J#r#  SSK$J%r%  SSK&J'r'  SSK(J)r)  SSK*J+r+J,r,  SSK-J.r.  SSK/J0r0J1r1J2r2J3r3J4r4  SSK5J6r6J7r7J8r8J9r9J:r:  SSK;J<r<J=r=  SSK>J?r?  SSK@JArAJBrB  SSKCJDrDJErEJFrFJGrG  SSKHJIrIJJrJ  SSKKJLrLJMrMJNrNJOrOJPrQ  \" SS5      rR " S S\5      rS\T" \R                  SS5      =(       d    \S" 5       rV\T" \R                  SS5      =(       d    \S" 5       rXSrY " S S \Z5      r[ " S! S"\[5      r\S# r]\S$ 5       r^S% r_\Y4S& jr` " S' S(\[5      raS) rbS\V\X4S* jrcS{S, jrPS|S. jrd      S}S/ jreS~S0 jrfSS1 jrgSS-S\XSS2S4S3 jrhSS4 jriS5 rjSS6 jrkSS7 jrl\lrm\Y4S8 jrn\Y4S9 jro\R                  4S: jrp\R                  4S; jrq\R                  4S< jrr\R                  4S= jrs\R                  4S> jrt\R                  4S? jruS@ rvSA rwS+S\R                  SS-S-4SB jrxS+S\R                  \Y4SC jry\R                  4SD jrz\R                  4SE jr{SF r|       SSG jr}SH r~\R                  4SI jrSJ rSSK jr SSL\JSM\\\\4      SN\\\   \4   4SO jjrSS\V\XS-4SP jrSS\V\XSQS-4SR jrSSS jrST rS|SU jrSV rSSW jrSSX jrSSY jrSSZ jrS[ rS\ rS] rSS^ jrS_ rS` rSa r   SSb\GSc\Sd\\\4   Se\\   Sf\Sg\4Sh jjrS\R                  \XSSS-S-S-4Si jrSSj jrSk rSSl jrSm\R                  S-S-4Sn jrSo rS|Sp jrSSq jrSr rSs rSt rSu rSv rSw rSx rSSy jrSz rg)a  Simple wrapper that provides porcelain-like functions on top of Dulwich.

Currently implemented:
 * archive
 * add
 * branch{_create,_delete,_list}
 * check-ignore
 * checkout
 * clone
 * commit
 * commit-tree
 * daemon
 * describe
 * diff-tree
 * fetch
 * init
 * ls-files
 * ls-remote
 * ls-tree
 * pull
 * push
 * rm
 * remote{_add}
 * receive-pack
 * reset
 * rev-list
 * tag{_create,_delete,_list}
 * upload-pack
 * update-server-info
 * status
 * symbolic-ref

These functions are meant to behave similarly to the git subcommands.
Differences in behaviour are considered bugs.

Functions should generally accept both unicode strings and bytestrings
    )
namedtuple)closingcontextmanager)BytesIO	RawIOBaseN)Path)DictOptionalTupleUnion)
tar_stream)get_transport_and_path)StackedConfig)
CHANGE_ADDCHANGE_DELETECHANGE_MODIFYCHANGE_RENAMECHANGE_COPYRENAME_CHANGE_TYPES)SendPackError)can_fast_forward)IgnoreFilterManager)blob_from_path_and_statget_unstaged_changes)tree_lookup_path)CommitTagformat_timezoneparse_timezonepretty_format_tree_entry)parse_commitparse_object	parse_refparse_reftuples
parse_tree)write_pack_indexwrite_pack_objects)write_tree_diff)ProtocolZERO_SHA)ANNOTATED_TAG_SUFFIXLOCAL_BRANCH_PREFIXstrip_peeled_refsRefsContainer)BaseRepoRepo)FileSystemBackendTCPGitServerReceivePackHandlerUploadPackHandlerupdate_server_info	GitStatuszstaged unstaged untrackedc                   4    \ rS rSrSrS	S jrS rS rS rSr	g)

NoneStream   z;Fallback if stdout or stderr are unavailable, does nothing.c                     g N )selfsizes     $lib/third_party/dulwich/porcelain.pyreadNoneStream.read           c                     g r;   r<   )r=   s    r?   readallNoneStream.readall   rB   rC   c                     g r;   r<   r=   bs     r?   readintoNoneStream.readinto   rB   rC   c                     g r;   r<   rH   s     r?   writeNoneStream.write   rB   rC   r<   N))
__name__
__module____qualname____firstlineno____doc__r@   rE   rJ   rM   __static_attributes__r<   rC   r?   r8   r8      s    ErC   r8   bufferutf-8c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )Error   zPorcelain-based error. c                 8   > [         [        U ]  U5        X l        g r;   )superrY   __init__inner)r=   msgr^   	__class__s      r?   r]   Error.__init__   s    eT#C(
rC   r^   r;   )rP   rQ   rR   rS   rT   r]   rU   __classcell__)r`   s   @r?   rY   rY      s    ! rC   rY   c                       \ rS rSrSrSrg)RemoteExists   z&Raised when the remote already exists.r<   NrP   rQ   rR   rS   rT   rU   r<   rC   r?   re   re      s    0rC   re   c                 F    [        U [        5      (       a  U $ [        U 5      $ )zEOpen an argument that can be a repository or a path for a repository.)
isinstancer/   r0   path_or_repos    r?   	open_reporl      s     ,))rC   c              #      #    U v   g7f)zBContext manager that has the same api as closing but does nothing.Nr<   )objs    r?   _noop_context_managerro      s      Is   c                 j    [        U [        5      (       a  [        U 5      $ [        [	        U 5      5      $ )zOpen an argument that can be a repository or a path for a repository.
returns a context manager that will close the repo on exit if the argument
is a path, else does nothing if the argument is a repo.
)ri   r/   ro   r   r0   rj   s    r?   open_repo_closingrq      s,    
 ,))$\224%&&rC   c                    [         R                  S:  a  [        U[        5      (       d  [        R
                  " U5      n[        U [        5      (       d  [        R
                  " U 5      n [        R                  R                  X5      nUR                  S5      (       a  SU< SU < S3n[        U5      e[        R                  R                  S:w  a9  UR                  [        R                  R                  R                  S5      S5      nU$ [         R                  S	:X  a  [        R                  R                  U5      n[        U5      nUR!                  5       n[         R                  S	:X  a  [        R                  R                  U 5      n [        U 5      R!                  5       n  UR#                  U 5      n[         R                  S	:X  aB  [+        U5      R                  [        R                  R                  S5      R                  U5      $ [        U5      $ ! [         aP    UR%                  5       (       a9  UR&                  R!                  5       nXqR(                  -  R#                  U 5      n Ne f = f)
a  Convert a path to a path usable in an index, e.g. bytes and relative to
the repository root.

Args:
  repopath: Repository path, absolute or relative to the cwd
  path: A path, absolute or relative to the cwd
Returns: A path formatted for use in e.g. an index
)      s   ..zPath z not in repo path ()/ascii   /win32)sysversion_infori   bytesosfsencodepathrelpath
startswith
ValueErrorsepreplaceencodeplatformabspathr   resolverelative_to
is_symlinkparentnamestr)repopathr   tree_encodingtreepatherr_msgresolved_pathr   r   s           r?   path_to_tree_pathr      s    & $&&;;t$D(E**{{8,H77??42u%%9=xHGW%%77;;#''(:(:7(CTJH <<7"77??4(DDz
 <<7"wwx0H>))+		#//9G <<7"w<''S9@@OO>!  	   ,,.!II-::8D	s   *H AI64I6c                       \ rS rSrSrSrg)DivergedBranchesi  z8Branches have diverged and fast-forward is not possible.r<   Nrg   r<   rC   r?   r   r     s    BrC   r   c                 f     [        XU5      nU(       d  [        X5      eg! [         a    Sn N!f = f)zCheck if updating to a sha can be done with fast forwarding.

Args:
  repo: Repository object
  current_sha: Current head sha
  new_sha: New head sha
FN)r   KeyErrorr   )repocurrent_shanew_shacans       r?   check_divergedr     s>    t': {44   s   ! 00c                    Uc  Sn[        U 5       n[        XA5      n[        UR                  UR                  UR                     UR
                  5       H  nUR                  U5        M     SSS5        g! , (       d  f       g= f)zCreate an archive.

Args:
  repo: Path of repository for which to generate an archive.
  committish: Commit SHA1 or ref to use
  outstream: Output stream (defaults to stdout)
  errstream: Error stream (defaults to stderr)
NHEAD)rq   r!   r   object_storetreecommit_timerM   )r   
committish	outstream	errstreamrepo_objcchunks          r?   archiver   !  sl     
	4	 H.!!8#8#8#@!--
E OOE"
 
!	 	 s   AA66
B.c                 d    [        U 5       n[        U5        SSS5        g! , (       d  f       g= f)zQUpdate server info files for a repository.

Args:
  repo: path to the repository
N)rq   server_update_server_infor   rs     r?   r5   r5   :  s"     
4	 A!!$ 
!	 	 s   !
/Fc                     [        U 5       n[        U5      nU(       d+  XCR                  R                  5       ;  a  [	        SU-  5      eUR                  R                  SU5        SSS5        g! , (       d  f       g= f)zSet git symbolic ref into HEAD.

Args:
  repo: path to the repository
  ref_name: short name of the new ref
  force: force settings without checking if it exists in refs/heads
zfatal: ref `%s` is not a ref   HEADN)rq   _make_branch_refrefskeysrY   set_symbolic_ref)r   ref_nameforcer   ref_paths        r?   symbolic_refr   D  s^     
4	 H#H-););)==6ABB&&w9	 
!	 	 s   AA//
A=c           	         [        USS5      (       a  UR                  U=(       d    [        5      n[        USS5      (       a  UR                  U=(       d    [        5      n[        USS5      (       a  UR                  U=(       d    [        5      n[        U 5       nUR	                  UUUUUS9sSSS5        $ ! , (       d  f       g= f)a  Create a new commit.

Args:
  repo: Path to repository
  message: Optional commit message
  author: Optional author name and email
  committer: Optional committer name and email
  no_verify: Skip pre-commit and commit-msg hooks
Returns: SHA1 of the new commit
r   N)messageauthor	committerencoding	no_verify)getattrr   DEFAULT_ENCODINGrq   	do_commit)r   r   r   r   r   r   r   s          r?   commitr   S  s    ( w$''..!=-=>vx&&x;+;<y(D))$$X%A1AB		4	 A{{  
 
!	 	 s   B99
Cc                 n    [        U 5       nUR                  X!XCS9sSSS5        $ ! , (       d  f       g= f)zCreate a new commit object.

Args:
  repo: Path to repository
  tree: An existing tree object
  author: Optional author name and email
  committer: Optional committer name and email
)r   r   r   r   N)rq   r   )r   r   r   r   r   r   s         r?   commit_treer   w  s0     
4	 A{{)  
 
!	 	 s   &
4c                     [         R                  R                  U 5      (       d  [         R                  " U 5        U(       a  [        R
                  " U 5      $ [        R                  " U 5      $ )zCreate a new git repository.

Args:
  path: Path to repository.
  bare: Whether to create a bare repository.
Returns: A Repo instance
)r}   r   existsmkdirr0   	init_bareinit)r   bares     r?   r   r     sB     77>>$
~~d##yyrC      originc                    Ub  SSK n	U	R                  S[        SS9  UnUc  U(       + nU(       a  U(       a  [        S5      eUc  U R	                  S5      S   n[
        R                  R                  U5      (       d  [
        R                  " U5        U(       a  [        R                  " U5      n
O[        R                  " U5      n
S	U R                  S
5      -   n U
R                  5       n[        U [        5      (       d  U R                  [         5      n UR#                  SU4SU 5        UR#                  SU4SSU-   S-   5        UR%                  5         ['        U
U4UUUS.UD6nUR(                  R+                  5        H   u  pU
R,                  R/                  X5        M"      XR,                  S      nUR0                  U
S'   U(       aF  U(       d?  Ub<  UR5                  SUR0                  -   S-   5        U
R7                  UR8                  5        U
$ ! [2         a    Sn N]f = f! [:         a(    [<        R>                  " U5        U
RA                  5         e f = f)a  Clone a local or remote git repository.

Args:
  source: Path or URL for source repository
  target: Path to target repository (optional)
  bare: Whether or not to create a bare repository
  checkout: Whether or not to check-out HEAD after cloning
  errstream: Optional stream to write progress to
  outstream: Optional stream to write progress to (deprecated)
  origin: Name of remote from the repository used to clone
  depth: Depth to fetch at
Returns: The new repository
Nr   z7outstream= has been deprecated in favour of errstream=.rs   )
stacklevelz"checkout and bare are incompatiblerv   rO   s   clone: from rW      remote   urls   fetchs   +refs/heads/*:refs/remotes/s   /*)r   r   depthr   s   Checking out    
)!warningswarnDeprecationWarningrY   splitr}   r   r   r   r0   r   r   r   
get_configri   r|   r   setwrite_to_pathfetchsymrefsitemsr   r   idr   rM   reset_indexr   BaseExceptionshutilrmtreeclose)sourcetargetr   checkoutr   r   originr   kwargsr   r   reflog_messagetarget_configfetch_resultkeyheads                   r?   cloner     s&   2 E 	 	

 	8D899~c"2&77>>&!!
NN6"IIf$v}}W'==N!&%((]]#34F9f-vv>*V3e;	

 	##%
  "
 
 (//557KCFF##C0 8	!&&w/0D AgJDT%5OO,tww6>?MM$))$ H  	D	  f		s2   C	H' &H 7AH' H$!H' #H$$H' '2Ic                    [        5       n[        U 5       n[        UR                  5      R	                  5       n[
        R                  " U5      nU(       d`  [        [        [        [        [        R                  " 5       5      R	                  5       5      [        U5      UR                  5       5      5      n/ n[        U[        5      (       d  U/nU Hn  n[        [        U5      R	                  5       R                  U5      5      nUR                  U5      (       a  UR!                  U5        M]  UR#                  U5        Mp     UR%                  U5        SSS5        Xb4$ ! , (       d  f       WU4$ = f)zAdd files to the staging area.

Args:
  repo: Repository for the files
  paths: Paths to add.  No value passed stages all modified files.
Returns: Tuple with set of added files and ignored files
N)r   rq   r   r   r   r   	from_repolistget_untracked_pathsr   r}   getcwd
open_indexri   r   
is_ignoredaddappendstage)	r   pathsignoredr   	repo_pathignore_managerrelpathspr   s	            r?   r   r     s!    eG	4	 AL((*	,66q9#RYY[)1134	NLLNE %&&GEA$q'//+77	BCG((11G$OOG$  	
+ 
!, - 
!	 , gs   E E!!
E2c                    [         R                  R                  U5      [         R                  R                  -   n[         R                  R                  U 5      [         R                  R                  -   nUR	                  U5      $ )zCheck whether subdir is parentdir or a subdir of parentdir

If parentdir or subdir is a relative path, it will be disamgibuated
relative to the pwd.
)r}   r   realpathr   r   )subdir	parentdirparentdir_abs
subdir_abss       r?   
_is_subdirr    sW     GG$$Y/"''++=M!!&)BGGKK7J  //rC   c                 J   Uc  [         R                  " 5       n[        U 5       n[        XR                  5      (       d  [        S5      eUR                  5       nUR                  SSS5      nUR                  5       n[        R                  " U5      n[        XR                  5      n[        [        U5      5       H  u  pU	(       aC  [        [         R                  " U5      5      S:H  n
U
(       a  [         R                   " U5        MM  MO  [#        UR                  U5      nX;   n[         R                  R%                  XR                  5      nUR'                  U5      nU(       a  M  U(       a  M  [         R(                  " U5        M     SSS5        g! , (       d  f       g= f)zRemove any untracked files from the target directory recursively

Equivalent to running `git clean -fd` in target_dir.

Args:
  repo: Repository where the files may be tracked
  target_dir: Directory to clean - current directory if None
Nz,target_dir must be in the repo's working dir)s   cleans   requireForceTr   )r}   r   rq   r  r   rY   get_config_stackget_booleanr   r   r   _walk_working_dir_pathsreversedr   lenlistdirrmdirr   r   r   remove)r   
target_dirr   configrequire_forceindexr   paths_in_wdapis_diris_emptyip
is_trackedrpr   s                  r?   cleanr    s0    YY[
	4	 A*ff--FGG##%**$
 ,66q9-j&&A #4#45JB rzz"~.!3HHRL  'qvvr2[
WW__R0+66r:
!z**IIbM 6% 
!	 	 s   E F(F1F
F"c                 J   [        U 5       nUR                  5       nU GH	  n[        R                  " [        R                  R                  U5      5      n[        UR                  U5      n XG   R                  nU(       d   [        R                  " U5      n	 [        Xi5      n
 [        UR                  X3R                  5          R                  U5      S   nU
R                   U:w  a  X:w  a  [        SU-  5      eX:w  a  [        SU-  5      e[        R"                  " U5        XG	 GM     UR)                  5         SSS5        g! [         a    [        SU-  5      ef = f! [         a    Sn Nf = f! [$         a     NZf = f! [&         a     Njf = f! , (       d  f       g= f)zeRemove files from the staging area.

Args:
  repo: Repository for the files
  paths: Paths to remove
z%s did not match any files   NzAfile has staged content differing from both the file and head: %szfile has staged changes: %s)rq   r   r}   r~   r   r   r   shar   rY   lstatr   r   __getitem__r   r   r   r  IOErrorOSErrorrM   )r   r   cachedr   r  r   	full_path	tree_path	index_shastblobcommitted_shas               r?   r  r  O  s    
4	 AABGGOOA$67I)!&&!4I>!,00	 -),B-6yE1,< !q{/?/?--!M  77i/I4N"'!BDE!F# 
 %5"'(E(I"JJ		), G H 	M 
!	   >81<==>$  ( 1,0M1 #    
!	 s   A F-E;FFE4&4E"A#FEF"E1.F0E11F4
F>F FF
FFFF
F"c                     U R                   (       a  U R                   R                  S5      nOUnUR                  US5      $ )Nrw   r   )r   decoder   contentsdefault_encodingr   s       r?   commit_decoder+    s3    ??))'2#??8Y//rC   c                     U R                   (       a  U R                   R                  S5      nOUnUR                  U5      $ )Nrw   )r   r'  r   r(  s       r?   commit_encoder-    s1    ??))'2#??8$$rC   c                    UR                  S5        UR                  SU R                  R                  S5      -   S-   5        [        U R                  5      S:  aR  UR                  SSR                  U R                  SS  Vs/ s H  o3R                  S5      PM     sn5      -   S-   5        UR                  S	U" U R                  5      -   S-   5        U R                  U R                  :w  a'  UR                  S
U" U R                  5      -   S-   5        [        R                  " U R                  U R                  -   5      n[        R                  " SU5      n[        U R                  5      R                  S5      nUR                  SU-   S-   U-   S-   5        UR                  S5        UR                  U" U R                  5      S-   5        UR                  S5        gs  snf )zsWrite a human-readable commit log entry.

Args:
  commit: A `Commit` object
  outstream: A stream file to write to
z3--------------------------------------------------
zcommit: rw   
r  zmerge: z...NzAuthor: zCommitter: %a %b %d %Y %H:%M:%SDate:    )rM   r   r'  r  parentsjoinr   r   timegmtimeauthor_timeauthor_timezonestrftimer   r   )r   r'  r   r   
time_tupletime_strtimezone_strs          r?   print_commitr=    s    OOO$OOJ!1!1'!::TAB
6>>QjjV^^AB5GH5G((7+5GHIJ	

 OOJ!66=>}}(((v/?/?(@@4GHV//&2H2HHIJ}}3Z@H"6#9#9:AA'JLOOJ)C/,>EFOODOOF6>>*T12OOD Is   G!c                    UR                  SU" U R                  5      -   S-   5        [        R                  " U R                  U R
                  -   5      n[        R                  " SU5      n[        U R
                  5      R                  S5      nUR                  SU-   S-   U-   S-   5        UR                  S5        UR                  U" U R                  5      S-   5        UR                  S5        g)zWrite a human-readable tag.

Args:
  tag: A `Tag` object
  decode: Function for decoding bytes to unicode string
  outstream: A stream to write to
zTagger: r/  r0  rw   r1  r2  N)
rM   taggerr5  r6  tag_timetag_timezoner9  r   r'  r   )tagr'  r   r:  r;  r<  s         r?   	print_tagrC    s     OOJ

!33d:;S\\C,<,<<=J}}3Z@H"3#3#34;;GDLOOJ)C/,>EFOODOOF3;;'$./OODrC   c                 F    UR                  U" UR                  5      5        g)zWrite a blob to a stream.

Args:
  repo: A `Repo` object
  blob: A `Blob` object
  decode: Function for decoding bytes to unicode string
  outstream: A stream file to write to
N)rM   data)r   r$  r'  r   s       r?   	show_blobrF    s     OOF499%&rC   c                 @   [        XUS9  UR                  (       a  XR                  S      nUR                  nOSn[        5       n[	        X`R
                  XQR                  5        UR                  S5        UR                  [        XR                  5       5      5        g)zShow a commit to a stream.

Args:
  repo: A `Repo` object
  commit: A `Commit` object
  decode: Function for decoding bytes to unicode string
  outstream: Stream to write to
)r'  r   r   N)
r=  r3  r   r   r(   r   seekrM   r+  getvalue)r   r   r'  r   parent_commit	base_tree
diffstreams          r?   show_commitrM    sw     )<~~^^A./!&&		JJ 1 19kkJOOAOOM&*=*=*?@ArC   c                 J    U H  nUR                  U" U5      S-   5        M     g)zPrint a tree to a stream.

Args:
  repo: A `Repo` object
  tree: A `Tree` object
  decode: Function for decoding bytes to unicode string
  outstream: Stream to write to
r/  N)rM   )r   r   r'  r   ns        r?   	show_treerP    s#     q	D() rC   c                 T    [        XU5        [        X UR                  S      X#5        g)zPrint a tag to a stream.

Args:
  repo: A `Repo` object
  tag: A `Tag` object
  decode: Function for decoding bytes to unicode string
  outstream: Stream to write to
r  N)rC  show_objectobject)r   rB  r'  r   s       r?   show_tagrT    s%     c9%3::a=)6=rC   c                 X    [         [        [        [        S.UR                     " XX#5      $ )N)s   trees   blobs   commits   tag)rP  rF  rM  rT  	type_name)r   rn   r'  r   s       r?   rR  rR    s2    	
 
mm
 3 3rC   c              #   |  #    U  GH1  nU(       d  M  [        U[        5      (       a  US   nUR                  [        :X  a  UR                  R
                  nSnSnOUR                  [        :X  a  UR                  R
                  nSnSnOUR                  [        :X  a  UR                  R
                  nSnSnOmUR                  [        ;   aY  UR                  R
                  nUR                  R
                  nUR                  [        :X  a  SnOUR                  [        :X  a  SnW<S W<S	 W<S	 3v   GM4     g
7f)z5Print a simple status summary, listing changed files.r    ADMRC820N)ri   r   typer   newr   r   oldr   r   r   r   )changeschangepath1path2kinds        r?   print_name_statusrh    s     fd##AYF;;*$JJOOEED[[M)JJOOEED[[M)JJOOEED[[//JJOOEJJOOE{{m++"&u551 s   D:D<c           	      L  ^
 [        U 5       nUR                  X1US9nU Hc  m
U
4S jn[        T
R                  X5        U(       d  M(  UR	                  [        T
R                  5       5       V	s/ s H  oS-   PM	     sn	5        Me     SSS5        gs  sn	f ! , (       d  f       g= f)a1  Write commit logs.

Args:
  repo: Path to repository
  paths: Optional set of specific paths to print entries for
  outstream: Stream to write log output to
  reverse: Reverse order in which entries are printed
  name_status: Print name status
  max_entries: Optional maximum number of entries to display
)max_entriesr   reversec                 0   > [        TR                  U 5      $ r;   )r+  r   )xentrys    r?   r'  log.<locals>.decode7  s    $U\\155rC   r/  N)rq   
get_walkerr=  r   
writelinesrh  rc  )r   r   r   rj  rk  name_statusr   walkerr'  linern  s             @r?   logru  !  s    $ 
4	 A+GTE6 v9{$$->u}}-OP-OTD[-OP  
!	  Q 
!	 s#   7B&B.B<BB
B#c                   ^^ Uc  S/n[        U[        5      (       d  U/n[        U 5       nU H>  n[        XE5      m[        T[        5      (       a  UU4S jnOU4S jn[        UTXb5        M@     SSS5        g! , (       d  f       g= f)zPrint the changes in a commit.

Args:
  repo: Path to repository
  objects: Objects to show (defaults to [HEAD])
  outstream: Stream to write to
  default_encoding: Default encoding to use if none is set in the
    commit
Nr   c                    > [        TU T5      $ r;   )r+  )rm  r*  os    r?   r'  show.<locals>.decodeZ  s    (A/?@@rC   c                 &   > U R                  T5      $ r;   )r'  )rm  r*  s    r?   r'  ry  _  s    88$455rC   )ri   r   rq   r"   r   rR  )r   objectsr   r*  r   	objectishr'  rx  s      `   @r?   showr}  B  su     (gt$$)	4	 A IQ*A!V$$A
6 1f0 ! 
!	 	 s   AA::
Bc                 z    [        U 5       n[        X4R                  X5        SSS5        g! , (       d  f       g= f)zCompares the content and mode of blobs found via two tree objects.

Args:
  repo: Path to repository
  old_tree: Id of old tree
  new_tree: Id of new tree
  outstream: Stream to write to
N)rq   r(   r   )r   old_treenew_treer   r   s        r?   	diff_treer  e  s(     
4	 A	>>8F 
!	 	 s   ,
:c                    [        U 5       nUR                  U Vs/ s H  oCU   R                  PM     snS9 H+  nUR                  UR                  R                  S-   5        M-     SSS5        gs  snf ! , (       d  f       g= f)zLists commit objects in reverse chronological order.

Args:
  repo: Path to repository
  commits: Commits over which to iterate
  outstream: Stream to write to
)includer   N)rq   rp  r   rM   r   )r   commitsr   r   r   rn  s         r?   rev_listr  r  sf     
4	 A\\G*DGqQ477G*D\EEOOELLOOe34 F 
!	 *D 
!	 s   A6A1
4A61A66
Bc                  L    SS K nUR                  S[        5        [        U 0 UD6$ )Nr   z0tag has been deprecated in favour of tag_create.)r   r   r   
tag_createargsr   r   s      r?   rB  rB    s)    MM:<N t&v&&rC   c	                    [        U 5       n	[        X5      n
U(       Ga  [        5       nUc  U	R                  U	R	                  5       5      nX+l        X;l        Xl        [        U
5      U
R                  4Ul
        Uc  [        [        R                  " 5       5      nXkl        Uc  SnO [        U[        5      (       a  [!        U5      nX{l        U(       aC  SSKnUR'                  SS9 nUR)                  UR+                  5       5      u  Ul        nSSS5        U	R.                  R1                  U5        UR                  nOU
R                  nXR2                  [5        U5      '   SSS5        g! , (       d  f       Nb= f! , (       d  f       g= f)a  Creates a tag in git via dulwich calls:

Args:
  repo: Path to repository
  tag: tag string
  author: tag author (optional, if annotated is set)
  message: tag message (optional)
  annotated: whether to create an annotated tag
  objectish: object the tag should point at, defaults to HEAD
  tag_time: Optional time for annotated tag
  tag_timezone: Optional timezone for annotated tag
  sign: GPG Sign the tag
Nr   T)armor)rq   r"   r   _get_user_identityr  r?  r   r   r`  r   rS  intr5  r@  ri   r   r   rA  gpgContextsignas_raw_string	signaturer   
add_objectr   _make_tag_ref)r   rB  r   r   	annotatedr|  r@  rA  r  r   rS  tag_objr  r   unused_resulttag_ids                   r?   r  r    s1   2 
4	 Aa+eG~--a.@.@.BC#N%OL"6lFII6GNtyy{+'# L#..-l;#/ [[t[,78vvg>S>S>U7V4G%} -NN%%g.ZZFYYF%+}S!"A 
!	 2 -,3 
!	 s%   CE<'(E+AE<+
E9	5E<<
F
c                  L    SS K nUR                  S[        5        [        U 0 UD6$ )Nr   z4list_tags has been deprecated in favour of tag_list.)r   r   r   tag_listr  s      r?   	list_tagsr    s)    MM> T$V$$rC   c                     [        U 5       n[        UR                  R                  S5      5      nUsSSS5        $ ! , (       d  f       g= f)zVList all tags.

Args:
  repo: Path to repository
  outstream: Stream to write tags to
	   refs/tagsN)rq   sortedr   as_dict)r   r   r   tagss       r?   r  r    s4     
4	 Aaffnn\23 
!	 	 s	   &<
A
c                 
   [        U 5       n[        U[        5      (       a  U/nO&[        U[        5      (       a  UnO[	        SU-  5      eU H  nUR
                  [        U5      	 M     SSS5        g! , (       d  f       g= f)zNRemove a tag.

Args:
  repo: Path to repository
  name: Name of tag to remove
zUnexpected tag name type %rN)rq   ri   r|   r   rY   r   r  r   r   r   namess       r?   
tag_deleter    sl     
4	 AdE""FEd##E5<==D}T*+  
!	 	 s   AA44
Bc                     US:w  a  [        S5      e[        U 5       n[        X25      nUR                  UR                  5        SSS5        g! , (       d  f       g= f)zReset current HEAD to the specified state.

Args:
  repo: Path to repository
  mode: Mode ("hard", "soft", "mixed")
  treeish: Treeish to reset to
hardz)hard is the only mode currently supportedN)rY   rq   r%   r   r   )r   modetreeishr   r   s        r?   resetr    sG     v~?@@	4	 A!%	dgg 
!	 	 s   'A
Ar   remote_locationreturnc                 6   U R                  5       nUc  [        U 5      n[        U[        5      (       a  UR	                  5       nOUnSU4nS nUR                  U5      (       a%  UR                  5       nUR                  US5      nUnOS nXSR                  5       4$ )Nr   url)r   get_branch_remoteri   r   r   has_sectionr'  get)r   r  r  encoded_locationsectionremote_namer  s          r?   get_remote_repor    s     __F+D1/3''*113**+GK'""&--/jj%(00233rC   c           	      `  ^^^^^ [        U 5       mTc  [        T5      /m[        TU5      u  pq[        U4STR	                  5       0UD6u  p/ m0 mUUUUU4S jn
[        USS5      =(       d    [        nUR                  U	5      n UR                  U	U
TR                  UR                  S9nUR                  SUR                  U5      -   S-   5        UR                   =(       d    0 R#                  5        HB  u  pUb&  UR                  SXR                  U5      4-  5        M.  UR                  SU-  5        MD     Ub  [%        TR&                  UT5        SSS5        g! [         a3  n[        SU-   S	-   UR                  S
   R                  5       -   US9eSnAff = f! , (       d  f       g= f)a  Remote push with dulwich via dulwich.client

Args:
  repo: Path to repository
  remote_location: Location of the remote
  refspecs: Refs to push to remote
  outstream: A stream file to write output
  errstream: A stream file to write errors
  force: Force overwriting refs
Nr  c           	      2  > T
R                  [        TR                  U TTS95        0 nT
 HL  u  p#nUc  [        X'   S T	U'   M   TR                  U   nU(       d  X0;   a  [        TX   U5        XQU'   UT	U'   MN     U$ ! [         a    [        SU-  5      ef = f)Nr   z#No valid ref %s in local repository)extendr$   r   r*   r   rY   r   )r   new_refslhrh	force_reflocalshar   r   refspecsremote_changed_refsselected_refss         r?   update_refspush.<locals>.update_refs8  s      xu!UVH'4#:#+HL.2'+P#$66": %&q$(H=#+RL.6'+ (5 O $ P#$IB$NOOPs   A==Br   )generate_pack_dataprogresss   Push to s    successful.
zPush to z failed -> r   rb   s   Push of ref %s failed: %s
s   Ref %s updated
)rq   active_branchr  r   r  r   r   get_url	send_packr  rM   r   r   rY   r  r'  
ref_statusr   _import_remote_refsr   )r   r  r  r   r   r   r   r  clientr   r  err_encodingresultereferrorr   r  r  s     `  `          @@@r?   pushr    s   * 
4	 A%a()H)8O)L& .
$%$6$6$8
<B
  	 	& y*d;O?O ...	%%#$#7#7"	 & F OOo44\BBEVV ",,299;JC 2c<<;U5VV  3c 9: < "5HIy 
!	 R  	_,}<qvvay?O?O?QQ 	S 
!	 s1   A5F&E-B)F
F).FFF
F-Tc                   ^^^^ [        U 5       m[        TU5      u  pTc  S/m/ mUUUU4S jn	[        U4STR                  5       0UD6u  pU
R	                  UTUR
                  U	S9nT HJ  u  pn [        TTR                  U   UR                  U   5        UR                  U   TR                  U'   ML     T(       a  UR                  TS   S      TS'   TS   R                  nTR                  US	9  Ub   [        TR                  XR                  5        SSS5        g! [         a    U(       a  e [        S5      ef = f! , (       d  f       g= f)
zPull from remote via dulwich.client

Args:
  repo: Path to repository
  remote_location: Location of the remote
  refspec: refspecs to fetch
  outstream: A stream file to write to output
  errstream: A stream file to write to errors
Nr   c           	         > TR                  [        U TR                  TTS95        T VVVs/ s H  u  pnX   TR                  ;  d  M  X   PM      snnn$ s  snnnf )Nr  )r  r$   r   r   )remote_refsr  r  r  r   r   r  r  s       r?   determine_wantspull.<locals>.determine_wants  sa      QVVXUK
 ,9+8'RY?!..8  +8  s   A
Ar  )r  r  zmerge is not yet supportedr   r  )r   )rq   r  r   r  r   rM   r   r   r   NotImplementedErrorr   r   r  )r   r  r  r   r   fast_forwardr   r   r  r  r  r   r   r  r  r  r   r   r  s     `   `          @@r?   pullr  j  sg   ( 
4	 A)8O)L&yH	 	 .
$%$6$6$8
<B
 ||!ioo $ 
 $1RYLq!&&*l.?.?.CD &**2.AFF2J $1 %**=+;A+>?AgJ z	4 "5F5FGO 
!	 4 $ L-.JKK	L5 
!	 s%   A"E3'D#B E#EE
Ec                 p   [        U 5       n[        U5      nUR                  5       nUR                  5       nUR                  n[        [        XBR                  U5      5      n[        UR                  UR                  XA(       + S9n[        U5      n	[        X7U	5      sSSS5        $ ! , (       d  f       g= f)a  Returns staged, unstaged, and untracked changes relative to the HEAD.

Args:
  repo: Path to repository or repository object
  ignored: Whether to include ignored files in `untracked`
Returns: GitStatus tuple,
    staged -  dict with lists of staged paths (diff index/HEAD)
    unstaged -  list of unstaged paths (diff index/working-tree)
    untracked - list of untracked, un-ignored & non-.git paths
)exclude_ignoredN)
rq   get_tree_changesr   get_blob_normalizercheckin_normalizer   r   r   r   r6   )
r   r   r   tracked_changesr  
normalizerfilter_callbackunstaged_changesuntracked_pathsuntracked_changess
             r?   statusr    s     
4	 A*1-**,
$66 4UFFO TU-FFAFFE;
 !1<MN 
!	 	 s   BB''
B5c              #   6  #    [         R                  " U 5       H{  u  p#nSU;   a  UR                  S5        X!:w  a  M$  SU;   a  UR                  S5        X!:w  a  MB  X :w  a  US4v   U H(  n[         R                  R	                  X%5      nUS4v   M*     M}     g7f)z}Get path, is_dir for files in working dir from frompath

Args:
  frompath: Path to begin walk
  basepath: Path to compare to
z.gitTFN)r}   walkr  r   r4  )frompathbasepathdirpathdirnames	filenamesfilenamefilepaths          r?   r  r    s      )+(9$9XOOF#"YV$"4-!Hww||G6HE/! " ):s   BBc              #     #    U(       a+  [        U 5       n[        R                  " U5      nSSS5        OSn[        X5       Hy  u  pgWb5  UR	                  [
        R                  R                  X`5      5      (       a  M=  U(       a  MF  [        X5      nX;  d  MX  [
        R                  R                  X`5      v   M{     g! , (       d  f       N= f7f)zGet untracked paths.

Args:
  frompath: Path to walk
  basepath: Path to compare to
  index: Index to check against
  exclude_ignored: Whether to exclude ignored paths
N)	rq   r   r   r  r   r}   r   r   r   )	r  r  r  r  r   r   r  r  r  s	            r?   r   r     s      x(A0::1=N )( -hA
%.*C*CGGOOB)+
 +
 v"80Bggoob33 B )(s(   CC ACC&C 
C
Cc                    [        U 5       nUR                  5       n/ / / S.n US   R                  nUR	                  UR
                  U5       H  nUS   S   (       d  US   R                  US   S   5        M,  US   S   (       d  US   R                  US   S   5        MU  US   S   US   S   :X  a  US   R                  US   S   5        M  [        S	5      e   UsSSS5        $ ! [         a    Sn Nf = f! , (       d  f       g= f)
zReturn add/delete/modify changes to tree by comparing index to HEAD.

Args:
  repo: repo path or object
Returns: dict with lists for each type of change
)r   deletemodifyr   Nr   r   r  r  r  zgit mv ops not yet supported)rq   r   r   r   changes_from_treer   r   r  )r   r   r  r  tree_idrd  s         r?   r  r    s    
4	 A 

	jooG --anngFF!9Q<&--fQil;AYq\)001>11-)001>)*HII G 3 
!	   	G	 
!	 s.   C<C*B-C<*C96C<8C99C<<
D
c                 R    [        U 5      n[        X1U5      nUR                  5         g)zRun a daemon serving Git requests over TCP/IP.

Args:
  path: Path to the directory to serve.
  address: Optional address to listen on (defaults to ::)
  port: Optional port to listen on (defaults to TCP_GIT_PORT)
N)r1   r2   serve_forever)r   addressportbackendservers        r?   daemonr    s&      %G'D1F
rC   c                 v    SSK JnJnJnJn  [        U 5      nU" U5      nU" UUUUUS9n	U	R                  5         g)zRun a daemon serving Git requests over HTTP.

Args:
  path: Path to the directory to serve
  address: Optional address to listen on (defaults to ::)
  port: Optional port to listen on (defaults to 80)
r   )make_wsgi_chainmake_serverWSGIRequestHandlerLoggerWSGIServerLogger)handler_classserver_classN)dulwich.webr  r  r  r  r1   r  )
r   r  r  r  r  r  r  r  appr  s
             r?   
web_daemonr  )  sI       %G
'
"C.%F rC   c                 |  ^ Tc)  [        [        R                  S[        R                  5      mUc)  [        [        R                  S[        R                  5      n[        R
                  R                  U 5      n [        U 5      nU4S jn[        UR                  U5      n[        X0/U5      nUR                  5         g)zUpload a pack file after negotiating its contents using smart protocol.

Args:
  path: Path to the repository
  inf: Input stream to communicate with client
  outf: Output stream to communicate with client
rV   c                 H   > TR                  U 5        TR                  5         g r;   rM   flushrE  outfs    r?   send_fnupload_pack.<locals>.send_fnS      

4

rC   r   )r   rz   stdoutstdinr}   r   
expanduserr1   r)   r@   r4   handler   infr
  r  r  protohandlers     `    r?   upload_packr  D  s     |szz8SZZ8
{cii399577d#D%G SXXw'E7GNNrC   c                 |  ^ Tc)  [        [        R                  S[        R                  5      mUc)  [        [        R                  S[        R                  5      n[        R
                  R                  U 5      n [        U 5      nU4S jn[        UR                  U5      n[        X0/U5      nUR                  5         g)zReceive a pack file after negotiating its contents using smart protocol.

Args:
  path: Path to the repository
  inf: Input stream to communicate with client
  outf: Output stream to communicate with client
rV   c                 H   > TR                  U 5        TR                  5         g r;   r  r	  s    r?   r  receive_pack.<locals>.send_fnm  r  rC   r   )r   rz   r  r  r}   r   r  r1   r)   r@   r3   r  r  s     `    r?   receive_packr  ^  s     |szz8SZZ8
{cii399577d#D%G SXXw'E &%8GNNrC   c                 b    [        U SS 5      (       a  U R                  [        5      n [        U -   $ )Nr   )r   r   r   r,   r   s    r?   r   r   x  s+    tXt$${{+,%%rC   c                 Z    [        U SS 5      (       a  U R                  [        5      n SU -   $ )Nr   
   refs/tags/)r   r   r   r  s    r?   r  r  ~  s+    tXt$${{+,4rC   c                     [        U 5       n[        U[        5      (       a  UnOU/nU H  nUR                  [	        U5      	 M     SSS5        g! , (       d  f       g= f)zRDelete a branch.

Args:
  repo: Path to the repository
  name: Name of the branch
N)rq   ri   r   r   r   r  s       r?   branch_deleter     sO     
4	 AdD!!EFED'-.  
!	 	 s   ;A
Ac                 v   [        U 5       nUc  Sn[        XB5      n[        U5      nSUR                  S5      -   nU(       a'  UR                  R                  USUR                  US9  O7UR                  R                  XeR                  US9(       d  [        SU-  5      eSSS5        g! , (       d  f       g= f)zCreate a branch.

Args:
  repo: Path to the repository
  name: Name of the new branch
  objectish: Target object to point new branch at (defaults to HEAD)
  force: Force creation of branch, even if it already exists
Nr   s   branch: Created from rW   )r   z#Branch with name %s already exists.)	rq   r"   r   r   r   set_if_equalsr   
add_if_newrY   )r   r   r|  r   r   rS  refnameref_messages           r?   branch_creater&    s     
4	 AIa+"4(.1A1A'1JJFF  $		; O66$$Wii$MADHII 
!	 	 s   BB**
B8c                     [        U 5       nUR                  R                  [        S9sSSS5        $ ! , (       d  f       g= f)z9List all branches.

Args:
  repo: Path to the repository
)baseN)rq   r   r   r,   r   s     r?   branch_listr)    s-     
4	 Avv{{ 3{4 
!	 	 s	   3
Ac                     [        U 5       nUR                  R                  S5      S   S   nUR                  [        5      (       d  [        U5      eU[        [        5      S sSSS5        $ ! , (       d  f       g= f)zReturn the active branch in the repository, if any.

Args:
  repo: Repository to open
Returns:
  branch name
Raises:
  KeyError: if the repository does not have a working tree
  IndexError: if HEAD is floating
r   r   r  N)rq   r   followr   r,   r   r  )r   r   
active_refs      r?   r  r    sd     
4	 AVV]]7+A.q1
$$%899Z((#1245	 
!	 	 s   AA..
A<c                     [        U 5       n[        UR                  5      nUR                  5       n UR	                  SU4S5      nSSS5        U$ ! [
         a    Sn Nf = f! , (       d  f       W$ = f)zReturn the active branch's remote name, if any.

Args:
  repo: Repository to open
Returns:
  remote name
Raises:
  KeyError: if the repository does not have a working tree
s   branchr   r   N)rq   r  r   r   r  r   )r   r   branch_namer  r  s        r?   r  r    su     
4	 A#AFF+	$ **i%=yIK	 
!   	$#K	$ 
!	  s(   &A#AA A#A  A##
A2refs_containerr  r   r   prune
prune_tagsc                    [        U5      nUR                  5        VVs0 s H4  u  pxUR                  [        5      (       d  M!  U[	        [        5      S  U_M6     n	nnU R                  SUR                  5       -   U	UUS9  UR                  5        VVs0 s HH  u  pxUR                  S5      (       d  M  UR                  [        5      (       a  M9  U[	        S5      S  U_MJ     n
nnU R                  SXUS9  g s  snnf s  snnf )Ns   refs/remotes/)r   r0  r  r  )	r-   r   r   r,   r  import_refsr   endswithr+   )r/  r  r   r   r0  r1  stripped_refsrO  vbranchesr  s              r?   r  r    s    &d+M $))++FQ<<+, 	)#!
"
$%q(+  
 ;--//	   $))++FQ<<& 	#/0zz:N/O 	##m

"+ 	 
 |T*U!s    C7C7C=3C=C=c	           
      V   [        U 5       n
[        X5      u  pUc  SUR                  S5      -   n[        U4SU
R	                  5       0U	D6u  pUR                  XUR                  US9nUb"  [        U
R                  UUR                  UUUS9  SSS5        U$ ! , (       d  f       W$ = f)a  Fetch objects from a remote server.

Args:
  repo: Path to the repository
  remote_location: String identifying a remote server
  outstream: Output stream (defaults to stdout)
  errstream: Error stream (defaults to stderr)
  message: Reflog message (defaults to b"fetch: from <remote_name>")
  depth: Depth to fetch at
  prune: Prune remote removed refs
  prune_tags: Prune reomte removed tags
Returns:
  Dictionary with refs on the remote
Ns   fetch: from rW   r  )r  r   )r0  r1  )	rq   r  r   r   r  r   rM   r  r   )r   r  r   r   r   r   r0  r1  r   r   r   r  r  r   r   s                  r?   r   r     s    4 
4	 A)8)L&?%(>(>w(GGG-
$%$6$6$8
<B
 ||DiooU|S"!!% 
!" # 
!	 " s   BB
B(c                 t    Uc  [         R                  " 5       n[        U 4SU0UD6u  p4UR                  U5      $ )zList the refs in a remote.

Args:
  remote: Remote repository location
  config: Configuration to use
Returns:
  Dictionary with remote refs
r  )r   defaultr   get_refs)remoter  r   r  	host_paths        r?   	ls_remoter>  $  s=     ~&&(.vOfOOF??9%%rC   c                     [        U 5       nUR                  R                  5         SSS5        g! , (       d  f       g= f)ztRepack loose files in a repository.

Currently this only packs loose objects.

Args:
  repo: Path to the repository
N)rq   r   pack_loose_objectsr   s     r?   repackrA  3  s*     
4	 A	))+ 
!	 	 s   0
>c           
      @   [        U 5       n[        UUR                  R                  S U 5       5      US9u  pgSSS5        UbC  [	        WR                  5        VV	s/ s H  u  pXS   U	S   4PM     sn	n5      n[        X6W5        gg! , (       d  f       NU= fs  sn	nf )zPack objects into a file.

Args:
  repo: Path to the repository
  object_ids: List of object ids to write
  packf: File-like object to write to
  idxf: File-like object to write to (can be None)
c              3   (   #    U  H  oS 4v   M
     g 7fr;   r<   ).0oids     r?   	<genexpr>pack_objects.<locals>.<genexpr>K  s     $GJS4[Js   )delta_window_sizeNr   r  )rq   r'   r   	iter_shasr  r   r&   )
r   
object_idspackfidxfrH  r   entriesdata_sumkr6  s
             r?   pack_objectsrP  ?  s     
4	 A.NN$$$GJ$GG/
 
! Hfq1dAaD/HI1  
!	  Is   .B	B
	
Br   c                    ^^^^ UUUU4S jm[        U 5       n[        XQ5      nT" UR                  UR                  S5        SSS5        g! , (       d  f       g= f)zList contents of a tree.

Args:
  repo: Path to the repository
  tree_ish: Tree id to list
  outstream: Output stream (defaults to stdout)
  recursive: Whether to recursively list files
  name_only: Only print item name
c                 D  > X   R                  5        H  u  p4nU(       a  [        R                  " X#5      nT(       a  TR                  US-   5        OTR                  [	        X4U5      5        [
        R                  " U5      (       d  Mw  T	(       d  M  T" XU5        M     g )Nr   )	iteritems	posixpathr4  rM   r    statS_ISDIR)
storetreeidr(  r   r  r  	list_tree	name_onlyr   	recursives
         r?   rY  ls_tree.<locals>.list_treed  sr    !&!8!8!:T ~~d1u- 8S IJ||D!!ii%d+ ";rC   rX  N)rq   r%   r   r   )r   r  r   r[  rZ  r   r   rY  s     ```  @r?   ls_treer]  S  sC    "	, 	, 
4	 A!%!..$''2. 
!	 	 s   *A
Ac                    [        U[        5      (       d  UR                  [        5      n[        U[        5      (       d  UR                  [        5      n[	        U 5       nUR                  5       nSU4nUR                  U5      (       a  [        U5      eUR                  USU5        UR                  5         SSS5        g! , (       d  f       g= f)zZAdd a remote.

Args:
  repo: Path to the repository
  name: Remote name
  url: Remote URL
r   r   N)
ri   r|   r   r   rq   r   r  re   r   r   )r   r   r  r   r   r  s         r?   
remote_addr_  t  s     dE""{{+,c5!!jj)*	4	 ALLNd#==!!w''	gvs#	 
!	 	 s    AC
Cc              #     #    [        U 5       nUR                  5       n[        R                  " U5      nU H  nU(       d  [	        UR
                  U5      U;   a  M&  [        R
                  R                  U5      (       a)  [        R
                  R                  XcR
                  5      nUR                  U5      (       d  M  Uv   M     SSS5        g! , (       d  f       g= f7f)zDebug gitignore files.

Args:
  repo: Path to the repository
  paths: List of paths to check for
  no_index: Don't check index
Returns: List of ignored files
N)
rq   r   r   r   r   r   r}   isabsr   r   )r   r   no_indexr   r  r   r   s          r?   check_ignorerc    s      
4	 A,66q9D 1!&&$ ?5 Hww}}T""wwtVV4((..
  
!	 	 s#   C$B0CC
	C$
C!C$c                 f   [        U 5       nUb  [        U5      nOSnU(       a0  UR                  U	 [        XA5      R                  UR                  U'   O%UR                  R                  U[        XA5      5        Ub  UR                  R                  SU5        SSS5        g! , (       d  f       g= f)zUpdate HEAD to point at a new branch/commit.

Note that this does not actually update the working tree.

Args:
  repo: Path to the repository
  detach: Create a detached head
  target: Branch or committish to switch to
  new_branch: New branch to create
Nr   )rq   r   r   r!   r   r   r#   )r   r   detached
new_branchr   to_sets         r?   update_headrh    s     
4	 A!%j1FF v)!477AFF6NFF##FIa,@A!FF##GV4 
!	 	 s   BB""
B0c                    [        U 5       nSSKJn   UR                  [        R
                  R                  UR
                  S5      5      nUR                  U5      sSSS5        $ ! [         a
    U" 5       n N-f = f! , (       d  f       g= f)zCheck canonical name and email of contact.

Args:
  repo: Path to the repository
  contact: Contact name and/or email
Returns: Canonical contact data
r   )Mailmapz.mailmapN)	rq   dulwich.mailmaprj  	from_pathr}   r   r4  FileNotFoundErrorlookup)r   contactr   rj  mailmaps        r?   check_mailmaprq    sp     
4	 A+	 ''QVVZ(HIG ~~g& 
!	 
 ! 	 iG	  
!	 s.   A>9A'A>'A;8A>:A;;A>>
Bc              #      #    [        U 5       nUR                   H#  nUR                  U   n UR                  5         M%     SSS5        g! [         a  nX$4v    SnAME  SnAff = f! , (       d  f       g= f7f)zcCheck a repository.

Args:
  repo: A path to the repository
Returns: Iterator over errors/warnings
N)rq   r   check	Exception)r   r   r  rx  r  s        r?   fsckru    sh      
4	 A >>Cs#A	 "	 
!	   h 
!	 sD   A9A(AA(	A9
A%A A( A%%A((
A62A9c                     [        U 5       nSSKJn  UR                  U5      n[	        [        UR                  5       5      5      sSSS5        $ ! , (       d  f       g= f)z!List all stashes in a repository.r   StashN)rq   dulwich.stashrx  r   	enumerater   stashesr   r   rx  stashs       r?   
stash_listr~    s<    	4	 A'"emmo./	 
!	 	 s   9A
Ac                     [        U 5       nSSKJn  UR                  U5      nUR	                  5         SSS5        g! , (       d  f       g= f)z Push a new stash onto the stack.r   rw  N)rq   ry  rx  r   r  r|  s       r?   
stash_pushr    s2    	4	 A'"

	 
!	 	 	   (=
Ac                     [        U 5       nSSKJn  UR                  U5      nUR	                  5         SSS5        g! , (       d  f       g= f)zPop a new stash from the stack.r   rw  N)rq   ry  rx  r   popr|  s       r?   	stash_popr    s2    	4	 A'"			 
!	 	 r  c                     [        U 5       n[        UR                  5       5      sSSS5        $ ! , (       d  f       g= f)zList all files in an index.N)rq   r  r   r   s     r?   ls_filesr    s&    	4	 Aalln% 
!	 	 s   /
=c           
         [        U 5       nUR                  5       n0 nUR                  5        H  u  pEUR                  5       nUR	                  U5      nSU;  a  M.  UR                  SS5      u  px UR                  n	UR	                  U	S   5      n	[        R                  " [        R                  " U	R                  5      SS 6 U	R                  R                  S5      /X8'   M     [        UR                  5       S SS	9n
[        U
5      S
:X  aF  SR                  XR!                  5          R                  R                  S5      SS 5      sSSS5        $ S
nXR!                  5          nUR#                  5       nU H  nUR$                  R                  R                  S5      nU
 Hg  nUS
   nUS   S   nUU:X  d  M  US
:X  a  Us  s  sSSS5        $ SR                  UUUR                  R                  S5      SS 5      s  s  sSSS5        $    US-  nM     SR                  UR                  R                  S5      SS 5      sSSS5        $ ! [         a     GM/  f = f! , (       d  f       g= f)zDescribe the repository version.

Args:
  projdir: git repository root
Returns: a string description of the current git revision

Examples: "gabcdefh", "v0.1" or "v0.1-5-gabcdefh".
r  rv   r  Nrt   rw   c                     U S   S   $ )Nr  r   r<   )rB  s    r?   <lambda>describe.<locals>.<lambda>!  s    3q6!9rC   T)r   rk  r   zg{}   z	{}-{}-g{})rq   r;  r   r'  
get_objectrsplitrS  AttributeErrordatetimer5  r6  r   r   r  r  formatr   rp  r   )r   r   r   r  r   valuern   _rB  r   sorted_tagscommit_countlatest_commitrs  rn  	commit_idtag_name
tag_commits                     r?   describer     s;    
4	 Azz|**,JC**,C,,u%Cc!ZZa(FA1 fQi0!!4;;v/A/A#B2A#FG		  )DI '& TZZ\/DdS {q <<&&( 5 5g >r BC7 
!	 <  &&( E..w7I"q6 VAY

*#q('[ 
!	 ^  +11$(),,33G<Ra@  _ 
!	 P # AL! & ||M,,33G<Ra@Aq 
!	  "  
!	 sJ   A%I"2I>CI"A$I">I"2I"7I"
II"II""
I0c                    Uc  Sn[        U 5       n[        X25      nUR                  n[        U[        5      (       d  [        XA5      n[        UR                  R                  XQ5      u  pgX7   sSSS5        $ ! , (       d  f       g= f)zGet an object by path.

Args:
  repo: A path to the repository
  path: Path to look up
  committish: Commit to look up path in
Returns: A `ShaFile` object
Nr   )	rq   r!   r   ri   r|   r-  r   r   r  )r   r   r   r   r   rK  r  r  s           r?   get_object_by_pathr  E  sl     
	4	 Aa,KK	$&& .D&q~~'A'A9Sv 
!	 	 s   AA88
Bc                     [        U 5       nUR                  5       R                  UR                  5      sSSS5        $ ! , (       d  f       g= f)zWrite a tree object from the index.

Args:
  repo: Repository for which to write tree
Returns: tree id for the tree that was written
N)rq   r   r   r   r   s     r?   
write_treer  Z  s2     
4	 A||~$$Q^^4 
!	 	 s	   )?
A)r   )F)r   NNNNF)NNN)r   F)r   N)r   NF)NNFr   NNF)r   r;   )r   NN)NF)NFF)FN)rT   collectionsr   
contextlibr   r   ior   r   r  r}   pathlibr   rT  r   rU  rz   r5  typingr	   r
   r   r   dulwich.archiver   dulwich.clientr   dulwich.configr   dulwich.diff_treer   r   r   r   r   r   dulwich.errorsr   dulwich.graphr   dulwich.ignorer   dulwich.indexr   r   dulwich.object_storer   dulwich.objectsr   r   r   r   r    dulwich.objectspecr!   r"   r#   r$   r%   dulwich.packr&   r'   dulwich.patchr(   dulwich.protocolr)   r*   dulwich.refsr+   r,   r-   r.   dulwich.repor/   r0   dulwich.serverr1   r2   r3   r4   r5   r   r6   r8   r   r  default_bytes_out_streamstderrdefault_bytes_err_streamr   rt  rY   re   rl   ro   rq   r   r   r   r   r   r   r   r   r   r   r  r  r  rmr+  r-  r=  rC  rF  rM  rP  rT  rR  rh  ru  r}  r  r  rB  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  boolr  r   r>  rA  rP  r]  r_  rc  rh  rq  ru  r~  r  r  r  r  r  r  r<   rC   r?   <module>r     s  *$L # "  	     
    /   *  (  {$?@	   #3::x>N*, "3::x>N*,   I 15 1  
' 5E 6"rCu C5$ &&	#2%:  
!
H
& 	&
WtD0-"`-`  6F 0 6F % ,/:: 8 &)ZZ $ -0JJ 	' 14

 B* -0JJ 
* +.** 
>36< 

jjD 
jj%	 1F 36** 
G '*jj 
5' 	9,x% !ZZ 	,$$ @D4
4!)%U
*;!<4
8C=#46 &&
QJl &&
;H|O8"444 F644& / J,56$0  $V!VV sCx.V e_	V
 V V< jj&


+\&	,2, jj/B**58'$&0&BBJ*5rC   