+
    .pÐj /  ã                  óà   € R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHt R R lt	R t
R R	 ltR
 R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR# ) a{  Steps of ``hermes update --check``: debris cleanup, channel target, scoped fetch, verdict.

``update_cmd._cmd_update_check`` (a frozen updater surface, see ``tests/compat``) orchestrates
these. Facade helpers are read through ``_uc()`` at call time and origin helpers are imported
per function, so test patches on ``hermes_cli.update_cmd`` and the origin modules stay effective.
)ÚannotationsN)ÚPath)ÚAnyc          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
é   Úgit_cmdú	list[str]Úrootr   ÚargsÚkwargsr   Úreturnz subprocess.CompletedProcess[str]© )Úformats   "Ú*/opt/hermes/hermes_cli/update_cmd_check.pyÚ__annotate__r      s0   € ÷ 
ñ 
�)ð 
 4ð 
¨yð 
ÀCð 
ÐLlñ 
ó    c                ó‚   € ^ RI Hp VP                  R^ 4      V! 4       ,          VR&   ^ RIHp V! W3RVRRRRRR	R
R/VB # )é    )Úwindows_hide_flagsÚcreationflags)Úrun_gitÚcwdÚcapture_outputTÚtextÚencodingzutf-8ÚerrorsÚreplace)Úhermes_cli._subprocess_compatr   ÚgetÚhermes_cli.update_custodyr   )r   r	   r
   r   r   r   s   &&&,  r   Ú_gitr       sh   € Ý@ð %Ÿj™j¨¸!Ó<Ñ?QÓ?SÕS€Fˆ?ÑÝ1áØñØðØ04ðØ;?ðØJQðØZcðà
ñð r   c                 ó   € ^ RI Hp  V # )r   ©Ú
update_cmd)Ú
hermes_clir#   r"   s    r   Ú_ucr%      s   € Ý%àÐr   c               ó    € V ^8„  d   QhRRRR/# ©r   r	   r   r   ÚNoner   )r   s   "r   r   r   #   s   € ÷ +ñ +˜4ð + Dñ +r   c                ó¶   € ^ RI HpHpHp V! V 4       F  p\	        RV R24       K  	  V! V 4      pV'       d   \	        R\        V4       R24       V! V 4       R# )a”  Remove abandoned git locks and aborted-fetch pack temps before fetching.

A crashed fetch can leave ``.git/shallow.lock`` (or another lock) behind, and every later
fetch then fails with "File exists". Aborted fetches on flaky lines also strand
``tmp_pack_*`` debris: unchecked it reached 6 GB and corrupted the pack dir (#93732).
A partial clone also gets its commit-graph-off keys re-applied (#127711).
)Úclear_stale_git_locksÚclear_stale_tmp_packsÚ settle_partial_clone_maintenancez  (removed stale git lock: Ú)z  (removed z! aborted-fetch pack temp file(s))N)Úhermes_cli.gitlockr*   r+   r,   ÚprintÚlen)r	   r*   r+   r,   Ú	lock_pathÚswepts   &     r   Úclear_git_debrisr3   #   sW   € ÷ rÑqá*¨4Ö0ˆ	ÜÐ+¨I¨;°aÐ8Ö9ñ 1á! $Ó'€EßÜ�œC ›J˜<Ð'HÐIÔJÙ$ TÖ*r   c               ó    € V ^8„  d   QhRRRR/# r'   r   )r   s   "r   r   r   5   s   € ÷ 	lñ 	l˜4ð 	l Dñ 	lr   c                óD  € ^ RI HpHp V! V 4      pVP                  '       g   VP                  '       dI   \        RVP                   RVP                  R,          R RVP                   RVP                   R2	4       VP                  '       d   \        R	V R
24       R# R# )z[Spend the update's bounded slice on a partial clone's on-demand packs, and say what it did.)ÚTIDY_BUDGET_SECONDSÚtidy_partial_clone_packsz  (git cleanup: erased z duplicate pack(s), g    €„.Az.0fz MB freed; merged z; z left)z  (git cleanup stopped at its z&s limit; the next update continues it)N)	Úhermes_cli.git_pack_tidyr6   r7   ÚerasedÚmergedr/   Úfreed_bytesÚ
packs_leftÚout_of_time)r	   r6   r7   Útidys   &   r   Úreport_pack_tidyr?   5   s“   € çVá# DÓ)€DØ‡{‡{€{�d—k—k�kÜÐ'¨¯© }Ð4HÈ×IYÑIYÐ\_ÕI_Ð`cÐHdð eØŸ™˜ R¨¯©Ð'8¸ð@ô 	Aà××ÐÜÐ.Ð/BÐ.CÐCiÐjÖkñ r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   Úselected_channelÚstrr   r   r	   r   r   z
str | Noner   )r   s   "r   r   r   A   s)   € ÷ !ñ !¨Sð !¸9ð !ÈDð !ÐU_ñ !r   c                ó¢  € ^ RI HpHp ^ RIHp ^ RIHpHp \        RV  24       V! V! V! 4       4      V4      pV! W€V4      p	 V! WW)R7      p
X
P                  '       g   V
P                   # V
P"                  '       d   \        R	V  R
V
P$                   24       V
P&                  '       d   \        RV
P(                   R24       R# \+        4       P-                  W4      V
P                  8X  d   \        RV
P(                   R24       R# \/        WRRV
P                  R.4      P0                  ^ 8X  d'   \        RV
P(                   R24       \        R4       R# \        RV
P(                   24       \        R4       R#   \        \        \        P                  3 d3   p\        RT  RT 24       \        P                  ! ^4        Rp?EL|Rp?ii ; i)a  Report a release-pinned channel's verdict, or return the branch to compare against.

``None`` means the verdict is printed (the channel pins a commit); exits 1 when the channel
cannot be resolved. An install riding its default channel only ever moves forward.
)Úget_config_pathÚ$require_readable_config_before_write©Úresolve_source_target©Úchannel_recordÚrides_default_channelõ   â†’ Update channel: ©Úforward_onlyõ   âœ— Could not resolve the ú source channel: Nõ   â†’ ú retired; source destination: u   âœ“ No newer release: Ú.u(   âœ“ Up to date with the latest release (ú).z
merge-basez--is-ancestorÚHEADu6   â†’ This checkout is newer than the selected release: zj  `hermes update` moves it back to that release (`hermes update --set-channel main` follows every commit).u    â†’ Selected release available: z$  Run `hermes update` to install it.)Úhermes_cli.configrD   rE   Úhermes_cli.source_releasesrG   Úhermes_cli.update_channelrI   rJ   r/   ÚOSErrorÚ
ValueErrorÚ
subprocessÚSubprocessErrorÚsysÚexitÚcommitÚbranchÚretiredÚchannelÚaheadÚlabelr%   Ú_capture_head_shar    Ú
returncode)rA   r   r	   rD   rE   rG   rI   rJ   ÚrecordrM   ÚtargetÚexcs   &&&         r   Úchannel_compare_branchri   A   s   € ÷ XÝ@ßOä	Ð Ð!1Ð 2Ð
3Ô4ÙÑ@ÁÓARÓSÐUYÓZ€FÙ(¨À4ÓH€LðÙ&Ð'7À$Ôbˆð �=�=ˆ=Ø�}‰}ÐØ‡~‡~€~Ü�Ð%Ð&Ð&DÀVÇ^Á^ÐDTÐUÔVØ‡|‡|€|ÜÐ& v§|¡| n°AÐ6Ô7ñ ô 
‹×	 Ñ	  Ó	/°6·=±=Ô	@ÜÐ8¸¿¹¸ÀbÐIÔJñ ô 
ˆg˜l¨O¸V¿]¹]ÈFÐSÓ	T×	_Ñ	_ÐcdÔ	dÜÐFÀvÇ|Á|ÀnÐTUÐVÔWÜð Lô 	Mñ
 ô 	Ð0°·±°Ð?Ô@ÜÐ4Ô5Ùøô% ”Z¤×!;Ñ!;Ð<ô ÜÐ*Ð+;Ð*<Ð<MÈcÈUÐSÔTÜ�Š��Šûðús   Á
E< Å< GÆ'G	Ç	Gc               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   r	   r   r   Úboolr   )r   s   "r   r   r   e   s&   € ÷ bñ b 9ð b°Dð b¸Tñ br   c                óT   € \        WR R.4      P                  P                  4       R8H  # )ú	rev-parsez--is-shallow-repositoryÚtrue)r    ÚstdoutÚstrip)r   r	   s   &&r   Úis_shallow_repositoryrq   e   s*   € Ü� Ð-FÐGÓH×OÑO×UÑUÓWÐ[aÑaÐar   c               ó$   € V ^8„  d   QhRRRRRR/# )r   ÚremoterB   r_   r   r   )r   s   "r   r   r   i   s&   € ÷ Bñ B˜Sð B¨#ð B°#ñ Br   c                ó   € RV RV  RV 2# )aZ  Refspec that always writes ``<remote>/<branch>``, whatever ``remote.<remote>.fetch`` says.

Narrow clones (tag-pinned ``--single-branch``, #125112) map only the tag, so a by-name fetch
writes FETCH_HEAD and never the tracking ref the updater resolves. The ``+`` is load-bearing:
on a depth-1 clone the new tip is not a descendant of the old one.
z+refs/heads/z:refs/remotes/Ú/r   )rs   r_   s   &&r   Útracking_refspecrv   i   s   € ð ˜&˜ °¨x°q¸¸ÐAÐAr   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   r   r   r	   r   Ú
depth_argsrs   rB   r_   r   )r   s   "r   r   r   s   s0   € ÷ )ñ )�Ið ) Tð )°yð )È#ð )ÐWZñ )r   c           	     ó†   € \        R V R24       \        WR.VOVN\        W44      N3/ \        4       P	                  4       B # )u   â†’ Fetching from z...Úfetch)r/   r    rv   r%   Ú_no_prompt_git_kwargs)r   r	   rx   rs   r_   s   &&&&&r   Ú_fetchr|   s   sQ   € Ü	Ð˜v˜h cÐ
*Ô+ÜØ˜ÐW *ÐW¨fÐWÔ6FÀvÓ6VÐWñ)ä
‹%×
%Ñ
%Ó
'ñ)ð )r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r   r   r	   r   r_   rB   rx   r   )r   s   "r   r   r   z   s/   € ÷ qñ q )ð q°4ð qÀð qÐR[ñ qr   c           	     ó  a€ VR8X  dF   \        V S. R
O4      P                  ^ 8X  d(   \        V SVRV4      pVP                  ^ 8X  d   VRV 23# ^ RIHp \        R4       V! V3R lV R.VORN\        RV4      NS4      R	V 23# )aC  Fetch only ``branch`` and return ``(fetch_result, compare_ref)``.

A bare ``git fetch <remote>`` pulls every ref, and this repo has thousands of auto-generated
branches. ``main`` prefers upstream as the canonical reference; other branches go straight
to origin, because a fork's branch usually has no upstream counterpart.
ÚmainÚupstreamz	upstream/)Ú!fetch_with_partial_clone_recoveryu   â†’ Fetching from origin...c                óL   <€ \        V SV3/ \        4       P                  4       B # )N)r    r%   r{   )ÚgcÚar	   s   &&€r   Ú<lambda>Ú&fetch_compare_branch.<locals>.<lambda>‹   s   ø€ ”d˜2˜t QÑH¬#«%×*EÑ*EÓ*GÒHr   rz   Úoriginúorigin/)rs   zget-urlr€   )r    re   r|   r.   r�   r/   rv   )r   r	   r_   rx   Úfetch_resultr�   s   &f&&  r   Úfetch_compare_branchrŠ   z   sª   ø€ ð �Ôä�˜Ò@ÓA×LÑLÐPQÔQÜ! '¨4°¸ZÈÓPˆLØ×&Ñ&¨!Ô+Ø# y°°Ð%9Ð9Ð9ÝDä	Ð
'Ô(Ù,ÜHØ�'ÐU˜JÐU¨ÐUÔ2BÀ8ÈVÓ2TÐUÐW[ó]à`gÐhnÐgoÐ^pðqð qr   c               ó    € V ^8„  d   QhRRRR/# r'   r   )r   s   "r   r   r   �   s   € ÷ Yñ Y ð Y¨ñ Yr   c                ó–   € ^ RI HpHp V! V 4      pV'       d   \        RV R24       V! V 4      pV'       d   \        RV R24       R# R# )zÏDrop the stale ``.git/shallow`` grafts a depth-1 fetch leaves behind.

Git never removes old grafts; unpruned, the file keeps growing and merge-base / the
orphan-divergence heuristic stop working (#105951).
)Úprune_stale_shallow_graftsÚ repair_broken_shallow_boundariesz  (restored z broken shallow boundary(ies))z
  (pruned z4 stale shallow graft(s) left by past depth-1 checks)N)r.   r�   rŽ   r/   )r	   r�   rŽ   ÚrepairedÚpruneds   &    r   Úrepair_shallow_graftsr‘   �   sK   € ÷ `á/°Ó5€HßÜ�˜X˜JÐ&DÐEÔFÙ'¨Ó-€FßÜ�
˜6˜(Ð"VÐWÖXñ r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   r   r   r	   r   Úcompare_branchrB   r   rk   r   )r   s   "r   r   r   Ÿ   s.   € ÷ eñ e 	ð e°ð eÀsð eÈtñ er   c                ó<   € \        WR RRV.4      P                  ^ 8H  # )rm   z--verifyz--quiet)r    re   )r   r	   r“   s   &&&r   Úcompare_ref_existsr•   Ÿ   s$   € ä� ¨Z¸ÀNÐSÓT×_Ñ_ÐcdÑdÐdr   c               ó(   € V ^8„  d   QhRRRRRRRR/# ©	r   r   r   r	   r   r“   rB   r   r(   r   )r   s   "r   r   r   ¤   s/   € ÷ Añ A Ið A°Tð AÈ3ð AÐSWñ Ar   c           	     óÄ  € \        WRR.4      P                  P                  4       p\        WRV.4      P                  P                  4       pV'       d   V'       d   W48X  d   \        R4       R# ^ RIHp ^ RIHp V! W44      pV^ 8X  d   \        R4       R# Ve"   V^8X  d   RMRp\        R	V R
V RV R24       M\        RV R24       \        RV! 4        R24       R# )zýReport behind-ness without local history across the shallow boundary.

Compares tip SHAs (mirrors the banner's ``_check_via_local_git``), then asks the GitHub
compare API for the exact count: the remote graph is complete even when the local one is not.
rm   rT   õ   âœ“ Already up to date.N©Úrecommended_update_command)Ú_github_compare_behindr^   Úcommitsõ   âš• Update available: Ú ú behind rR   u   âš• Update available (behind rS   ú  Run 'ú' to install.)r    ro   rp   r/   rU   r›   Úhermes_cli.source_checkrœ   )	r   r	   r“   Úhead_shaÚ
target_shar›   rœ   ÚcountedÚcommits_words	   &&&      r   Úreport_shallow_verdictr¨   ¤   sÙ   € ô �G K°Ð#8Ó9×@Ñ@×FÑFÓH€HÜ�g k°>Ð%BÓC×JÑJ×PÑPÓR€Jß—J 8Ô#9ÜÐ'Ô(ÙÝ<Ý>á$ XÓ:€GØ�!„|äÐ'Ô(ÙØÒØ#*¨a¤<‘x°YˆÜÐ& w i¨q°°¸hÀ~ÐFVÐVWÐXÕYäÐ-¨nÐ-=¸RÐ@ÔAÜ	ˆGÑ.Ó0Ð1°Ð
?Ö@r   c               ó(   € V ^8„  d   QhRRRRRRRR/# r—   r   )r   s   "r   r   r   ¿   s/   € ÷ 
Añ 
A Yð 
A°dð 
AÈCð 
AÐTXñ 
Ar   c           	     ó  € \        WR RV 2R.RR7      p\        VP                  P                  4       4      pV^ 8X  d   \	        R4       R# V^8X  d   RMRp\	        R	V R
V RV R24       ^ RIHp \	        RV! 4        R24       R# )zrev-listzHEAD..z--countT)Úcheckr™   Nr^   r�   rž   rŸ   r    rR   rš   r¡   r¢   )r    Úintro   rp   r/   rU   r›   )r   r	   r“   Ú
rev_resultÚbehindr§   r›   s   &&&    r   Úreport_rev_list_verdictr¯   ¿   s’   € Ü�g j°F¸>Ð:JÐ2KÈYÐ%WÐ_cÔd€JÜ�×"Ñ"×(Ñ(Ó*Ó+€FØ�„{ÜÐ'Ô(ÙØ%¨œ{‘8°	€LÜ	Ð" 6 (¨!¨L¨>¸À.ÐAQÐQRÐ
SÔTÝ<ä	ˆGÑ.Ó0Ð1°Ð
?Ö@r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r_   rB   ÚrequestÚdictr   Útupler   )r   s   "r   r   r   Ì   s&   € ÷ )Eñ )E cð )E°Dð )EÈuñ )Er   c               ó   € ^ RI Hp ^ RIHp ^ RIHp ^ RIHp ^ RIH	p	H
p
 ^ RIHp \        V RR4      '       d
   R	V 2RR
R3# \        4       P                  4       P                   p\        4       P#                  V 4      pV! V	! V! \%        VR,          4      R,          4      V4      4      p\'        RV 24        V! 4       ;_uu_ 4        V! WÓVV
! WíV4      R7      pRRR4       XP4                  '       dY   \'        RT RTP6                   24       \        T RR4      '       g+   TP9                  RR4      T8X  d   RTRTP6                  /TR&   TP:                  '       dm   \'        RTP<                  '       d   RMR RTP>                   24       TP:                  TR&   TP:                  TP:                  TP<                  TP@                  3# TPB                  f   Q hTPB                  TR&   R	TPB                   2RR
TP@                  3#   + '       g   i     EL5; i  \(        \*        \,        P.                  3 dC   p\'        RT RT R24       T! 4        T! R4       \0        P2                  ! ^4        Rp?EL•Rp?ii ; i)aX  Resolve the update's target before any tree write: ``(target_ref, release_sha,
target_is_head, repository)``; records branch/expected_sha/retirement on ``request``.

``target_is_head`` means an unchosen default subscription is already past the release,
so HEAD itself is the target. Exits 1 (after ``stop()``) when the channel is unresolvable.
)Údeepcopy)rE   )Úretrying_readsrF   rH   )Ú_record_stopr_   Nrˆ   FÚhomezconfig.yamlrK   rL   rN   rO   z. No update was applied.Úchannel_unresolvedrP   rQ   ra   r   ÚoriginalÚdestinationÚchannel_retirementÚReleasezLatest releasez: Úexpected_sha)"Úcopyrµ   rU   rE   Úhermes_cli.release_channelsr¶   rV   rG   rW   rI   rJ   Úhermes_cli.update_cmd_commonr·   Úgetattrr%   Ú_mÚPROJECT_ROOTÚ_update_run_channelr   r/   rX   rY   rZ   r[   r\   r]   r`   ra   r   r^   rb   rc   Ú
repositoryr_   )r
   r_   r±   r   Ústoprµ   rE   r¶   rG   rI   rJ   r·   r	   Úselectedrº   rg   rh   s   &&&$$            r   Úselect_apply_targetrÉ   Ì   s'  € õ åFÝ:Ý@ßOÝ9äˆt�X˜t×$Ò$Ø˜˜Ð! 4¨°Ð4Ð4Ü‹5�8‰8‹:×"Ñ"€DÜ‹u×(Ñ(¨Ó.€HÙ™Ñ'KÜˆW�V�_Ó Õ-ó(/Ø04ó6ó 7€Hä	Ð   
Ð
+Ô,ðÙ×ÕÙ*¨8¸dÙ8MÈhÐbfÓ8gôiˆF÷ ð ‡~‡~€~Ü��X�JÐ<¸V¿^¹^Ð<LÐMÔNÜ�t˜Y¨×-Ò-°(·,±,¸yÈ&Ó2QÐU]Ô2]Ø-7¸À=ÐRX×R`ÑR`Ð,aˆGÐ(Ñ)Ø‡}‡}€}Ü� &§,§, ,‘YÐ4DÐEÀRÈÏÉÀ~ÐVÔWØ"(§-¡-ˆ�ÑØ�}‰}˜fŸm™m¨V¯\©\¸6×;LÑ;LÐLÐLØ�=‰=Ò$Ð$Ð$ØŸ™€GˆHÑØ�V—]‘]�OÐ$ d¨E°6×3DÑ3DÐDÐD÷% ×Ðûô ”Z¤×!;Ñ!;Ð<ô ÜÐ*¨8¨*Ð4EÀcÀUÐJbÐcÔdÙŒÙÐ)Ô*Ü�Š��Šûð	ús6   Â9H ÃHÃH ÈH	ÈH ÈH È I=È;7I8É8I=)Ú__doc__Ú
__future__r   rZ   r\   Úpathlibr   Útypingr   r    r%   r3   r?   ri   rq   rv   r|   rŠ   r‘   r•   r¨   r¯   rÉ   r   r   r   Ú<module>rÎ      sk   ðñõ #ã Û 
Ý Ý õ
òõ+õ$	lõ!õHbõBõ)õqõ*Yõ eõ
Aõ6
A÷)Er   