ó
    ‘óýjH=  ã                   ór   • S r S/rSSKrSSKJrJr  SSKJr  SSKJ	r	J
r
  SSKJrJr  SSKJr   " S	 S5      rg)
zGit bisect implementation.ÚBisectStateé    N)ÚSequenceÚSet)Úpeel_sha)ÚCommitÚObjectID)ÚHEADREFÚRef)ÚRepoc                   ó´  • \ rS rSrSrS\SS4S jr\S\4S j5       r	      S%S\
S-  S	\\
   S-  S
\\   S-  S\S\S\SS4S jjrS&S\
S-  S\
S-  4S jjrS&S\
S-  S\
S-  4S jjrS&S\\
   S-  S\
S-  4S jjrS&S\
S-  SS4S jjrS\4S jrS\SS4S jrS\
S-  4S jrS\
S\\
   S\\
   S\\
   4S jrS\
S\4S jrS \SS4S! jrS"\S\4S# jrS$rg)'r   é#   z&Manages the state of a bisect session.ÚrepoÚreturnNc                 óv   • Xl         [        R                  R                  UR	                  5       S5      U l        g)zIInitialize BisectState.

Args:
    repo: Repository to perform bisect on
ÚBISECT_STARTN)r   ÚosÚpathÚjoinÚ
controldirÚ_bisect_dir)Úselfr   s     Ú9/usr/local/lib/python3.13/site-packages/dulwich/bisect.pyÚ__init__ÚBisectState.__init__&   s'   € ð Œ	ÜŸ7™7Ÿ<™<¨¯©Ó(9¸>ÓJˆÕó    c                 óT   • [         R                  R                  U R                  5      $ )z$Check if a bisect session is active.)r   r   Úexistsr   )r   s    r   Ú	is_activeÚBisectState.is_active/   s   € ô �w‰w�~‰~˜d×.Ñ.Ó/Ð/r   ÚbadÚgoodÚpathsÚno_checkoutÚterm_badÚ	term_goodc                 ó&  • U R                   (       a  [        S5      e[        R                  R	                  U R
                  R                  5       SS5      n[        R                  " USS9   U R
                  R                  R                  [        5      u  p‰U	c  [        S5      e[        U5      S:”  a  US   n
OU	n
 [        U R                  S	5       nUR!                  U
5        SSS5        [        R                  R	                  U R
                  R                  5       S
5      n[        US5       nUR!                  U SU S35        SSS5        [        R                  R	                  U R
                  R                  5       S5      n[        US5       nU(       a+  UR!                  SR	                  S U 5       5      S-   5        OUR!                  S5        SSS5        [        R                  R	                  U R
                  R                  5       S5      n[        US5       nUR!                  S5        UR!                  S5        SSS5        Ub  U R#                  U5        U(       a  U H  nU R%                  U5        M     gg! [         a8     U R
                  R                  5       n
 GNò! [         a    [        S5      ef = ff = f! , (       d  f       GNî= f! , (       d  f       GNœ= f! , (       d  f       GN= f! , (       d  f       NÀ= f)aZ  Start a new bisect session.

Args:
    bad: The bad commit SHA (defaults to HEAD)
    good: List of good commit SHAs
    paths: Optional paths to limit bisect to
    no_checkout: If True, don't checkout commits during bisect
    term_bad: Term to use for bad commits (default: "bad")
    term_good: Term to use for good commits (default: "good")
z"Bisect session already in progressÚrefsÚbisectT)Úexist_okNz+Cannot start bisect: repository has no HEADé   ÚwbÚBISECT_TERMSÚwÚ
ÚBISECT_NAMESc              3   óD   #   • U  H  oR                  S S5      v •  M     g7f)úutf-8ÚreplaceN)Údecode)Ú.0r   s     r   Ú	<genexpr>Ú$BisectState.start.<locals>.<genexpr>p   s   é € ÐPÊ%À$Ÿk™k¨'°9×=Ð=Ê%ùs   ‚ Ú
BISECT_LOGzgit bisect start
z0# status: waiting for both good and bad commits
)r   Ú
ValueErrorr   r   r   r   r   Úmakedirsr'   Úfollowr	   ÚlenÚKeyErrorÚheadÚopenr   ÚwriteÚmark_badÚ	mark_good)r   r    r!   r"   r#   r$   r%   Úbisect_refs_dirÚ	ref_chainÚshaÚcurrent_branchÚfÚ
terms_fileÚ
names_fileÚlog_fileÚgs                   r   ÚstartÚBisectState.start4   s]  € ð& �>�>ÜÐAÓBÐBô Ÿ'™'Ÿ,™, t§y¡y×';Ñ';Ó'=¸vÀxÓPˆÜ
�Š�O¨dÒ3ð	PØ!ŸY™YŸ^™^×2Ñ2´7Ó;‰NˆIØ‰{ä Ð!NÓOÐOô �9‹~ Ó!Ø!*¨1¡‘à!$‘ô �$×"Ñ" DÔ)¨QØ�G‰G�NÔ#÷ *ô —W‘W—\‘\ $§)¡)×"6Ñ"6Ó"8¸.ÓIˆ
Ü�*˜cÔ" aØ�G‰G�x�j  9 +¨RÐ0Ô1÷ #ô —W‘W—\‘\ $§)¡)×"6Ñ"6Ó"8¸.ÓIˆ
Ü�*˜cÔ" aÞØ—‘Ø—I‘IÑPÉ%ÓPÓPÐSWÑWõð —‘˜”÷ #ô —7‘7—<‘< §	¡	× 4Ñ 4Ó 6¸ÓEˆÜ�(˜CÔ  AØ�G‰GÐ(Ô)Ø�G‰GÐGÔH÷ !ð
 ‰?Ø�M‰M˜#Ôö Û�Ø—‘˜qÖ!ò ð øôM ó 	PðPØ!%§¡§¡Ó!1“øÜó Pä Ð!NÓOÐOðPúð		Pú÷ *Ö)ú÷
 #Ö"ú÷
 #Ö"ú÷ !Õ úsV   Á,AJ Â:J ÃKÄ1KÆAK0È%#LÊ
K	ÊJ/Ê/KËK	Ë
KË
K-Ë0
K?Ì
LÚrevc                 óˆ  • U R                   (       d  [        S5      eUc  U R                  R                  5       nO-[	        U R                  R
                  U5      S   R                  n[        R                  R                  U R                  R                  5       SSS5      n[        US5       nUR                  US-   5        SSS5        U R                  S	UR                  S
5       SU R                  U5       35        U R                  SUR                  S
5       35        U R!                  5       $ ! , (       d  f       Nv= f)z£Mark a commit as bad.

Args:
    rev: Commit SHA to mark as bad (defaults to HEAD)

Returns:
    The SHA of the next commit to test, or None if bisect is complete
úNo bisect session in progressNr*   r'   r(   r    r+   ó   
z# bad: [Úasciiú] zgit bisect bad )r   r8   r   r=   r   Úobject_storeÚidr   r   r   r   r>   r?   Ú_append_to_logr3   Ú_get_commit_subjectÚ_find_next_commit)r   rM   Úbad_ref_pathrF   s       r   r@   ÚBisectState.mark_bad„   s  € ð �~�~ÜÐ<Ó=Ð=à‰;Ø—)‘)—.‘.Ó"‰Cä˜4Ÿ9™9×1Ñ1°3Ó7¸Ñ:×=Ñ=ˆCô —w‘w—|‘| D§I¡I×$8Ñ$8Ó$:¸FÀHÈeÓTˆÜ�, Ô%¨Ø�G‰G�C˜%‘KÔ ÷ &ð 	×ÑØ�s—z‘z 'Ó*Ð+¨2¨d×.FÑ.FÀsÓ.KÐ-LÐMô	
ð 	×Ñ˜o¨c¯j©j¸Ó.AÐ-BÐCÔDà×%Ñ%Ó'Ð'÷ &Õ%ús   Â.D3Ä3
Ec           	      ó¬  • U R                   (       d  [        S5      eUc  U R                  R                  5       nO-[	        U R                  R
                  U5      S   R                  n[        R                  R                  U R                  R                  5       SSSUR                  S5       35      n[        US5       nUR                  US	-   5        SSS5        U R                  S
UR                  S5       SU R                  U5       35        U R                  SUR                  S5       35        U R!                  5       $ ! , (       d  f       Nv= f)z¥Mark a commit as good.

Args:
    rev: Commit SHA to mark as good (defaults to HEAD)

Returns:
    The SHA of the next commit to test, or None if bisect is complete
rO   Nr*   r'   r(   úgood-rQ   r+   rP   z	# good: [rR   zgit bisect good )r   r8   r   r=   r   rS   rT   r   r   r   r   r3   r>   r?   rU   rV   rW   )r   rM   Úgood_ref_pathrF   s       r   rA   ÚBisectState.mark_good¢   s  € ð �~�~ÜÐ<Ó=Ð=à‰;Ø—)‘)—.‘.Ó"‰Cä˜4Ÿ9™9×1Ñ1°3Ó7¸Ñ:×=Ñ=ˆCô Ÿ™Ÿ™Ø�I‰I× Ñ Ó" F¨H¸¸c¿j¹jÈÓ>QÐ=RÐ6Só
ˆô �- Ô&¨!Ø�G‰G�C˜%‘KÔ ÷ 'ð 	×ÑØ˜Ÿ
™
 7Ó+Ð,¨B¨t×/GÑ/GÈÓ/LÐ.MÐNô	
ð 	×ÑÐ.¨s¯z©z¸'Ó/BÐ.CÐDÔEà×%Ñ%Ó'Ð'÷ 'Õ&ús   Ã EÅ
EÚrevsc           
      óT  • U R                   (       d  [        S5      eUc  U R                  R                  5       /nU HÈ  n[	        U R                  R
                  U5      S   R                  n[        R                  R                  U R                  R                  5       SSSUR                  S5       35      n[        US5       nUR                  US	-   5        SSS5        U R                  S
UR                  S5       35        MÊ     U R                  5       $ ! , (       d  f       NE= f)z¨Skip one or more commits.

Args:
    revs: List of commits to skip (defaults to [HEAD])

Returns:
    The SHA of the next commit to test, or None if bisect is complete
rO   Nr*   r'   r(   úskip-rQ   r+   rP   zgit bisect skip )r   r8   r   r=   r   rS   rT   r   r   r   r   r3   r>   r?   rU   rW   )r   r^   rM   Úskip_ref_pathrF   s        r   ÚskipÚBisectState.skipÂ   sò   € ð �~�~ÜÐ<Ó=Ð=à‰<Ø—I‘I—N‘NÓ$Ð%ˆDãˆCÜ˜4Ÿ9™9×1Ñ1°3Ó7¸Ñ:×=Ñ=ˆCÜŸG™GŸL™LØ—	‘	×$Ñ$Ó&¨°¸EÀ#Ç*Á*ÈWÓBUÐAVÐ:WóˆMô �m TÔ*¨aØ—‘˜˜e™Ô$÷ +ð ×ÑÐ"2°3·:±:¸gÓ3FÐ2GÐ HÖIñ ð ×%Ñ%Ó'Ð'÷ +Õ*ús   ÃDÄ
D'	Úcommitc                 óÔ  • U R                   (       d  [        S5      e[        U R                  S5       nUR	                  5       R                  5       nSSS5        S Hw  n[        R                  R                  U R                  R                  5       U5      n[        R                  R                  U5      (       d  Ma  [        R                  " U5        My     [        R                  R                  U R                  R                  5       SS5      n[        R                  R                  U5      (       af  [        R                  " U5       H6  n[        R                  " [        R                  R                  Xd5      5        M8     [        R                  " U5        Ucq  WR                  S5      (       a4  U R                  R                   R#                  [$        ['        U5      5        g[)        U5      U R                  R                   [$        '   g[+        U R                  R,                  U5      S   R.                  nXR                  R                   [$        '   g! , (       d  f       GN= f)	z�Reset bisect state and return to original branch/commit.

Args:
    commit: Optional commit to reset to (defaults to original branch/commit)
rO   ÚrbN)r   r,   r/   r7   ÚBISECT_EXPECTED_REVÚBISECT_ANCESTORS_OKr'   r(   s   refs/r*   )r   r8   r>   r   ÚreadÚstripr   r   r   r   r   r   ÚremoveÚlistdirÚrmdirÚ
startswithr'   Úset_symbolic_refr	   r
   r   r   rS   rT   )r   rd   rF   ÚoriginalÚfilenameÚfilepathrB   s          r   ÚresetÚBisectState.resetÝ   sˆ  € ð �~�~ÜÐ<Ó=Ð=ô �$×"Ñ" DÔ)¨QØ—v‘v“x—~‘~Ó'ˆH÷ *ó
ˆHô —w‘w—|‘| D§I¡I×$8Ñ$8Ó$:¸HÓEˆHÜ�w‰w�~‰~˜h×'Ó'Ü—	’	˜(Ö#ñ
ô Ÿ'™'Ÿ,™, t§y¡y×';Ñ';Ó'=¸vÀxÓPˆÜ�7‰7�>‰>˜/×*Ñ*ÜŸJšJ Ö7�Ü—	’	œ"Ÿ'™'Ÿ,™, ÓAÖBñ 8ä�HŠH�_Ô%ð ‰>Ø×"Ñ" 8×,Ñ,à—	‘	—‘×/Ñ/´¼¸X»ÕGô +3°8Ó*<�—	‘	—‘œwÒ'ä˜dŸi™i×4Ñ4°fÓ=¸aÑ@×CÑCˆFØ&,�I‰I�N‰Nœ7Ò#÷C *Ö)ús   ³IÉ
I'c                 ó  • U R                   (       d  [        S5      e[        R                  R	                  U R
                  R                  5       S5      n[        U5       nUR                  5       sSSS5        $ ! , (       d  f       g= f)zGet the bisect log.rO   r7   N)	r   r8   r   r   r   r   r   r>   ri   )r   rI   rF   s      r   Úget_logÚBisectState.get_log
  sR   € à�~�~ÜÐ<Ó=Ð=ä—7‘7—<‘< §	¡	× 4Ñ 4Ó 6¸ÓEˆÜ�(Œ^˜qØ—6‘6“8÷ �^�^ús   Á A:Á:
BÚlog_contentc           	      ó
  • UR                  5        GHi  nUR                  5       nUR                  S5      (       d  U(       d  M3  UR                  5       n[	        U5      S:  d  US   S:w  d	  US   S:w  a  Mf  US   n[	        U5      S:”  a  USS O/ nU=S	:X  a    U R                  5         M›  =S
:X  a:    U(       a  [        US   R                  S5      5      OSnU R                  U5        MÛ  =S:X  a;    U(       a  [        US   R                  S5      5      OSnU R                  U5        GM  S:X  d  GM$  U(       a+  U Vs/ s H  n[        UR                  S5      5      PM     snOSnU R                  U5        GMl     gs  snf )zNReplay a bisect log.

Args:
    log_content: The bisect log content to replay
Ú#é   r   Úgitr*   r(   é   NrK   r    rQ   r!   rb   )Ú
splitlinesrj   rn   Úsplitr;   rK   r   Úencoder@   rA   rb   )	r   rx   ÚlineÚpartsÚcmdÚargsrM   Úargr^   s	            r   ÚreplayÚBisectState.replay  s/  € ð  ×*Ñ*×,ˆDØ—:‘:“<ˆDØ�‰˜s×#Ñ#®4Ùà—J‘J“LˆEÜ�5‹z˜A‹~  q¡¨UÓ!2°e¸A±hÀ(Ó6JÙà˜‘(ˆCÜ # E£
¨Q£�5˜˜‘9°BˆDàÞØ—J‘J–LÞÞ?Cœ( 4¨¡7§>¡>°'Ó#:Ô;È�CØ—M‘M #Ö&ÞÞ?Cœ( 4¨¡7§>¡>°'Ó#:Ô;È�CØ—N‘N 3×'ßö  ñ CGÓGÂ$¸3œ #§*¡*¨WÓ"5Ö6Á$ÒGà!ð ð
 —I‘I˜d—Oò7 -ùò. Hs   Å $F c                 óŠ  • [         R                  R                  U R                  R	                  5       SSS5      n[         R                  R                  U5      (       d  U R                  S5        g[        US5       n[        UR                  5       R                  5       5      nSSS5        / n[         R                  R                  U R                  R	                  5       SS5      n[         R                  " U5       Hƒ  nUR                  S5      (       d  M  [        [         R                  R                  XV5      S5       nUR                  [        UR                  5       R                  5       5      5        SSS5        M…     U(       d  U R                  S5        g[        5       n[         R                  " U5       Hƒ  nUR                  S	5      (       d  M  [        [         R                  R                  XV5      S5       nUR                  [        UR                  5       R                  5       5      5        SSS5        M…     U R!                  WXG5      nU(       d6  U R                  S
UR#                  S5       SU R%                  U5       35        g['        U5      S-  n	X‰   n
[         R                  R                  U R                  R	                  5       S5      n[        US5       nUR)                  U
S-   5        SSS5        U R+                  ['        U5      5      nU R                  S['        U5      S-
   SU S35        U R                  SU
R#                  S5       SU R%                  U
5       35        U
$ ! , (       d  f       GNÞ= f! , (       d  f       GM   = f! , (       d  f       GMó  = f! , (       d  f       N»= f)z‚Find the next commit to test using binary search.

Returns:
    The SHA of the next commit to test, or None if bisect is complete
r'   r(   r    z/# status: waiting for both good and bad commitsNrf   r[   z6# status: waiting for good commit(s), bad commit knownr`   z# first bad commit: [rQ   rR   r}   rg   r+   rP   zBisecting: r*   z, revisions left to test after this (roughly z steps)Ú[)r   r   r   r   r   r   rU   r>   r   ri   rj   rl   rn   ÚappendÚsetÚaddÚ_find_bisect_candidatesr3   rV   r;   r?   Ú_estimate_steps)r   rX   rF   Úbad_shaÚ	good_shasrB   rq   Ú	skip_shasÚ
candidatesÚmid_idxÚnext_commitÚexpected_fileÚsteps_remainings                r   rW   ÚBisectState._find_next_commit7  sí  € ô —w‘w—|‘| D§I¡I×$8Ñ$8Ó$:¸FÀHÈeÓTˆÜ�w‰w�~‰~˜l×+Ñ+Ø×ÑÐ QÔRØä�, Ô%¨Ü˜qŸv™v›xŸ~™~Ó/Ó0ˆG÷ &ð %'ˆ	ÜŸ'™'Ÿ,™, t§y¡y×';Ñ';Ó'=¸vÀxÓPˆÜŸ
š
 ?Ö3ˆHØ×"Ñ" 7×+Ó+Üœ"Ÿ'™'Ÿ,™, ÓAÀ4ÔHÈAØ×$Ñ$¤X¨a¯f©f«h¯n©nÓ.>Ó%?Ô@÷ IÑHñ 4ö
 Ø×ÑØHôð ô $'£5ˆ	ÜŸ
š
 ?Ö3ˆHØ×"Ñ" 7×+Ó+Üœ"Ÿ'™'Ÿ,™, ÓAÀ4ÔHÈAØ—M‘M¤(¨1¯6©6«8¯>©>Ó+;Ó"<Ô=÷ IÑHñ 4ð ×1Ñ1°'¸9ÓPˆ
æà×ÑØ'¨¯©°wÓ(?Ð'@ÀØ×+Ñ+¨GÓ4Ð5ð7ôð ô �j“/ QÑ&ˆØ Ñ)ˆô Ÿ™Ÿ™ T§Y¡Y×%9Ñ%9Ó%;Ð=RÓSˆÜ�- Ô&¨!Ø�G‰G�K %Ñ'Ô(÷ 'ð ×.Ñ.¬s°:«Ó?ˆØ×ÑØœ#˜j›/¨AÑ-Ð.ð /Ø'Ð(¨ð1ô	
ð 	×ÑØ�×"Ñ" 7Ó+Ð,¨B¨t×/GÑ/GÈÓ/TÐ.UÐVô	
ð Ð÷m &Ö%ú÷ I×Hú÷ I×Hú÷( 'Õ&ús0   Á=(M<Å7NÈ7N!Ë*N4Í<
NÎ
N	Î!
N1	Î4
Or�   r�   r‘   c                 ó¬  • / n[        U5      nU/nU(       a¦  UR                  S5      nXu;   d  Xs;   a  M$  UR                  U5        U R                  R                  U   nXr;  a  UR                  U5        [        U[        5      (       a+  UR                   H  n	X•;  d  M
  UR                  U	5        M     U(       a  M¦  X;   a  UR                  U5        U$ )zåFind all commits between good and bad commits.

Args:
    bad_sha: The bad commit SHA
    good_shas: List of good commit SHAs
    skip_shas: Set of commits to skip

Returns:
    List of candidate commit SHAs in topological order
r   )
r‹   ÚpoprŒ   r   rS   rŠ   Ú
isinstancer   Úparentsrk   )
r   r�   r�   r‘   r’   ÚvisitedÚqueuerD   rd   Úparents
             r   r�   Ú#BisectState._find_bisect_candidates{  s¾   € ð  &(ˆ
Ü!$ Y£ˆØ!( 	ˆæØ—)‘)˜A“,ˆCØ‹~ Ó!1Ùà�K‰K˜ÔØ—Y‘Y×+Ñ+¨CÑ0ˆFð Ó#Ø×!Ñ! #Ô&ô ˜&¤&×)Ñ)Ø$Ÿnœn�FØÕ,ØŸ™ VÖ,ñ -÷ ˆeð& Ó Ø×Ñ˜gÔ&àÐr   rD   c                 óÒ   • U R                   R                  U   n[        U[        5      (       a9  UR                  R                  SSS9nUR                  S5      nU(       a  US   $ S$ g)z)Get the subject line of a commit message.r1   r2   )Úerrorsr.   r   Ú )r   rS   rš   r   Úmessager3   r   )r   rD   Úobjr£   Úliness        r   rV   ÚBisectState._get_commit_subject§  s^   € à�i‰i×$Ñ$ SÑ)ˆÜ�cœ6×"Ñ"Ø—k‘k×(Ñ(¨¸Ð(ÐCˆGØ—M‘M $Ó'ˆEÞ$�5˜‘8Ð,¨"Ð,Ør   r�   c                 óè   • [         R                  R                  U R                  R	                  5       S5      n[        US5       nUR                  US-   5        SSS5        g! , (       d  f       g= f)z Append a line to the bisect log.r7   Úar.   N)r   r   r   r   r   r>   r?   )r   r�   rI   rF   s       r   rU   ÚBisectState._append_to_log°  sK   € ä—7‘7—<‘< §	¡	× 4Ñ 4Ó 6¸ÓEˆÜ�(˜CÔ  AØ�G‰G�D˜4‘KÔ ÷ !× Ö ús   ÁA#Á#
A1Únum_candidatesc                 óH   • US::  a  gSnUS:”  a  US-  nUS-  nUS:”  a  M  U$ )z1Estimate the number of steps remaining in bisect.r*   r   r}   © )r   rª   Ústepss      r   rŽ   ÚBisectState._estimate_steps¶  s>   € à˜QÓØØˆØ˜qÓ Ø˜qÑ ˆNØ�Q‰JˆEð ˜qÕ ð ˆr   )r   r   )NNNFr    r!   )N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   ÚpropertyÚboolr   r   r   ÚbytesÚstrrK   r@   rA   rb   rs   rv   r†   rW   r   Úlistr�   rV   rU   ÚintrŽ   Ú__static_attributes__r¬   r   r   r   r   #   sÂ  † Ù0ðK˜Tð K dô Kð ð0˜4ó 0ó ð0ð  $Ø*.Ø(,Ø!ØØñN"à˜‰_ðN"ð �xÑ  4Ñ'ðN"ð ˜‰ Ñ%ð	N"ð
 ðN"ð ðN"ð ðN"ð 
õN"ñ`(˜H t™Oð (°xÀ$±õ (ñ<(˜X¨™_ð (¸À4¹õ (ñ@(˜ (Ñ+¨dÑ2ð (¸hÈ¹oõ (ñ6+-˜H t™Oð +-°tõ +-ðZ˜ô ð"$ #ð "$¨$ô "$ðHB 8¨d¡?ô BðH*Øð*Ø,4°XÑ,>ð*ØKNÈxÉ=ð*à	ˆh‰ô*ðX xð °Cô ð! 3ð !¨4ô !ð¨cð °c÷ r   )r³   Ú__all__r   Úcollections.abcr   r   Údulwich.object_storer   Údulwich.objectsr   r   Údulwich.refsr	   r
   Údulwich.repor   r   r¬   r   r   Ú<module>rÁ      s/   ðñ, !àˆ/€ã 	ß )å )ß ,ß %Ý ÷[ò [r   