
    6hf                    b   % 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  SSK	J
r
JrJr  SSKJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r'J(r(J)r)J*r*J+r,J-r.  SSK/J0r1  SSK2J3r3J4r4J5r5  \Rl                  (       a  S S	KJ7r7J8r8  \Rr                  r9S
r:S5S jr;S r< " S S5      r=\\(\=S.r>\\\$\%S.r?S r@S6S jrA/ rBS7S jrC     S8S jr0    S9S jrDS rES rF     S:S jrGS rHS rIS7S jrJS7S jrKS rL    S;S jrMS rN          S<S  jrOS5S! jrPS7S" jrQS=S# jrR\RrSS>S$ jrT\TrU\R                  \R                  \R                  \R                  1rZS=S% jr[   S?S& jrS' r\  S=S( jr]S7S) jr^S* r_S+ r`S, ra\b" 5       rcS7S- jrdS7S. jr+S/ re/ S0QrfS1\gS2'    " S3 S45      rhg)@    )annotationsN   )_)hexsha1nodeconstantsshort)	bookmarks
bundlerepocmdutildestutil	discoveryerrorexchange
extensionsgraphmodhttppeer	localrepolock
logcmdutillogexchangemerge
mergestate
narrowspecphasesrequirementsscmutilsshpeerstatichttprepoui	unionrepourlutilverifyvfs)
repository)hashutil
stringutilurlutil)ListTuple	   bookmarksc                  ^ ^^ [        US5      (       a  UR                  US9nOUnUu  pbU(       d&  U(       d  T=(       d    S nT(       a  TS   nXx4$ S nXx4$ T(       a  [        T5      mO/ mUR                  S5      (       d>  U(       a  [        R
                  " [        S5      5      eTR                  U5        TTS   4$ UR                  5        n	U	R                  S0 5      R                  5       mS S S 5        UU U4S jn
U H2  nU
" U5      (       a  M  [        R                  " [        S5      U-  5      e   U(       a  U
" U5      (       d  TR                  U5        TTS   4$ ! , (       d  f       Nz= f)Npeer)remotehiddenr   s	   branchmaps"   remote branch lookup not supportedc                   > U S:X  a@  T(       d  [         R                  " [        S5      5      eTR                  R	                  5       n U T;   a%  TR                  S [        TU    5       5       5        gg)N   .s   dirstate branch not accessiblec              3  8   #    U  H  n[        U5      v   M     g 7fN)r   ).0rs     ./usr/lib/python3/dist-packages/mercurial/hg.py	<genexpr>1addbranchrevs.<locals>.primary.<locals>.<genexpr>k   s     D(C1A(Cs   TF)r   Abortr   dirstatebranchextendreversed)r:   	branchmaplreporevss    r5   primaryaddbranchrevs.<locals>.primarye   s^    T>kk!$E"FGG^^**,FYKKD61B(CDD    s   unknown branch '%s')hasattrr-   listcapabler   r8   r   appendcommandexecutorcallcommandresultRepoLookupError)r>   otherbranchesr?   r.   r-   
hashbranchxyer@   r:   r=   s   `  `        @r5   addbranchrevsrQ   I   sE   ufzz|z4#JhLDQA t AtDz<<%%++a EFGGJT!W}				1MM,3::<	 
 	 v''*@(AF(JKK  z""KK
#a=) 
 	s   !E&&
E4c                    [         R                  " U 5      n[        R                  " UR                  5      $ ! [         a>  n[
        R                  " U5      n[        R                  " [        S5      X4-  5      eS nAf[         a     gf = f)Ns   invalid path %s: %sF)osstatS_ISREGst_mode
ValueErrorr'   forcebytestrr   r8   r   OSError)pathstrP   msgs       r5   _isfiler]   y   su    (
 WWT] ||BJJ''  C%%a(kk!23tkABB s   8 
B9A;;B
Bc                  <    \ rS rSrSr\SS j5       r\S 5       rSrg)LocalFactory   z:thin wrapper to dispatch between localrepo and bundle repoc                v    [         R                  " [        R                  " U 5      5      n [	        U 5      (       + $ r2   )r"   
expandpathr(   urllocalpathr]   rZ   s    r5   islocalLocalFactory.islocal   s(    w33D9:4=  rB   c                    [         R                  " [        R                  " U5      5      n[	        U5      (       a  [
        nO[        nUR                  " X/UQ70 UD6$ r2   )r"   rb   r(   rc   r]   r
   r   instance)r   rZ   argskwargsclss        r5   rh   LocalFactory.instance   sG    w33D9:4==CC||B6t6v66rB    N)rZ   bytesreturnbool)	__name__
__module____qualname____firstlineno____doc__staticmethodre   rh   __static_attributes__rm   rB   r5   r_   r_      s+    D! ! 7 7rB   r_   )   bundles   union   file)s   https   https   sshs   static-httpc                   [        U [        5      (       a  [        R                  " U 5      nUR                  =(       d    SnU[
        ;   a  [
        U   nUR                    O&U[        ;   a  [        U   nUR                    O[        n[        US5      (       a  UR                  U 5      $ gU R                  R                  SS5        U R                  5       $ )z7return true if repo (or path pointing to repo) is localry   re   Fs'   use obj.local() instead of islocal(obj)s   6.4)
isinstancern   r(   r!   schemepeer_schemes	make_peerrepo_schemesrh   r_   rC   re   r   
deprecwarnlocal)repour}   rk   s       r5   re   re      s    $KK$W\!v&CMM|#v&CLLC3	"";;t$$GGA6J::<rB   c                    [         R                  " USSS9nUR                  5       (       a%  [        R                  " UR                  5       S5      $ [        R                  " XUS9$ )z0open path with open if local, url.open if remoteF)
parsequeryparsefragments   rb)
sendaccept)r(   r!   re   r"   	posixfile	localpathopen)r   rZ   r   pathurls       r5   openpathr      sL    kk$5FG~~g//1599xxZ88rB   c                ~   [        USU 5      n U=(       d    /  H  nU" X5        M     U R                  SS5        [        R                  " S5       n[        R                  " U 5       Hk  u  pVU R                  SSU5        [        USS 5      nU(       d  M.  [        R                  " SU5       nU" X5        S S S 5        Sn	U R                  SXW5        Mm     S S S 5        U R                  SS	W5        UR                  5       (       d  [         H  nU" X5        M     g g ! , (       d  f       Nn= f! , (       d  f       N^= f)
Nr   s	   extensions   - executing reposetup hooks
zall reposetups     - running reposetup for %s
	reposetupzreposetup %rs     > reposetup for %s took %s
s   > all reposetup took %s
)getattrlogr"   timedcmr   r   wirepeersetupfuncs)
r   objpresetupfuncsfallreposetupstatsnamemodulehookstatsr\   s
             r5   _setup_repo_or_peerr      s    	dB	B b 	"
 !FF<9:	o	&*;&11"5LDFF<!BDI6;5Dt\\.$75M 87|S6 6 
' FF<57HI99;;#AbJ $  87 
'	&s+   AD.D.,	D5!D.
D+'D..
D<c                <   [         R                  " U5      R                  nUc  Sn[        R	                  U5      nUc2  U[
        ;   a"  [        R                  " [        S5      U-  5      e[        nUR                  U UUUUS9n[        XUS9  UR                  S5      $ )z1return a repository object for the specified pathry   s   repository '%s' is not localintents
createopts)r   s   visible)r(   r!   r}   r   getr~   r   r8   r   r_   rh   r   filtered)	r   rZ   creater   r   r   r}   rk   r   s	            r5   r%   r%      s     [[%%F~


6
"C
{\!++a ?@4GHH<<
  D >==$$rB   c           	        [        U SU 5      n[        X5      n[        US5      (       a  Un	O[        R                  " USUSS9n	U	R
                  R                  n
U
[        ;   a*  [        U
   nUR                  UU	UUUUS9n[        X5        U$ U	R                  nU(       d  U	R                  n[        UUUUUS9nUR                  XS9nU$ )	z/return a repository peer for the specified pathr   r!   NF)rawlocvalidate_path)r   r   r.   r   )rZ   r.   )r   remoteuirC   r(   rZ   r!   r}   r~   r   r   locr   r%   r-   )uiorrepooptsrZ   r   r   r   r.   r   rui	peer_pathr}   rk   r-   	repo_pathr   s                  r5   r-   r-      s     
4	*B
8
"CtU	LLT$eL	]]!!F6"}}!%  
 	C& K MM	!((I!
 yyiyCKrB   c                    [         R                  " U 5      R                  nU(       d  g[        R                  R	                  [        R                  R                  U5      5      $ )a  return default destination of clone if none is given

>>> defaultdest(b'foo')
'foo'
>>> defaultdest(b'/foo/bar')
'bar'
>>> defaultdest(b'/')
''
>>> defaultdest(b'')
''
>>> defaultdest(b'http://example.org/')
''
>>> defaultdest(b'http://example.org/foo/')
'foo'
rB   )r(   r!   rZ   rS   basenamenormpath)sourcerZ   s     r5   defaultdestr   '  sB      ;;v##D77BGG,,T233rB   c                P   U R                   U R                  :X  a  g[        U S5      (       a  U R                  (       a  U R                  $ U R                  R                  U R                   5      S   n[        R                  " U5      u  p#[        U R                  U5      nX@l        U$ )zuReturns repository object for source repository of a shared repo.

If repo is not a shared repository, returns None.
Nsrcrepor   )

sharedpathrZ   rC   r   r$   splitr(   parseurlr%   r   )r   r   srcurlrL   r   s        r5   sharedreposourcer   =  s~    
 $))#tYDLL|| XX^^DOO,Q/F''/F&)GLNrB   c           	        [        S5      n[        US5      (       a(  UR                  5       c  [        R                  " U5      eO&[        U5      (       d  [        R                  " U5      eU(       d  [        U5      nO [        R                  " X5      R                  n[        U[        5      (       aI  [        R                  " X5      n[        XR                  5      n	UR                  / 4n
[        XU
S5      u  pOUR                  5       n	Sn[        5       nU(       a  UR!                  ["        5        [        U USU	UUS.S9n[%        XUS9  [        X5      n['        XUS9  U$ )	zcreate a shared repositorys!   can only share local repositoriesr   NT)s
   sharedrepos   sharedrelatives   shareditemsr   r   )defaultpath)checkout)r   rC   r   r   r8   re   r   r(   get_clone_path_objr   r|   rn   r%   r:   rQ   setaddsharedbookmarks	postshare_postshareupdate)r   r   destupdater	   r   relativenot_local_msgsource_pathr   rL   revr   shareditemsr4   s                  r5   sharer   P  s0    :;Mvw<<>!++m,, "V__kk-((6"))"377&%  00<R1&&+%g$GX,,.%K(
"''
			A gk22AQ2HrB   c                   [         R                  " U R                  5      n[         R                  " U R                  5      nUR	                  S5      (       d  gSnUR	                  S5      (       a  UR                  S5      nU" SS5       nUR                  S5      nUR                  S5        UR                  U5        UR                  S5        UR                  U5        SSS5        g! , (       d  f       g= f)zcopies the source repo config and prepend it in current repo .hg/hgrc
on unshare. This is only done if the share was perfomed using share safe
method where we share config of source in shares   hgrcNrB   s   wbs#   # Config copied from shared source
   
)vfsmodr$   r   rZ   existsreadwrite)r   srcvfsdstvfscurrentconfigfpsourceconfigs         r5   _prependsourcehgrcr     s     ZZ(FZZ		"F==!!M}}WG,		2{{7+
89


 
 		s   
AC))
C7c                n   UR                  5          [        XUR                  5      nU=(       d    [        R                  " 5          [
        R                  UR
                  ;   a  [        U5        UR                  R                  S5      n[        R                  " X3S-   5        UR
                  R                  [
        R                  5        UR
                  R                  [
        R                  5        [        R                  " U5        SSS5        SSS5        [!        UR"                  UR$                  SS9nUS   nUR&                  n[)        U5       H"  nUR+                  U5      R-                  5         M$     [.        R0                  " U5        U$ ! , (       d  f       N= f! , (       d  f       N= f)zconvert a shared repository to a normal one

Copy the store data to the repo and remove the sharedpath data.

Returns a new repository object representing the unshared repository.

The passed repository object is not usable after this function is
called.
s
   sharedpaths   .oldNF)r   r0   )r   	copystorerZ   r"   nullcontextmanagerr   SHARESAFE_REQUIREMENTr   r$   joinrenamediscardSHARED_REQUIREMENTRELATIVE_SHARED_REQUIREMENTr   writereporequirementsr%   baseuirootsubstatesortedsubunsharer   poisonrepository)r   r   destlock	sharefilenewrepocsubsss           r5   r   r     s4    

 Rtyy12002211T5F5FF #4(m4IKK	w#67%%l&E&EF%%l&N&NO))$/ 3 
. dii>G 	A::DD\	a  t$N9 32 
s$   5F&CFF&
F#	F&&
F4c                ,   U=(       d    U R                   R                  SS5      nU(       a4  SnUR                  R                  S[        R
                  " XC-  5      5        [        R                  U R                  ;   ac  UR                  5          UR                  5          UR                  S5         [        R                  " U5        SSS5        SSS5        SSS5        gg! , (       d  f       N = f! , (       d  f       N)= f! , (       d  f       g= f)a-  Called after a new shared repo is created.

The new repo only has a requirements file and pointer to the source.
This function configures additional shared data.

Extensions can wrap this function and write additional entries to
destrepo/.hg/shared to indicate additional pieces of data to be shared.
   paths   defaults   [paths]
default = %s
r   s   narrow-shareN)r   configr$   r   r"   tonativeeolr   NARROW_REQUIREMENTwlockr   transactionr   copytoworkingcopy)
sourcerepodestrepor   defaulttemplates        r5   r   r     s     GZ]]11(JGG-7D$4$4X5G$HI&&**A*AA^^x}}0D0D1
 ((21
 B1
 1
s<   D C42C#	C4D#
C1-C44
D	>D
Dc                    U(       d  gU R                   R                  [        S5      5        USLa  UnUSS4 H  nUc  M   U R                  U5      n  O   [        U W5        g! [        R
                   a     MB  f = f)zMaybe perform a working directory update after a shared repo is created.

``update`` can be a boolean or a revision to update to.
Ns   updating working directory
Tr      tip)r   statusr   lookupr   rJ   _update)r   r   r   testuprevs        r5   r   r     s    
 GGNN1456T:v.<	KK%E / D% $$ 		s   A$$A<;A<c                "   Sn SnU(       a  [        S5      O
[        S5      nU R                  U[        S5      S9 nSnUR                  5       n[        R                  " UR
                  5      n	[        R                  " U5      n
UR                  R                  5        GH  nU(       a  UR                  S5      (       a  M#  [        R                  R                  U5      nU(       a'  U
R                  U5      (       d  U
R                  U5        U	R                  U5      (       d  M  UR                  S5      (       a6  [        R                  R                  US	5      n[        R                  " X5      n[         R"                  " U	R                  U5      U
R                  U5      XF5      u  pNX~-  nGM     U(       a  U R%                  S
U-  5        OU R%                  SU-  5        SSS5        U$ ! , (       d  f       U$ = f!   ['        U5        e = f)z?copy files from store of srcrepo in destpath

returns destlock
Ns   linkings   copyings   files)unitr   
   phaserootss   datas   locks   linked %d files
s   copied %d files
)r   makeprogress
publishingr   r$   r   storecopylistendswithrS   rZ   dirnamer   mkdirr   r   r"   	copyfilesdebugrelease)r   r   destpathr   hardlinktopicprogressnumsrcpublishingr   r   r   dstbaselockfilens                  r5   r   r     s   
 H!)*q}__U8_5C#..0MZZ 2 23FZZ)F]]++- QZZ%>%>''//!,6==#9#9LL)==##zz'**#%77<<#A#'99V#>"&..AA#KH HC .  -34-341 62 3 652 s0   8H  C'G.'B=G.$	H  .
G=8H  =H   Hc
                   Sn
U(       a  UR                  S5      (       d  [        R                  " [        S5      5      e/ nU HM  nUR	                  5        nUR                  UR                  SSU05      R                  5       5        SSS5        MO     Un
[        R                  R                  U5      n [        R                  " US5        [        R                  " U5      n[        R                  R!                  U5      n["        R"                  " USU-  5         [        R                  R%                  U5      (       a  U R'                  [        S5      U-  5        O-U R'                  [        S5      U-  5        [)        U UUUS	USU	S
9  SSS5        [+        U5      (       a+  [        R,                  " [.        R0                  " U5      5      nOUn[3        XS9n[5        U UUSSUS9n[6        R8                  " UXJS9  [;        UU5        U[=        XU5      4$ ! , (       d  f       GM  = f! [         a     GNjf = f! , (       d  f       N= f)a  Perform a clone using a shared repo.

The store for the repository will be located at <sharepath>/.hg. The
specified revisions will be cloned or pulled from "source". A shared repo
will be created at "dest" and a working copy will be created if "update" is
True.
N   lookupX   src repository does not support revision lookup and so doesn't support clone by revision   keyFs   %s.locks-   (sharing from existing pooled repository %s)
s(   (sharing from new pooled repository %s)
T)r   pullr?   r   streamrd   )r   r   r	   r   )heads)rE   r   r8   r   rG   rF   rH   rI   rS   rZ   r  r"   makedirFileExistsErrorr   r$   r   r   r   r   clonere   abspathr(   rc   r%   r   r   r  r   r-   )r   peeropts	sharepathr   srcpeerr   r  r   r   r  r?   
remoterevsr4   rP   pooldirpoolvfsr   r   	sharerepor   s                       r5   clonewithsharer,    s   & D
y))++1  
A((*a!!MM!"A
 fh +*   ggooi(GWe$ jj!Gww	*H	7J1	277>>)$$IICDxO II>?(J 	 
30 vll7#7#7#?@2.I
H MM(G0Xv&Dt,,,O +*"   
3	2s+   2H6H* A0H;
H'	*
H87H8;
I	c                b   U R                   R                  U5      n[        R                  R                  X5      n[        R                  R	                  U5      (       aQ  [        R                  R	                  U5      (       d  [        R
                  " U5        [        R                  " X45        gg)z8copy a cache from srcrepo to destcachedir (if it exists)N)cachevfsr   rS   rZ   r   r  r"   copyfile)r   dstcachedirfnamesrcfnamedstfnames        r5   
_copycacher4    sm    $$U+Hww||K/H	ww~~hww~~k**HH[!h)  rB   c                
   [        U[        5      (       ar  [        R                  " X5      nUc  [	        XS5      nS=pSU=(       d    / 4nO~[	        XU5      nUR
                  nUR                  U=(       d    / 4nUR                  nOB[        US5      (       a  UR	                  5       nOUnSU=(       d    / 4nUR                  5       =pS=n=n=nnSn [        XUU5      u  nnUc0  [        U5      nU(       a  U R                  [        S5      U-  5        O([        R                  " X5      nUb  UR
                  nOSn[        R                  " U5      n[        R                  " U5      nU(       d  [        R                   " [        S5      5      e["        R$                  " USS9nUR'                  5       (       an  UR)                  5       (       d"  [        R                   " [        S5      U-  5      eUR+                  5       (       a"  [        R                   " [        S	5      U-  5      e0 nS
nU
b  [,        R.                  " U
5        SnUb  [,        R.                  " U5        SnU(       a  U(       a
  U
(       d  S1n
SUS'   U(       a  SUS'   UR1                  S5      (       aS  SUS'   S[2        R4                  " 5       ;   a  U R                  [        S5      5        OU R                  [        S5      5        U	=(       d    0 n	U	R7                  S5      nU	R7                  S5      nU(       Ga  [9        U5      (       Ga  SnUS:X  a   UR;                  5        nUR=                  SSS05      R?                  5       nSSS5        W[@        RB                  :w  a*  [D        RF                  RI                  U[K        U5      5      nOU R                  [        S5      5        OtUS:X  aL  [D        RF                  RI                  U[K        [N        RP                  " U5      RS                  5       5      5      nO"[        RT                  " [        S5      U-  5      eU(       a  U R                  [        S5      5        SnU(       av  [W        U UUUUUUUUUS9
[Y        UUU5        Ub  [Z        R\                  " US5        Ub  UR_                  5         U(       a#  URa                  5       c  UR_                  5         $ $ $ URa                  5       n Un![9        U5      (       a*  [b        Rd                  " [        R                  " U5      5      n![9        U5      (       af  [D        RF                  Rg                  U5      (       a@  [D        RF                  Ri                  [D        RF                  RI                  US5      5      n"U"nOUnS
n#U (       aU  U Rk                  5       (       a@  [9        U5      (       a0  [l        Rn                  " U 5      (       d  U(       + =(       a    U(       + n#U(       a  S
n#U#(       a   U Rq                  S
S9nU#(       GaD  U Ru                  S SS!S"9  [        R                  " U5      n$[v        Rx                  " U UU 5      n%[v        Rz                  " U U$U%S#9  [v        R|                  " U U$5      n&U&R                  5       nU&Rq                  5       nS$S%K@JAn'  U'R                  U U&5        [	        U X5      nU&R                  R                  (       a  S&n([        R                  " U(5      eURa                  5       R                  US'9nURa                  5       Rq                  US'9nU Ru                  S(S!U R                  R                  S)9  GOV [	        U =(       d    U UUSUS*9nU(       a  UR1                  S5      (       d  [        RT                  " [        S+5      5      e/ n)U HM  n*UR;                  5        nU)R                  UR=                  SSU*05      R?                  5       5        SSS5        MO     U)nUS,   nOSnURa                  5       n+U+(       Ga  U(       as  U+R                  5          U+Rq                  5          U+R                  S-5         U+R                  X5        [,        R                  " U+5        SSS5        SSS5        SSS5        [        R                  " U!5      n,[        U,5      n-U+R                  R                  S.S/U-S!5        U(       d  U(       a  S
nOSnS0S0n.U+R                  R                  U.S!5         [        R                  " U+UUUU
UUS19  SSS5        O|U (       aV  U(       a  [        RT                  " [        S25      5      e[        R                  " U UUU R                  R                  5       S39  O[        RT                  " [        S45      5      eSnURa                  5       n&U&(       Ga  [        R                  S5   n/[        R                  " U!5      n,SU,lW        [        U,5      n-U&R$                  R                  S6[b        R                  " U/U--  5      5        U&R                  R                  S.S/U-S!5        U R                  S7S85      (       a  [        R                  " U&U5        U(       Ga  USLa;  UR;                  5        nUR=                  SSU05      R?                  5       nSSS5        Sn0Sn1Ubq  [        U5      S9:X  a	  UU&;   a  Un0OY[        R                  " U&U5      (       a&  [        R                  " U&U5      R                  5       n0OUSLa   U&R                  U5      n0U0c   U&R                  (       a(  U&R                  U&R                  5      n0U&R                  nOU&R                  S:   n0S:nU&U0   R                  5       n2U2S/:X  a  [        S;U-  5      n1O[        S<5      UU24-  n1 U1(       d!  U&U0   R                  5       n2[        S>5      U2-  n1U&R                  R                  U15        [        U&U05        UU&R                  ;   a  [        R                  " U&U5        Ub  [Y        U5        SnUb  [Y        U5        SnU&Rq                  5          U&R                  [        R                  S?9  SSS5        [Y        UUU5        Ub  [Z        R\                  " US5        Ub  UR_                  5         U(       a!  URa                  5       c  UR_                  5         UU4$ ! , (       d  f       G	N= f! [        RL                   a    U R                  [        S5      5         G	Nf = f! [        Rr                   a    S
n# GNOf = f! [         a%    Sn[        RT                  " [        S5      U-  5      ef = f! , (       d  f       GM  = f! , (       d  f       GN'= f! , (       d  f       GN1= f! , (       d  f       GN;= f! , (       d  f       GN;= f! , (       d  f       GN1= f! [        RL                   a     GNf = f! [         aC     U&R                  S/5      n0 GNo! [        RL                   a    U&R                  S=5      n0  GNf = ff = f! , (       d  f       GN= f! [Y        UUU5        Ub  [Z        R\                  " US5        Ub  UR_                  5         U(       a#  URa                  5       c  UR_                  5         f f f = f)@aa  Make a copy of an existing repository.

Create a copy of an existing repository in a new directory.  The
source and destination are URLs, as passed to the repository
function.  Returns a pair of repository peers, the source and
newly created destination.

The location of the source is added to the new repository's
.hg/hgrc file, as the default to be used for future pulls and
pushes.

If an exception is raised, the partly cloned/updated destination
repository will be deleted.

Arguments:

source: repository object or URL

dest: URL of destination repository to create (defaults to base
name of source repository)

pull: always pull from source repository, even in local case or if the
server prefers streaming

stream: stream raw data uncompressed from repository (fast over
LAN, slow over WAN)

revs: revision to clone up to (implies pull=True)

update: update working directory after clone completes, if
destination is local repository (True means update to default rev,
anything else is treated as a revision)

branch: branches to clone

shareopts: dict of options to control auto sharing behavior. The "pool" key
activates auto sharing mode and defines the directory for stores. The
"mode" key determines how to construct the directory name of the shared
repository. "identity" means the name is derived from the node of the first
changeset in the repository. "remote" means the name is derived from the
remote's path/URL. Defaults to "identity."

storeincludepats and storeexcludepats: sets of file patterns to include and
exclude in the repository copy, respectively. If not defined, all files
will be included (a "full" clone). Otherwise a "narrow" clone containing
only the requested files will be performed. If ``storeincludepats`` is not
defined but ``storeexcludepats`` is, ``storeincludepats`` is assumed to be
``path:.``. If both are empty sets, no files will be cloned.
NrB   r-   s   destination directory: %s
s#   empty destination path is not validT)rb   s   destination '%s' already existss   destination '%s' is not emptyFs   path:.s   narrowfiless   shallowfilestores	   lfs-serves   lfsse   (remote is using large file support (lfs), but it is explicitly disabled in the local configuration)
sT   (remote is using large file support (lfs); lfs will be enabled for this repository)
s   pools   modes   identityr  r     0s7   (not using pooled storage: remote appears to be empty)
sA   (not using pooled storage: unable to resolve identity of remote)
s   remotes   unknown share naming mode: %ss1   (pooled storage not supported for narrow clones)
)r  r   r   r  s   .hg)waits   preoutgoings   clone)throwr   )r   r   )streamclonez!dirstate dirty after stream clone)
steal_from   outgoing)r   noder   r  r   s   narrow-cloner   r   )   uis   quietbookmarkmove)r   streamclonerequestedincludepatsexcludepatsdepths2   narrow clone not available for remote destinations)r?   r	   s)   clone from remote to remote not supporteds   clonedr   s   experimentals   remotenames      @s   updating to bookmark %s
s%   updating to bookmark %s on branch %s
r   s   updating to branch %s
)caches)lr|   rn   r(   r   r-   r   r:   r   rC   r!   rQ   r   r   r   rc   r   
InputErrorr   r$   lexistsisdirlistdirr   validatepatternsrE   r   disabledr   re   rG   rH   rI   r   nullidrS   rZ   r   r   rJ   r&   sha1digestr8   r,  r  shutilrmtreecloser   r"   r$  r   realpathcancopyr   	hassecretr   	LockErrorr   r   clone_requirementscreaterepositorymakelocalrepositoryr    r9  
local_copyr9   _dirtyProgrammingErrornodeconstantsnullhexr"  rF   r   setnarrowpatsr   r   	setconfigconfigoverrider   r  push
_bookmarkskeysuimodsamplehgrcspasswdr   r   
configboolr   pullremotenameslenr   isrevsymbol	revsymbolr<  r   _activebookmarkKeyError	branchtipr  r	   activateupdatecachesrepositorymodCACHES_POST_CLONE)3r   r%  r   r   r  r?   r   r  r:   	shareoptsstoreincludepatsstoreexcludepatsrA  src_pathr'  
origsourcerL   srclockr   	destwlockcleandirdestpeerr   	dest_pathdestvfsr   narrow	sharepoolsharenamemoder&  rP   rootnoder   r$  hgdircopydestrootpath	dest_reqsr   r9  r\   r(  r   r   r   
defaulturl	overridesr   r  r   bns3                                                      r5   r#  r#    s   B &%  --b92-G"%%Jfl+H22G!J 26H\\F66""kkmGG&,B'%kkm+
044G4h4XHL&w4Hh<v&D		!:;dBC222<I$ ''##D)%%f-""1%K#LMM**Td3??==??&&89D@  ""&&67$>  
'''(89F'''(89F(8$-; )-J~&.2J*+??<(( "&Jv,,..		M 		= O	MM'*	!g.I+
 002a#$==% &$
 !&( ! 3  #4#;#;;$&GGLLCM$J			!A )+GGLLs8==#8#?#?#AB	 kk67-G 
 		KL !	%!!J 	9-MM(D)MMO(0NN 18{ --/:ll7#7#7
#CDG4==ww~~d##((dF)CD !!$$W--8(DD D
 ",,E,2 LLtHLE"//5L!44RWMI&&&
 !44RFH (I}}H%""7H5 GX4H   ''9,,S11 (..).DI~~',,,AHLL**22  PMr) y11++9   
C 002a"))MM )$*C!"
 %fh 32   "7NN$E

e6G6G'7 ++,<O"44U;	7 KK("1X
""8ZXN!&!%:DA	XX,,YAMM"-3$4$4# BA  ++3  %00557	 kkBC  >>#((3HG$AAHqJLLw(8(8J9N(OPKK!!(J
HM}}_n==++Hg>% 002a#$==% &$
 !&( ! 3 '
 8}*x8/C ( ,,Xx@@ ' 1 1(H E J J L!-%(0(? =<#33$,OOH4L4L$ME%-%=%=F$,$7$7$=E%)F%e_335+%&'Cf'L%MF !""K L!'&-F !%//1B9:R?F""6*%(X000&&x8#!$	" 	
 %%]-L-L%M ! 	9-MM(D)MMO(0NNHk	 32" ,, IIGN ?? f # Pkk!$F"G$"NOOP" 32"7 7  BA` 32. $)#8#8 % $%" $ <<$,$6$6z$BE$44 <$,OOF$;E<<, ! 	9-MM(D)MMO(0NN 18s  I/z t. #t8At. =z >t. B0z -D0z u# -Ez :v  Az #2v2Az w)+w=(w%w-w)5A:z /w;
E6z  #x#A.z x #z 'A1x: z x: )B'z z
.z 
t+&t. ..u z u  z #u=9z <u==z  /v//z 2
w	<	z 
ww
w&	!w))
w83z ;
x
z 
xz x73z 6x77z :
zyz %z>z?z zzz 

zz A&|c                    U(       a  UR                  5       (       a  g U R                  R                  [        S5      UR                  UR
                  UR                  UR                  4-  5        g )NsI   %d files updated, %d files merged, %d files removed, %d files unresolved
)isemptyr   r   r   updatedcountmergedcountremovedcountunresolvedcount)r   r   
quietemptys      r5   
_showstatsr  z  s_    emmooGGNN	7	

 !!	
			
rB   c           	     p    U R                   R                  SS5        [        R                  " U USUSS/US9$ )zUpdate the working directory to node.

When overwrite is set, changes are clobbered, merged else

returns stats (see pydoc mercurial.merge.applyupdates)sB   prefer merge.update() or merge.clean_update() over hg.updaterepo()s   5.7Fs   working copys   destination)branchmergeforcelabelsupdatecheck)r   r   mergemodr  )r   r<  	overwriter  s       r5   
updaterepor    sH     	GGM 0 rB   c                    [         R                  " X   US9n[        XU5        UR                  (       a$  U R                  R                  [        S5      5        UR                  S:  $ )z$update the working directory to noder  s1   use 'hg resolve' to retry unresolved file merges
r   )r  r   r  r  r   r   r   )r   r<  r  r  r   s        r5   r   r     sN    OODJK@EtJ'qNOP  1$$rB   c                ~    [         R                  " X   5      nUR                  S:X  d   eU(       a  [        XU5        g)zAforcibly switch the working directory to node, clobbering changesr   F)r  clean_updater  r  )r   r<  
show_statsr  r   s        r5   cleanr    s8    !!$*-E  A%%%4
+rB   c                |   Uc,  U R                  SS5      nU[        ;  a  [        R                  nU[        ;  a  [	        SU< S[        < S35      eUR                  5          SnSnUc  [        R                  " XS9nUu  p&nS	nU(       a  [        X5      n	OCU[        R                  :X  a%  [        R                  " USS
9  [        R                  n[        XUS9n	U	(       d  U(       a  XaS   R                  5       :X  a  GO[        R                   " X/US   R                  5       5      (       a;  U R#                  UR$                  S5      n
U R'                  [)        S5      U
-  5        GOU R#                  UR$                  S5      n
U R'                  [)        S5      U
-  5        [        R*                  " U5        OX1R,                  ;   aU  X1R$                  :w  a/  U R#                  US5      n
U R'                  [)        S5      U
-  5        [        R.                  " X5        OgU(       a`  UR$                  (       a9  U R#                  UR$                  S5      n
U R'                  [)        S5      U
-  5        [        R*                  " U5        U(       a  [        R0                  " X5        SSS5        U	$ ! , (       d  f       W	$ = f)a  Update the working directory with extra care for non-file components

This takes care of non-file components below:

:bookmark: might be advanced or (in)activated

This takes arguments below:

:checkout: to which revision the working directory is updated
:brev: a name, which might be a bookmark to be activated after updating
:clean: whether changes in the working directory can be discarded
:updatecheck: how to deal with a dirty working directory

Valid values for updatecheck are the UPDATECHECK_* constants
defined in the merge module. Passing `None` will result in using the
configured default.

 * ABORT: abort if the working directory is dirty
 * NONE: don't check (merge working directory changes into destination)
 * LINEAR: check that update is linear before merging working directory
           changes into destination
 * NO_CONFLICT: check that the update does not result in file merges

This returns whether conflict is detected at updating or not.
Ns   commandss   update.checkzInvalid updatecheck value z (can accept )F)r  T)r   r  r0   s   bookmarks.actives   updating bookmark %s
r+   s   (leaving bookmark %s)
s   (activating bookmark %s)
)r   _VALID_UPDATECHECKSr  UPDATECHECK_LINEARrW   r   r   
destupdate_cleanUPDATECHECK_ABORTr   bailifchangedUPDATECHECK_NONEr  r<  r	   r   labelrl  r   r   
deactivaterb  ro  statusotherdests)r   r   r   brevr  r  movemarkfromwarndestupdataretbs              r5   updatetotallyr    s2   4 ii_=11"55K--/1
 	
 
((;F+1(HDH(Ch888%%d%8&77$kBC|Dz00!!$T
8IJJHHT113FG		!56:; HHT11<@		!67!;<$$T*__$+++HHT#67		!9:Q>?t*##HHT11<@		!67!;<  &%%b/O 
R JS 
R Js   "I J,,
J;c                B   U R                  5       n[        R                  " XUS9n[        XE5        UR                  (       a%  UR
                  R                  [        S5      5        O+U(       a$  UR
                  R                  [        S5      5        UR                  S:  $ )zSBranch merge with node, resolving changes. Return true if any
unresolved conflicts.)r  r  sR   use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
s'   (branch merge, don't forget to commit)
r   )r   r  r   r  r  r   r   r   )ctxr  remindr  r   r   s         r5   r   r     sy     88:DNN3F;Et6	
 
qDEF  1$$rB   c                   [         R                  R                  U5      nUR                  5       (       a  UR                  R                  5       nOUS   R                  5       nUR                  R                  [        S5      US S -  5        [        R                  " X   5      nUR                  S:X  d   e[        X5        g )Nr0   s(   aborting the merge, updating back to %s
   r   )mergestatemodr   r   activelocalctxr   r   r   r   r  r  r  r  )r   r   msr<  r   s        r5   
abortmerger  '  s    		!	!	&	&t	,B	yy{{{{  Dz~~GGNN1ABT#2YNO!!$*-E  A%%%trB   c           
     f   [         R                  " X2U/5      n[        U5      n[        U5      S:w  a/  [	        S5      n	U	[        U5      -  n	[
        R                  " U	5      eUS   n
Uc  U
nU
R                  nO[         R                  " U5      nUR                  5       (       a  [        U5      =pO[         R                  " U
R                  5      nUR                  5       (       a  [        R                  R                  nO[        R                  nU" SUR                  U4-  5      Ul        [        U5      =p[!        X5U5      nUR"                  n UR%                  [	        S5      [         R&                  " U5      -  5        U
R(                  UR+                  S/ 5      4n[-        X?UUR+                  S5      5      u  nnU(       a!  U Vs/ s H  nUR/                  U5      PM     nn[0        R2                  " X#UUUR+                  S5      UR+                  S	5      5      u  nnnU(       d(  UR%                  [	        S
5      5        U" 5       U" 5         $ UR5                  S5        [6        R8                  " X/XVS9nU " UUU5        UR#                  5         U" 5         U" 5         gs  snf ! U" 5         f = f)z
Helper for incoming / gincoming.
displaychlist gets called with
    (remoterepo, incomingchangesetlist, displayer) parameters,
and is supposed to contain only code that can't be unified.
r   s<   for now, incoming supports only a single source, %d providedr      %s/%s   comparing with %s
   branch   revrx      forces   no changes found
s   incomingbuffered)r(   get_pull_pathsrD   ri  r   r   r8   r   r!   isabsrn   re   rS   rZ   r   	posixpathr-   rP  r   hidepasswordr:   r   rQ   r   r
   getremotechangespagerr   changesetdisplayer)displaychlistsubreporecurser   r   r   r   r  subpathsrcsr\   rZ   r   r!   pr   rK   	cleanupfnrL   r?   r   r   chlist	displayers                          r5   	_incomingr  6  s5     !!$VH5D:D
4yA~OPs4ykk#7D	hh ++g&==??#Gn,IDHH%Ayy{{77++$--h!&&')::;AF#Ah&IY'EI
		!*+g.B.B3.GGHKK)R!89&tHdhhv>NOh156#ELL%D6#-#>#>eT488I#68J$
 vy IIa-./!# 	 	11t
	 	eVY/# 7 	s'   A9J' J"&A%J' A J' "J' '	J0c           
     F   ^ ^^^ UUUU 4S jnUU4S jn[        XeT TTTUS9$ )Nc            	        > Sn TR                  S5      (       aN  TS    n[        UR                  5       H0  nUR                  U5      n[	        XR                  TTT5      5      n M2     U $ Nr   s   subrepos)r   r   r   r   minincoming)r  r  r  r   r   r   r   r   s       r5   r   incoming.<locals>.subreporecurse{  s_    88K  t*C!#,,/ggg&#||B=> 0 
rB   c                  > [         R                  " T5      nTR                  S5      (       a  UR                  5         SnU H  nUb  XC:  a    g U R                  R                  U5       Vs/ s H  ofT	R                  :w  d  M  UPM     nnTR                  S5      (       a  [        U5      S:X  a  Mp  US-  nUR                  X   5        M     g s  snf )N   newest_firstr   	   no_merges   r   )	r   getlimitr   reverse	changelogparentsrK  ri  show)
rK   r  r  limitcountr  r  r  r   r   s
           r5   displayincoming.<locals>.display  s    ##D)88O$$NNA U^ ??22155adkk9I5   xx%%#g,!*;QJENN58$ s   ,CC)r  )r  )r   r   r   r   r  r  r  s   ````   r5   r  r  z  s.     %  T64 rB   c              #    #    [         R                  " U5      nUR                  S5      nUR                  S5      (       a  UR                  5         Uc  U(       d  U Sh  vN   gSnU R                  nU H`  nUb  XS:  a    gUR                  U5       Vs/ s H  oU R                  :w  d  M  UPM     n	nU(       a  [        U	5      S:X  a  MW  US-  nUv   Mb     g Nzs  snf 7f)z5apply revision filtering/ordering option for outgoingr  r  Nr   r  r   )r   r  r   r  r  r  rK  ri  )
r   r?   r   r  	no_mergesr  clr  r  r  s
             r5   _outgoing_filterr    s     %E&Ixx  }YE	B jjm@mDKK/?1m@W*
  	 As*   AC!C 5C!C,C2)C!C!c           	         SnUR                  S5      (       aM  US    n[        UR                  5       H/  nUR                  U5      n[	        XGR                  XU5      5      nM1     U$ r  )r   r   r   r   r  outgoing)r   r   destsr   r  r  r  r   s           r5   _outgoing_recurser    s\    
Cxx4jcll+G'''"Cc<<489C , JrB   c                    UR                   nUR                  UR                  S9  UR                  S5      (       ae  [        R
                  " XU5      nU R                  S5        [        R                  " XUSS9n[        R                  " XXV[        R                  5        g U R                  S5        [        R                  " XU5      n[        XU5       H&  nUR                  X   5        UR                  5         M(     g )N)key   graphr;  Tr  )r  sortr   r   r   	graphrevsr  r  displaygraphr   
asciiedgesr  r  rP  )r   r   or   r  revdagr  r  s           r5   display_outgoing_revsr    s    	BFFrvvFxx%%dt4
11"D4P	f)<)<	
 	11"DA	!$40ANN47#OO 1rB   c           
        UR                  S5      (       a  [        R                  " / U5        Sn[        R                  " XU5       GHp  nUR
                  n[        US[        5      n Xql        Ub  [        R                  " U5      nUR                  5       (       a  [        U5      nO}[        R                  " U5      n	U	R                  5       (       a  [        R                  R                  n
O[         R                  n
U
" SU	R                  U4-  5      U	l        [        U	5      nUR"                  UR                  S5      =(       d    / 4nU R%                  ['        S5      [        R(                  " U5      -  5        [+        XXR                  S5      5      u  pU(       a6  [        R,                  " X5       Vs/ s H  oU   R/                  5       PM     nn[1        XU5      n [2        R4                  " XXR                  S5      S	9nUR6                  nU(       d-  [8        R:                  " UR<                  UUR>                  5        OS
n[A        XUU5        [B        RD                  " XXU5        [G        U[I        XUR
                  4U5      5      n URK                  5          U[        L a  U?GMj  Xl        GMs     U$ s  snf !   e = f! URK                  5         f = f! U[        L a  U?f Xl        f = f)Nr  r   _subtoppathr  r  r  r  r  )r  r   )&r   r   checkunsupportedgraphflagsr(   get_push_pathsr   r   _no_subtoppathr  r!   r  rn   re   rS   rZ   r   r  r:   r   r   r  rQ   revranger<  r-   r   findcommonoutgoingmissingr   nochangesfoundr   excludedr  r   outgoinghooksr  r  rP  )r   r   r  r   r  r  rZ   r   prev_subtopathr  r   rL   r?   r   r   rK   r  r  s                     r5   r  r    s`   xx--b$7
C&&t7xx }nE5	2#"!++g.==?? >DD)Ayy{{#%77#3#3#,#5#5%h!&&'1B&BCAF 8D{{DHHY$7$=2=HIIa./'2F2Ft2LLM*Hhhv&6ND 0:0C0CD0O0OINN$0O   T*E$77XXh-? $$**477D(:K:KLC)"At<%%bQ? #0DHH;MN /$#1 q 8r JC0/$#1 sD   )EK9J>K$B-KK>KKK		KKK2c           	        [         R                  " XS9nU R                  S[        R                  " U R
                  U R                  5       S5      5      nU(       am  U R                  R                  [        S5      5        U HC  nX   n UR                   H+  n UR                  USS9R                  5       =(       d    UnM-     ME     U$ ! [        R                   a*  nU R                  R                  SXG4-  5         SnAMn  SnAff = f! [         aB    U R                  R                  [        S	5      [!        UR#                  5       5      -  5         M  f = f)
z&verify the consistency of a repository)levels   filelog(%s)s   .hgsubstates   checking subrepo links
F)allowcreates   %d: %s
Ns&   .hgsubstate is corrupt in revision %s
)	verifymodr#   r?   r"   pathtor   getcwdr   r   r   r   r   r   	RepoErrorwarn	Exceptionr   r<  )r   r  r  r?   r   r  r  rP   s           r5   r#   r#     s   


4
-C 99DIIt{{}nMD q456C)C"||G=GGGG?FFHOC   ,   J !?? =[C8%;<<= @ACHHJ'(s=   
D'CDD	D>DD		DAEEc                |   [        U S5      (       a'  U R                  R                  5       nU R                  n OU R                  5       nS HI  nUR	                  U5      =(       d    U R                  SU5      nU(       d  M6  UR                  SX4S5        MK     U R                  SS5      nU(       a  UR                  SSUS5        S H0  nU R                  U5       H  u  pxUR                  XgUS5        M     M2     U R                  SS	5      nU(       a(  UR                  SS	[        R                  " U5      S5        U$ )
z*build a remote ui from ui or repo and optsr   )rz   s	   remotecmdr=  s   copiedrx   s   mainreporoot)s   auths   hostfingerprintss   hostsecuritys
   http_proxys   webs   cacerts)
rC   r   r  r   r   r   r_  configitemsr"   rb   )	srcr   dstr  vr4   sectr  vals	            r5   r   r   1  s    sHjjooffhhj "HHQK/3::eQ/1MM%y1 " 	

9o.Ai!Y? O-HCMM$S)4 . O 	

6:&Afj$//!*<iHJrB   ))spaths   00changelog.i)r  r  )r  s   obsstore)rZ   r+   zList[Tuple[str, bytes]]foic                  0    \ rS rSrSrS rS rS rS rSr	g)	cachedlocalrepoiZ  z6Holds a localrepository that can be cached and reused.c                    [        U[        R                  5      (       d   eXl        U R	                  5       u  U l        U l        UR                  U l        g)zCreate a new cached repo from an existing repo.

We assume the passed in repo was recently created. If the
repo has changed between when it was created and when it was
turned into a cache, it may not refresh properly.
N)	r|   r   localrepository_repo
_repostate_statemtime
filtername_filtername)selfr   s     r5   __init__cachedlocalrepo.__init__]  sC     $	 9 9::::
"&//"3TZ??rB   c                   U R                  5       u  pXR                  :X  a  U R                  S4$ [        U R                  R                  U R                  R                  5       5      nU R                  (       a!  UR                  U R                  5      U l        OUR                  5       U l        Xl        X l	        U R                  S4$ )zRefresh (if necessary) and return a repository.

If the cached instance is out of date, it will be recreated
automatically and returned.

Returns a tuple of the repo and a boolean indicating whether a new
repo instance was created.
FT)
r  r  r  r%   r   r!   r   r   
unfilteredr  )r!  stater  r   s       r5   fetchcachedlocalrepo.fetchi  s     (KK::u$$$**++TZZ^^-=>t'7'78DJ*DJ
zz4rB   c                   / nSn[          H  u  p4[        U R                  U5      n[        R                  R                  XT5      n [        R                  " U5      nUR                  U[        R                     UR                  45        [        X'[        R                     5      nM     [        U5      U4$ ! [         a    [        R                  " U5      n N}f = f)N)r  r   r  rS   rZ   r   rT   rY   rF   ST_MTIMEst_sizemaxtuple)r!  r&  maxmtimeattrr1  prefixr  r[   s           r5   r  cachedlocalrepo._repostate  s    KDTZZ.FV+A%WWQZ LL"T]]+RZZ898%67H  U|X%%  %WWV_%s   B77 CCc                B   [        U R                  R                  U R                  R                  5      nU R                  (       a  UR                  U R                  5      nOUR                  5       n[        U5      nU R                  Ul        U R                  Ul	        U$ )zObtain a copy of this class instance.

A new localrepository instance is obtained. The new instance should be
completely independent of the original.
)
r%   r  r   origrootr   r   r%  r  r  r  )r!  r   r   s      r5   r  cachedlocalrepo.copy  sr     $**++TZZ-@-@A==!1!12D??$DD!;;**rB   )r   r  r  r  N)
rq   rr   rs   rt   ru   r"  r'  r  r  rw   rm   rB   r5   r  r  Z  s    @
+ 8&rB   r  )F)Tr2   )rB   FNNN)FNNF)NTTNF)FNTF)
NFNTFNNNNN)FN)TF)FTN)i
__future__r   rS   r  rN  rT   typingi18nr   r<  r   r   r   rX  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   rd  r    r!   r"   r#   r  r$   r   
interfacesr%   rq  utilsr&   r'   r(   TYPE_CHECKINGr)   r*   r  r   rQ   r]   r_   r   r~   re   r   r   r   r-   r   r   r   r   r   r   r   r   r,  r4  r#  r  r  r   r  r  r  r  r  r  UPDATECHECK_NO_CONFLICTr  r  r  r  r  r  r  r  objectr  r  r   r  __annotations__r  rm   rB   r5   <module>r?     s?   # 	             < 4  

 ,, -`( 7 7&  "	(9  , 
%@ *Z4,, 
3l ,-`3(,%^ 
h-X* 
		
cL"(%  
 $$	 Md 	%., AH>,& =@DB  H HrB   