
    6hJ                    L   % 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rS SKrS SKJ	r	J
r
Jr  S SKJr  S SKJrJrJrJrJr  S SKJrJr  \R.                  (       a  S SKJr  S SKJr  \R6                  r\R.                  (       a  \S$S
 j5       r\S%S j5       rS r " S S5      r    S&     S'S jjrS(S jrS)S jr  " S S\!5      r" S*         S+S jjr# " S S\!5      r$Sr%S	\&S'    " S S5      r' " S S5      r( " S S5      r) " S S 5      r* " S! S"\+5      r,S,S# jr-g)-    )annotationsN)AnyAnyStrOptional)_)encodingerrorphasespycompatutil)dateutilprocutil)overload)uibytesc                    g N ds    6/usr/lib/python3/dist-packages/hgext/convert/common.py_encodeornoner   2           c                    g r   r   r   s    r   r   r   6   r   r   c                ,    U c  g U R                  S5      $ )Nlatin1)encoder   s    r   r   r   ;   s    y88Hr   c                  R    \ rS rSrS	S jrS rS r\S
S j5       r\SS j5       r	Sr
g)_shlexpy3proxyA   c                    Xl         g r   _l)selfls     r   __init___shlexpy3proxy.__init__B   s    r   c                (    S U R                    5       $ )Nc              3  8   #    U  H  n[        U5      v   M     g 7fr   )r   ).0vs     r   	<genexpr>*_shlexpy3proxy.__iter__.<locals>.<genexpr>F   s     2'Qa  's   r#   r%   s    r   __iter___shlexpy3proxy.__iter__E   s    2$''22r   c                H    [        U R                  R                  5       5      $ r   )r   r$   	get_tokenr/   s    r   r3   _shlexpy3proxy.get_tokenH   s    TWW..011r   c                    U R                   R                  b*  [        R                  " U R                   R                  5      $ g)Ns	   <unknown>)r$   infiler   
strtolocalr/   s    r   r6   _shlexpy3proxy.infileK   s,    77>>%&&tww~~66r   c                .    U R                   R                  $ r   )r$   linenor/   s    r   r:   _shlexpy3proxy.linenoQ   s    ww~~r   r#   N)r&   zshlex.shlexreturnNone)r<   r   )r<   int)__name__
__module____qualname____firstlineno__r'   r0   r3   propertyr6   r:   __static_attributes__r   r   r   r    r    A   s9    32  
  r   r    c                   U c  [        USS9n O*Ub  [        R                  " S5      eU R                  S5      n Ub  [        R
                  " U5      OS n[        R                  " XSS9nUb+  SUl        U=R                  UR                  S5      -  sl        Ub$  U=R                  UR                  S5      -  sl	        [        U5      $ )Nr   )r   s/   shlexer only accepts data or filepath, not bothT)r6   posix)openr	   ProgrammingErrordecoder   strfromlocalshlexwhitespace_split
whitespace	wordcharsr    )datafilepathrN   rM   r6   r&   s         r   shlexerrQ   V   s     |Hx0((B  {{8$080DX""8,$FDt4A!	
))(33	y''11!r   c                H    SS jn[         R                  " U 5      nU" U5      $ )Nc                    [         R                  " U 5      n[        R                  " U5       Vs/ s H  o"R	                  5       S   PM     nnSR                  U5      $ s  snf )Nr   r   )base64encodebytesr   iterbytestr
splitlinesjoin)slinesr&   s      r   	encodeargencodeargs.<locals>.encodeargo   sP    ""1%,4,@,@,GH,Gq",GHxx Is   A)rY   r   r<   r   )pickledumps)argsr[   rY   s      r   
encodeargsr`   n   s!    
 	TAQ<r   c                Z    [         R                  " U 5      n [        R                  " U 5      $ r   )rT   decodebytesr]   loads)rY   s    r   
decodeargsrd   x   s     1A<<?r   c                      \ rS rSrSrg)MissingTool}   r   Nr?   r@   rA   rB   rD   r   r   r   rf   rf   }       r   rf   c                    U=(       d    U n[         R                  " U 5      (       dS  U(       a  [        R                  nO[        nU" [        S5      U-  U=(       a    [        S5      U-  =(       d    S-   5      eg )Ns   cannot find required "%s" tools     (try installing the %s package)r   )r   findexer	   Abortrf   r   )exenameabortdebnameexcs        r   	checktoolrr      so     ;3DC  ++CC!56=Oq!DEOVSVX Y 	Y !r   c                      \ rS rSrSrg)NoRepo   r   Nrh   r   r   r   rt   rt      ri   r   rt   s   SKIPSKIPREVc                  \    \ rS rSrSSSSS\R
                  SS4           SS jjrSrg)commit   NTc                    U=(       d    SU l         U=(       d    SU l        X0l        X@l        U=(       d    / U l        XPl        X`l        U=(       d    0 U l        Xl        Xl	        Xl
        Xl        g )Ns   unknowns   0 0)authordatedescparents
optparentsbranchrevextrasortkeysaverevphasectx)r%   r{   r|   r}   r~   r   r   r   r   r   r   r   r   s                r   r'   commit.__init__   sZ     *
NF		$*[b

r   )r{   r   r   r|   r}   r   r   r~   r   r   r   r   )r{   r   r|   r   r}   r   r   Optional[bytes]r   r>   r<   r=   )r?   r@   rA   rB   r
   draftr'   rD   r   r   r   rx   rx      sd     #'\\  	    
 r   rx   c                      \ rS rSrSr  S       SS jjr S     SS jjrSS jrSS jrS r	S	 r
S
 rS rS rS rS rS rSSS jjrS rSS jrS S jrS S jrS rS rSS!S jjrSrg)"converter_source   zConversion source interfaceNc                B    Xl         X0l        X@l        X l        SU l        g)zeInitialize conversion source (or raise NoRepo("message")
exception if path is not a valid repository)   utf-8N)r   pathrevsrepotyper   )r%   r   r   r   r   s        r   r'   converter_source.__init__   s     		  r   c                    [         R                  " SU5      (       d#  [        R                  " [	        S5      X!4-  5      eg)zkfails if revstr is not a 40 byte hex. mercurial and git both uses
such format for their revision numbering
s   [0-9a-fA-F]{40,40}$s.   %s entry %s is not a valid revision identifierN)rematchr	   rl   r   r%   revstrmapnames      r   checkhexformatconverter_source.checkhexformat   s@     xx/88++CD#$  9r   c                    g r   r   r/   s    r   beforeconverter_source.before       r   c                    g r   r   r/   s    r   afterconverter_source.after   r   r   c                    g)zReturns true if the given targetfile belongs to the source repo. This
is useful when only a subdirectory of the target belongs to the source
repo.Tr   )r%   targetfilenames     r   targetfilebelongstosource*converter_source.targetfilebelongstosource       
 r   c                    g)z*set the map of already-converted revisionsNr   )r%   revmaps     r   	setrevmapconverter_source.setrevmap       r   c                    [         e)z(Return a list of this repository's headsNotImplementedErrorr/   s    r   getheadsconverter_source.getheads       !!r   c                    [         e)zReturn a pair (data, mode) where data is the file content
as a string and mode one of '', 'x' or 'l'. rev is the
identifier returned by a previous call to getchanges().
Data is None if file is missing/deleted in rev.
r   )r%   rn   r   s      r   getfileconverter_source.getfile   s
     "!r   c                    [         e)a  Returns a tuple of (files, copies, cleanp2).

files is a sorted list of (filename, id) tuples for all files
changed between version and its first parent returned by
getcommit(). If full, all files in that revision is returned.
id is the source revision id of the file.

copies is a dictionary of dest: source

cleanp2 is the set of files filenames that are clean against p2.
(Files that are clean against p1 are already not in files (unless
full). This makes it possible to handle p2 clean files similarly.)
r   )r%   versionfulls      r   
getchangesconverter_source.getchanges   s
     "!r   c                    [         e)z$Return the commit object for versionr   )r%   r   s     r   	getcommitconverter_source.getcommit   r   r   c                    g)zGReturn the number of commits in this source.

If unknown, return None.
Nr   r/   s    r   
numcommitsconverter_source.numcommits  r   r   c                    [         e)zTReturn the tags as a dictionary of name: revision

Tag names must be UTF-8 strings.
r   r/   s    r   gettagsconverter_source.gettags	  s
    
 "!r   c                   U(       d  U R                   =(       d    Sn[        U[        5      (       a  UR                  S5      $  UR	                  [
        R                  " U5      5      R                  S5      $ ! [         ak     UR	                  S5      R                  S5      s $ ! [         a:    UR	                  [
        R                  " U5      S5      R                  S5      s s $ f = ff = f)Nr   zutf-8zlatin-1replace)r   
isinstancestrr   rI   r   sysstrUnicodeError)r%   rY   r   s      r   recodeconverter_source.recode  s    }}0Ha88G$$	88HOOH56==gFF 	xx	*11':: xx 99ELL 	s0   3A8 8
C-B%"C-%?C)$C-(C))C-c                    [         e)a  Return the files changed by rev compared to parent[i].

i is an index selecting one of the parents of rev.  The return
value should be the list of files that are different in rev and
this parent.

If rev has no parents, i is None.

This function is only needed to support --filemap
r   )r%   r   is      r   getchangedfiles converter_source.getchangedfiles   s
     "!r   c                    g)z5Notify the source that a revision has been converted.Nr   )r%   r   sinkrevs      r   	convertedconverter_source.converted-  r   r   c                    g)zReturn true if this source has a meaningful, native revision
order. For instance, Mercurial revisions are store sequentially
while there is no such global ordering with Darcs.
Fr   r/   s    r   hasnativeorderconverter_source.hasnativeorder0  s    
 r   c                    g)z7Return true if this source has ability to close branch.Fr   r/   s    r   hasnativecloseconverter_source.hasnativeclose7  s    r   c                    g)zIf rev is a meaningful revision reference in source, return
the referenced identifier in the same format used by getcommit().
return None otherwise.
Nr   r%   r   s     r   	lookuprevconverter_source.lookuprev;  r   r   c                    0 $ )z`Return the bookmarks as a dictionary of name: revision

Bookmark names are to be UTF-8 strings.
r   r/   s    r   getbookmarksconverter_source.getbookmarksB  s	    
 	r   c                    g)z|revstr is a string that describes a revision in the given
source control system.  Return true if revstr has correct
format.
Tr   r   s      r   checkrevformatconverter_source.checkrevformatI  r   r   )r   r   r   r   r   )NN)r   uimod.uir   r   r   r   r<   r=   )s	   splicemap)r   r   r   r   r<   r=   r<   r=   r   )rY   r   r   r   r<   r   )r<   bool)r   r   r<   r   )r?   r@   rA   rB   __doc__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      s    % !%!! ! 	! 
!" /;

&+
	
9""" "" "D r   r   c                  l    \ rS rSrSrSS jrS rS rS rS r	S r
S	 rSS
 jrSS jrS rS rS rSrg)converter_sinkiQ  z"Conversion sink (target) interfacec                6    Xl         X0l        / U l        X l        g)zInitialize conversion sink (or raise NoRepo("message")
exception if path is not a valid repository)

created is a list of paths to remove if a fatal error occurs
laterN)r   r   createdr   )r%   r   r   r   s       r   r'   converter_sink.__init__T  s     	 r   c                    [         e)zyPath to a file that will contain lines
source_rev_id sink_rev_id
mapping equivalent revision identifiers for each system.r   r/   s    r   
revmapfileconverter_sink.revmapfile_  
     "!r   c                    g)zrPath to a file that will contain lines
srcauthor=dstauthor
mapping equivalent authors identifiers for each system.Nr   r/   s    r   
authorfileconverter_sink.authorfilee  s     r   c	                    [         e)a,  Create a revision with all changed files listed in 'files'
and having listed parents. 'commit' is a commit object
containing at a minimum the author, date, and message for this
changeset.  'files' is a list of (path, version) tuples,
'copies' is a dictionary mapping destinations to sources,
'source' is the source repository, and 'revmap' is a mapfile
of source revisions to converted revisions. Only getfile() and
lookuprev() should be called on 'source'. 'full' means that 'files'
is complete and all other files should be removed.
'cleanp2' is a set of the filenames that are unchanged from p2
(only in the common merge case where there two parents).

Note that the sink repository is not told to update itself to
a particular revision (or even what that revision would be)
before it receives the file data.
r   )	r%   filescopiesr~   rx   sourcer   r   cleanp2s	            r   	putcommitconverter_sink.putcommitk  s
    & "!r   c                    [         e)zPut tags into sink.

tags: {tagname: sink_rev_id, ...} where tagname is an UTF-8 string.
Return a pair (tag_revision, tag_parent_revision), or (None, None)
if nothing was changed.
r   )r%   tagss     r   puttagsconverter_sink.puttags  s
     "!r   c                    g)zSet the current branch name. Called before the first putcommit
on the branch.
branch: branch name for subsequent commits
pbranches: (converted parent revision, parent branch) tuplesNr   )r%   r   	pbranchess      r   	setbranchconverter_sink.setbranch  r   r   c                    g)a  Tell the destination that we're using a filemap

Some converter_sources (svn in particular) can claim that a file
was changed in a revision, even if there was no change.  This method
tells the destination that we're using a filemap and that it should
filter empty revisions.
Nr   )r%   actives     r   setfilemapmodeconverter_sink.setfilemapmode  r   r   c                    g r   r   r/   s    r   r   converter_sink.before  r   r   c                    g r   r   r/   s    r   r   converter_sink.after  r   r   c                    g)zmPut bookmarks into sink.

bookmarks: {bookmarkname: sink_rev_id, ...}
where bookmarkname is an UTF-8 string.
Nr   )r%   	bookmarkss     r   putbookmarksconverter_sink.putbookmarks  r   r   c                    [         e)zHReturn False if a rev mentioned in a filemap is known to not be
present.r   r   s     r   hascommitfrommapconverter_sink.hascommitfrommap  s
     "!r   c                    [         e)zThis method is for the special needs for splicemap handling and not
for general use. Returns True if the sink contains rev, aborts on some
special cases.r   r   s     r   hascommitforsplicemap$converter_sink.hascommitforsplicemap  r   r   )r   r   r   r   N)r   r   r   r   r   r   r<   r=   r   )r?   r@   rA   rB   r   r'   r   r   r   r   r   r  r   r   r  r  r  rD   r   r   r   r   r   Q  sB    ,	!""*"H"
"r   r   c                      \ rS rSrSS jrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSSS jjrSS jrSS jr\S 5       rSS jrSS jrSrg)commandlinei  c                    Xl         X l        g r   )r   command)r%   r   r  s      r   r'   commandline.__init__  s    r   c                    g r   r   r/   s    r   preruncommandline.prerun  r   r   c                    g r   r   r/   s    r   postruncommandline.postrun  r   r   c                   [         R                  " U5      nU R                  U/[        U5      -   nUR	                  5        H  u  pV[        U5      S:X  a  UR                  SU-   5        O$UR                  SUR                  SS5      -   5         [        U5      S:X  a  UR                  SU-   5        Ms  US==   SU-   -  ss'   M     U Vs/ s H  n[        R                  " U5      PM     nnU R                  R                  (       d)  US[         R                  " [        R                  5      /-  nS	R!                  U5      nU$ ! [         a     GM  f = fs  snf )
N      -s   --   _r      =s   2>    )r   byteskwargsr  listitemslenappendr   	TypeErrorr   
shellquoter   	debugflagbytestrosdevnullrX   )r%   cmdr_   kwargscmdlinekr,   args           r   _cmdlinecommandline._cmdline  s   %%f-<<%T
2LLNDA1v{tax(uqyyt'<<=q6Q;NN37+BK4!8+K # 8??w8&&s+w?ww  x//

;<<G))G$  ?s   #E4E E
EEc                4    S nU R                   " XA/UQ70 UD6$ )Nc                    [         R                  " [        R                  " U 5      SS[        R                  [         R
                  S9nU$ )NTr#  )shellbufsize	close_fdsstdout)
subprocessPopenr   tonativestrclosefdsPIPE)r3  ps     r   popencommandline._run.<locals>.popen  s=      $$W-"++!A Hr   )_dorun)r%   r1  r_   r2  rD  s        r   _runcommandline._run  s"    	 {{57777r   c                L    U R                   " [        R                  U/UQ70 UD6$ r   )rF  r   popen2r%   r1  r_   r2  s       r   _run2commandline._run2  !    {{8??CA$A&AAr   c                L    U R                   " [        R                  U/UQ70 UD6$ r   )rF  r   popen3rK  s       r   _run3commandline._run3  rN  r   c                    U R                   " U/UQ70 UD6nU R                  R                  SU4-  5        U R                  5          U" U5      U R	                  5         $ ! U R	                  5         f = f)Ns   running: %s
)r6  r   debugr  r  )r%   openfuncr1  r_   r2  r3  s         r   rF  commandline._dorun  s[    --5d5f5&'34	G$LLNDLLNs   A A1c                    U R                   " U/UQ70 UD6nUR                  5       S   nU R                  R                  U5        XTR                  4$ )Nr   )rG  communicater   rT  
returncoder%   r1  r_   r2  rC  outputs         r   runcommandline.run  sG    IIc+D+F+#f||##r   c                    U R                   " U/UQ70 UD6nUR                  R                  5       nUR                  5         U R                  R                  SR                  U5      5        XTR                  4$ Nr   )rG  r=  	readlineswaitr   rT  rX   rY  rZ  s         r   runlinescommandline.runlines  s[    IIc+D+F+##%	chhv&'||##r   c                .   U(       a  U(       aL  U R                   R                  [        S5      U R                  -  5        U R                   R                  U5        [        R
                  " U5      n[        R                  " SU R                  U4-  5      eg )Ns
   %s error:
s   %s %s)r   warnr   r  r   explainexitr	   rl   )r%   statusr[  msgs       r   	checkexitcommandline.checkexit  sh    Q~.=>V$&&v.C++h$,,)<<== r   c                X    U R                   " U/UQ70 UD6u  pEU R                  XT5        U$ r   )r\  ri  r%   r1  r_   r2  r[  rg  s         r   run0commandline.run0  s-    #777v&r   c                x    U R                   " U/UQ70 UD6u  pEU R                  USR                  U5      5        U$ r_  )rb  ri  rX   rl  s         r   	runlines0commandline.runlines0  s8    s<T<V<vsxx/0r   c                p    Sn [         R                  " S5      nUS-  S-
  $ ! [        [        4 a     Nf = f)Ni   
SC_ARG_MAX   r   )r/  sysconfAttributeError
ValueError)r%   argmaxs     r   rx  commandline.argmax  sE     	ZZ-F {Q 
+ 		s   " 55c              /  $  #    [        U R                  " U/UQ70 UD65      nU R                  U-
  nSn/ nU HH  n	[        U	5      S-   n
Xz-   U:  d  [        U5      S:X  a  UR                  U	5        Xz-  nM?  Uv   U	/nU
nMJ     U(       a  Uv   g g 7f)Nr      )r)  r6  rx  r*  )r%   arglistr1  r_   r2  cmdlenlimitnumbytesflfnbs              r   _limit_arglistcommandline._limit_arglist  s     T]]38889f$BB!A|e#s2w!|		"T  H s   BBc                    U R                   " X/UQ70 UD6 H%  nU R                  " U/[        U5      U-   Q70 UD6  M'     g r   )r  rm  r'  )r%   r|  r1  r_   r2  r&   s         r   xargscommandline.xargs/  s@    $$WCDCFCAIIc7T$Z!^77 Dr   )r  r   N)r   r   r  r   r<   r=   r   )r1  r   r_   r   r<   r   )r1  r   r_   r   )r   )r[  r   r<   r=   )r?   r@   rA   rB   r'   r  r  r6  rG  rL  rQ  rF  r\  rb  ri  rm  rp  propertycacherx  r  r  rD   r   r   r   r  r    sc    *8BB$$>

  ""8r   r  c                  V   ^  \ rS rSrSU 4S jjrSU 4S jjrSU 4S jjrSS jrSrU =r	$ )	mapfilei4  c                v   > [         TU ]  5         Xl        X l        S U l        / U l        U R                  5         g r   )superr'   r   r   fporder_read)r%   r   r   	__class__s      r   r'   mapfile.__init__5  s/    	


r   c                F  > U R                   (       d  g  [        U R                   S5      n [        U5       Hs  u  p#UR	                  5       S   R                  5       nU(       d  M/   UR                  SS5      u  pEX@;  a  U R                  R                  U5        [        TU ]9  XE5        Mu     UR                  5         g ! [         a     g f = f! [         a2    [        R                  " [        S5      U R                   US-   4-  5      ef = f! UR                  5         f = f)Nrbr   r%  r   s/   syntax error in %s(%d): key/value pair expected)r   rG   FileNotFoundError	enumeraterW   rstriprsplitrw  r	   rl   r   r  r*  r  __setitem__close)r%   r  r   linekeyvaluer  s         r   r  mapfile._read=  s    yy	dii&B	$R=(+224!%T1!5JC ?JJ%%c*#C/ )  HHJ) ! 		 " ++LM99a!e,-  HHJs4   B? :D 'C;3D ?
CC<DD D c                  > U R                   c   [        U R                  S5      U l         U R                   R                  [        R                  " SX4-  5      5        U R                   R                  5         [        TU ]=  X5        g ! [         aQ  n[        R
                  " [        S5      U R                  [        R                  " UR                  5      4-  5      eS nAff = f)Nabs   could not open map file %r: %ss   %s %s
)r  rG   r   OSErrorr	   rl   r   r   r7   strerrorwriter   tonativeeolflushr  r  )r%   r  r  errr  s       r   r  mapfile.__setitem__X  s    77?tyy$/ 	d&&zSL'@ABC'  kk78yy("5"5cll"CDE s   B 
C#ACC#c                j    U R                   (       a"  U R                   R                  5         S U l         g g r   )r  r  r/   s    r   r  mapfile.closee  s"    77GGMMODG r   )r  r  r   r   )r   r   r   r   r<   r=   r   )
r?   r@   rA   rB   r'   r  r  r  rD   __classcell__)r  s   @r   r  r  4  s    6( r   r  c                .    [         R                  " U 5      $ r   )r   makedate)ts    r   makedatetimestampr  k  s    Qr   )r   r   r<   r   )r   r=   r<   r=   )NNNN)rP   r   rN   r   rM   r   )r_   r   r<   r   )rY   r   r<   r   )NTN)
rm   r   rn   r   ro   r   rp   r   r<   r=   )r  floatr<   zdateutil.hgdate).
__future__r   rT   r/  r]   r   rK   r>  typingr   r   r   mercurial.i18nr   	mercurialr   r	   r
   r   r   mercurial.utilsr   r   TYPE_CHECKINGr   r   uimodr  r   r    rQ   r`   rd   	Exceptionrf   rr   rt   rv   __annotations__rx   r   r   r  dictr  r  r   r   r   <module>r     sy   #  	  	      
 
 "" 
    , 
 $!%"&	   	0
	) 	
 ^b
Y	
Y%
Y59
YKZ
Y	
Y	Y 	   <[ [|]" ]"@@8 @8F4d 4n r   