403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib64/python3.9/site-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib64/python3.9/site-packages/mercurial/__pycache__/subrepo.cpython-39.pyc
a

�+�b��@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Zddlm
Z
ddlmZmZmZddlmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z"ddl#m$Z$m%Z%m&Z&m'Z'da(ej)Z)ej*Z*ej+Z+e j,Z,dd	�Z-d
d�Z.Gdd
�d
ej/�Z0dd�Z1dd�Z2dd�Z3dd�Z4dddd�Z5dd�Z6d(dd�Z7dd�Z8Gdd �d e9�Z:Gd!d"�d"e:�Z;Gd#d$�d$e:�Z<Gd%d&�d&e:�Z=e;e<e=d'�Z>dS))�)�absolute_importN�)�_)�bin�hex�short)�cmdutil�encoding�error�exchange�
logcmdutil�match�merge�pathutil�phases�pycompat�scmutil�subrepoutil�util�vfs)�dateutil�hashutil�procutil�urlutilcCs6t�t�|��}t�|�}|js2t�t�|j��}|S)zU
    get a path or url and if it is a path expand it and return an absolute path
    )	rZurllocalpathr�
expandpath�url�scheme�normpath�abspath�path)rZexpandedpath�u�r!�7/usr/lib64/python3.9/site-packages/mercurial/subrepo.py�_expandedabspath8s

r#cCstt�t|�����dd�S)zEget a unique filename for the store hash cache of a remote repositoryr�)rr�sha1r#�digest)�
remotepathr!r!r"�_getstorehashcachenameCsr(c@seZdZdZdd�ZdS)�SubrepoAbortzEException class used to avoid handling a subrepo error more than oncecOs:|�dd�|_|�dd�|_tjj|g|�Ri|��dS)N�subrepo�cause)�popr*r+r
�Abort�__init__)�self�args�kwr!r!r"r.KszSubrepoAbort.__init__N)�__name__�
__module__�__qualname__�__doc__r.r!r!r!r"r)Hsr)cs�fdd�}|S)Nc
s�z�|g|�Ri|��}Wn�tyB}z|�WYd}~nbd}~0tjy�}z@t|�}|jdtd�|}t||j|t��d��WYd}~n
d}~00|S)N� s(in subrepository "%s"))�hintr*r+)	r)r
r-�
subrelpath�messagerr7�sys�exc_info)r/r0Zkargs�res�exr*Zerrormsg��funcr!r"�decoratedmethodRs��z-annotatesubrepoerror.<locals>.decoratedmethodr!)r?r@r!r>r"�annotatesubrepoerrorQsrAcCs>|rtd�t|�||f}ntd�t|�||f}|�|d�S)Ns� subrepository sources for %s differ
you can use (l)ocal source (%s) or (r)emote source (%s).
what do you want to do?$$ &Local $$ &Remotes� subrepository sources for %s differ (in checked out version)
you can use (l)ocal source (%s) or (r)emote source (%s).
what do you want to do?$$ &Local $$ &Remoter)rr8Zpromptchoice)�ui�sub�dirty�local�remote�msgr!r!r"�
_updatepromptfs����rHc	Cs�|��D]�\}}}t|�D]\}}|��|kr||=q:q|�|���dkrNq|D]:}|��dkrR|�td�|�|��|�|�||��qRqdS)Ns.hg�hgrcs5warning: removing potentially hostile 'hgrc' in '%s'
)	�walk�	enumerate�lower�basename�warnr�join�unlink�reljoin)	rBr�ignore�dirname�dirs�names�i�d�fr!r!r"�	_sanitizeys"���rYcCsd|�d�s d|vs t�|�|kr2t�td�|��t�|j�|�|j	�
|�r`t�td�|��dS)N�~�$�+subrepo path contains illegal component: %ss$subrepo '%s' traverses symbolic link)�
startswithrrr
r-rrZpathauditor�root�wvfs�islink)�reporr!r!r"�_auditsubrepopath�s 
�rbTF)�hg�git�svncCsz|�ddd�s$tjtd�td�d��t�|d�}|�dd||�s\tjtd	�|td�d��|tvrvt�td
�|��dS)N�subrepossallowedTssubrepos not enableds)see 'hg help config.subrepos' for details�r7Fs
%s:alloweds%s subrepos not allowedsunknown subrepo type %s)Z
configboolr
r-r�SUBREPO_ALLOWED_DEFAULTS�get�types)rB�kind�defaultr!r!r"�
_checktype�s�
�rmcCsvddlm}|a|��}t||�|j|}t|j|d�|rX|d|�|�|df}t|d|||dd�|�S)z>return instance of the right subrepo class for subrepo in pathr��hg�rN)	�rorarb�substatermrB�subrevrj)�ctxrZ	allowwdir�allowcreate�hra�stater!r!r"r*�s

r*cCsnddlm}|a|��}t||�|j|}t|j|d�d}|ddkrPd}t|d|||d|fd�S)	z=return an empty subrepo in pctx for the extant subrepo in ctxrrnrp�rcs(0000000000000000000000000000000000000000rT)rqrorarbrrrmrBrj)rtrZpctxrvrarwrsr!r!r"�nullsubrepo�s

ryc@sBeZdZdd�Zdd�Zdd�ZdLdd	�ZdMd
d�ZdNd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dOdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�ZdPd3d4�Zd5d6�ZdQd8d9�Zd:d;�Zd<d=�Zd>d?�Z d@dA�Z!dBdC�Z"dDdE�Z#dRdFdG�Z$e%dHdI��Z&e%dJdK��Z'dS)S�abstractsubrepocCs|��j|_||_||_dS)z�Initialize abstractsubrepo part

        ``ctx`` is the context referring this subrepository in the
        parent repository.

        ``path`` is the path to this subrepository as seen from
        innermost repository.
        N)rarB�_ctx�_path)r/rtrr!r!r"r.�s	zabstractsubrepo.__init__cCsdS)z�Add the hgwebdir entries for this subrepo, and any of its subrepos.

        ``serverpath`` is the path component of the URL for this repo.

        ``webconf`` is the dictionary of hgwebdir entries.
        Nr!�r/Z
serverpathZwebconfr!r!r"�
addwebdirpath�szabstractsubrepo.addwebdirpathcCsdS)z�
        returns true if the repository has not changed since it was last
        cloned from or pushed to a given repository.
        Fr!�r/rr!r!r"�
storeclean�szabstractsubrepo.storecleanFcCst�dS)areturns true if the dirstate of the subrepo is dirty or does not
        match current stored state. If ignoreupdate is true, only check
        whether the subrepo has uncommitted changes in its dirstate.  If missing
        is true, check for deleted files.
        N��NotImplementedError�r/�ignoreupdate�missingr!r!r"rD�szabstractsubrepo.dirtycCs"|j||d�rtd�t|�SdS)z�return reason string if it is ``dirty()``

        Returned string should have enough information for the message
        of exception.

        This returns None, otherwise.
        �r�r�s)uncommitted changes in subrepository "%s"N)rDrr8r�r!r!r"�dirtyreasons�zabstractsubrepo.dirtyreasonNcCs$|j|dd�}|r tj||d��dS)z+raise Abort if subrepository is ``dirty()``Tr�rgN)r�r
r-)r/r�r7r�r!r!r"�
bailifchangedszabstractsubrepo.bailifchangedcCst�dS)zpcurrent working directory base state, disregarding .hgsubstate
        state and working directory modificationsNr��r/r!r!r"�	basestateszabstractsubrepo.basestatecCsdS)z7check if path is a subrepository within this repositoryFr!rr!r!r"�checknestedszabstractsubrepo.checknestedcCst�dS)z�commit the current changes to the subrepo with the given
        log message. Use given user and date if possible. Return the
        new state of the subrepo.
        Nr�)r/�text�user�dater!r!r"�commit"szabstractsubrepo.commitcCstjS)z6returns phase of specified state in the subrepository.)rZpublic�r/rwr!r!r"�phase)szabstractsubrepo.phasecCst�dS)zTremove the subrepo

        (should verify the dirstate is not dirty first)
        Nr�r�r!r!r"�remove-szabstractsubrepo.removecCst�dS)zTrun whatever commands are needed to put the subrepo into
        this state
        Nr�)r/rw�	overwriter!r!r"ri4szabstractsubrepo.getcCst�dS)z/merge currently-saved state with the new state.Nr�r�r!r!r"r:szabstractsubrepo.mergecCst�dS)zhperform whatever action is analogous to 'hg push'

        This may be a no-op on some systems.
        Nr��r/�optsr!r!r"�push>szabstractsubrepo.pushcKsgS�Nr!�r/rBr
�prefix�uipathfn�explicitonlyr�r!r!r"�addEszabstractsubrepo.addcCs|j�d|td�f�dS)Ns%s: %ssaddremove is not supportedr�rBrNr)r/�matcherr�r�r�r!r!r"�	addremoveHszabstractsubrepo.addremovecKsdS�Nrr!)r/r
�fm�
fntemplater�r�r!r!r"�catLszabstractsubrepo.catc	Kst�ggggggg�Sr�)r�status)r/�rev2r�r!r!r"r�Oszabstractsubrepo.statuscKsdSr�r!)r/rB�diffopts�node2r
r�r�r!r!r"�diffRszabstractsubrepo.diffcCsdSr�r!)r/rB�destr�r!r!r"�outgoingUszabstractsubrepo.outgoingcCsdSr�r!)r/rB�sourcer�r!r!r"�incomingXszabstractsubrepo.incomingcCst�dS)zreturn filename iteratorNr�r�r!r!r"�files[szabstractsubrepo.filescCst�dS)z9return file data, optionally passed through repo decodersNr��r/�name�decoder!r!r"�filedata_szabstractsubrepo.filedatacCsdS)zreturn file flagsrxr!)r/r�r!r!r"�	fileflagscszabstractsubrepo.fileflagscCstj|d�S)z,Resolve the fileset expression for this repo��badfn)�matchmod�never)r/�cwd�exprr�r!r!r"�matchfilesetgszabstractsubrepo.matchfilesetcCsdS)z)handle the files command for this subreporr!)r/rB�mr�r��fmt�subreposr!r!r"�
printfileskszabstractsubrepo.printfilesTc

s��dur �fdd�|��D�}n|��}t|�}t|�}|jjtd�|td�|d�}|�d�|D]J}	|�|	�}
d|
vr~dp�d	}d
|
v}|�||	|||�	|	|��|�
�qd|��|S)Ncsg|]}�|�r|�qSr!r!��.0rX�r
r!r"�
<listcomp>qrxz+abstractsubrepo.archive.<locals>.<listcomp>�archiving (%s)�files)�unit�totalr�xi�i��l)r��lenr8rB�makeprogressr�updater��addfiler��	increment�complete)
r/�archiverr�r
r�r�r��relpath�progressr��flags�mode�symlinkr!r�r"�archiveos&�

�
zabstractsubrepo.archivecCsdS)zv
        walk recursively through the directory tree, finding all files
        matched by the match function
        Nr!)r/r
r!r!r"rJ�szabstractsubrepo.walkcCsggfSr�r!�r/r
r�r��dryrun�interactiver!r!r"�forget�szabstractsubrepo.forgetc		Cs|�td�|j�dS)z�remove the matched files from the subrepository and the filesystem,
        possibly by force and/or after the file has been removed from the
        filesystem.  Return 0 on success, 1 on any warning.
        s)warning: removefiles not implemented (%s)r)�appendrr|�	r/r�r�r�Zafter�forcer�r��warningsr!r!r"�removefiles�s�zabstractsubrepo.removefilescOs$|j�td�|d|df�gS)Ns)%s: reverting %s subrepos is unsupported
rrpr��r/rr�patsr�r!r!r"�revert�s��zabstractsubrepo.revertcCs|Sr�r!�r/Zrevidr!r!r"�shortid�szabstractsubrepo.shortidcCsdS)zH
        convert this repository from shared to normal storage.
        Nr!r�r!r!r"�unshare�szabstractsubrepo.unsharecCsdS)a1verify the revision of this repository that is held in `_state` is
        present and not hidden.  Return 0 on success or warning, 1 on any
        error.  In the case of ``onpush``, warnings or errors will raise an
        exception if the result of pushing would be a broken remote repository.
        rr!)r/�onpushr!r!r"�verify�szabstractsubrepo.verifycCst�|j��j�|j��S)z@return vfs to access the working directory of this subrepository)�vfsmodrr{rar_rOr|r�r!r!r"r_�szabstractsubrepo.wvfscCs|j�t|j���|j�S�zCreturn path to this subrepository as seen from outermost repository)r_rQ�reporelpathr{rar|r�r!r!r"�_relpath�szabstractsubrepo._relpath)FF)FF)FN)F)N)NT)F)(r2r3r4r.r~r�rDr�r�r�r�r�r�r�rirr�r�r�r�r�r�r�r�r�r�r�r�r�r�rJr�r�r�r�r�r��
propertycacher_r�r!r!r!r"rz�sL
	







rzcs�eZdZ�fdd�Zedd��Zdd�Zdd�Zd	d
�Ze	dd��Z
d
d�Zdd�Zdd�Z
edd��Zedd��Zedd��Zedd��Zedd��Zedd��ZedZd!d"��Zed[d$d%��Zd&d'�Zd(d)�Zed*d+��Zed,d-��Zed.d/��Zd0d1�Zed\d2d3��Zed4d5��Zed6d7��Zed8d9��Zed:d;��Z ed<d=��Z!d>d?�Z"d@dA�Z#edBdC��Z$ed]dDdE��Z%dFdG�Z&edHdI��Z'edJdK��Z(edLdM��Z)dNdO�Z*dPdQ�Z+edRdS��Z,d^dTdU�Z-e	dVdW��Z.e	dXdY��Z/�Z0S)_�	hgsubrepoc
sHtt|��||�||_|��}|�t�|��}|oD|j�	d|�}t
j�|�}t
j�t
j�
t�|���}	|	|kr�t�td�|��tj|j||d�|_t
j�|jj�t
j�|�kr�t�d||jjf��||��ur�|j��|_|jj|_dD],\}
}|j�|
|�}|r�|j�|
||d�q�|j�ddd	d�|�||d
|�dS)Ns%s/.hgr\��creates9failed to reject unsafe subrepo path: %s (expanded to %s)))�uiscommitsubrepos�subrepor�s_usedassubreposTruer)�superr�r.�_statera�wjoinrZ	localpathr_�exists�osr�normcase�realpathrr
r-rroZ
repository�baseui�_repor^ZProgrammingError�
unfilteredrB�config�	setconfig�	_initrepo)
r/rtrrwru�rr^r�Z	norm_rootZ	real_root�s�k�v��	__class__r!r"r.�s6
�
��
zhgsubrepo.__init__cCst�|jt|�|�dSr�)rr~r�r8r}r!r!r"r~�szhgsubrepo.addwebdirpathcCs8|j���|�|�Wd�S1s*0YdSr�)r��lock�_storecleanrr!r!r"r��szhgsubrepo.storecleancCsJd}|�|�}|�|�D]}|t|d�krd}q4q|rFt|d�du}|S)NTF)�_calcstorehash�_readstorehashcache�next)r/r�cleanZ	itercache�filehashr!r!r"r�s
zhgsubrepo._storecleanccsNd}dt|�V|jj}|D]*}tt�|�|�����}d||fVqdS)z�calculate a unique "store hash"

        This method is used to to detect when there are changes that may
        require a push to a given remote path.)s	bookmarkssstore/phaserootssstore/00changelog.is# %s
�%s = %s
N)r#r�rrrr%Ztryreadr&)r/r'ZfilelistrZrelnamer	r!r!r"r�szhgsubrepo._calcstorehashcCst�|jj�d��S)Nscache/storehash)r�rr�rOr�r!r!r"�_cachestorehashvfs	szhgsubrepo._cachestorehashvfscCst|�}|j�|d�S)z7read the store hash cache for a given remote repository�r)r(rZtryreadlines)r/r'�	cachefiler!r!r"r
szhgsubrepo._readstorehashcachecCs\t|�}|j���6t|�|��}|j}|j||ddd�Wd�n1sN0YdS)z�cache the current store hash

        Each remote repo requires its own store hash cache, because a subrepo
        store may be "clean" versus a given remote repo, but not versus another
        swbT)r�Z
notindexedN)r(r�r�listrr�
writelines)r/r'r
Z	storehashrr!r!r"�_cachestorehashs
zhgsubrepo._cachestorehashcCs0|j��dur|jdS|jd}|j|SdS)zBfetch the context for this subrepo revision, possibly a workingctxNr)r{�revr�r�)r/rr!r!r"�_getctxs

zhgsubrepo._getctxcs�|�j_|�j_|r~dg���fdd�}t�jdd�}t�jddd�}|d|�||krb|d|��jj�d	t�d
�����dS)Ns[paths]
cs,|r(��d||f��j�d||d�dS)Nr
spathsr�)r�rBr�)�key�value��linesr/r!r"�
addpathconfig.sz*hgsubrepo._initrepo.<locals>.addpathconfigF)�abortTsdefaultsdefault-pushrIrx)	r��
_subparent�
_subsource�
_abssourcer�writerZtonativeeolrO)r/�
parentrepor�r�r�defpathZdefpushpathr!rr"r�&s

zhgsubrepo._initrepocKstj||j||||fi|��Sr�)rr�r�r�r!r!r"r�;s
��z
hgsubrepo.addcCs&t�|�}d|d<t�|j||||�S)NTrf)�copyrr�r�)r/r�r�r�r�r!r!r"r�As
zhgsubrepo.addremovecKs6|jd}|j|}tj|j|j|||||fi|��Sr�)r�r�rr�rB)r/r
r�r�r�r�rrtr!r!r"r�Js

��z
hgsubrepo.catcKs�z6|jd}|j|}|j|}|jj||fi|��WStjy�}z>|j�td�|t|�f�t	�ggggggg�WYd}~Sd}~00dS)Nr�*warning: error "%s" in subrepository "%s"
)
r�r�r�r
�RepoLookupErrorrBrNrr8r)r/r�r��rev1Zctx1Zctx2�instr!r!r"r�Rs



��zhgsubrepo.statusc	
Ks�zRt|jd�}|dur t|�}tj||j||j||j||f|dd�|��WnBtjy�}z(|j�t	d�|t
|�f�WYd}~n
d}~00dS)NrT)r�Zlistsubreposr )rr�rZdiffordiffstatr�r
r!rBrNrr8)	r/rBr�r�r
r�r��node1r#r!r!r"r�`s.��	�

��zhgsubrepo.diffNTc
s�|�|jd�|��}�r.�fdd�|D�}|jd}|j|}t�|j|��t�|j|�fg�t�	|||��}|j
D]<}	t||	d�}
t�
|	��}||	d}||
�	||||�7}qz|S)N)rccsg|]}�|�r|�qSr!r!r�r�r!r"r�~rxz%hgsubrepo.archive.<locals>.<listcomp>rT�/)�_getr�r�r�rZ
prefetchfilesrZ
matchfilesrzr�rrr*r�Z
subdirmatcher)
r/r�r�r
r�r�rrtr��subpathr�ZsubmatchZ	subprefixr!r�r"r�ys 

�
zhgsubrepo.archiveFcCsH|jd}|dkr|sdS|jd}||����kr<|s<dS|j|d�S)NrrxT)r�)r�r�Zp1rrD)r/r�r�r��wr!r!r"rD�s

zhgsubrepo.dirtycCs|jd��S�N�.)r�rr�r!r!r"r��szhgsubrepo.basestatecCs|j�|j�|��Sr�)r�Z_checknestedr�rr!r!r"r��szhgsubrepo.checknestedcCsV|�d�s|jd��S|j�dt|��|j�|||�}|sN|jd��St|�S)NTr*scommitting subrepo %s
)rDr�rrB�debugr8r�)r/r�r�r��nr!r!r"r��s
zhgsubrepo.commitcCs|j|p
d��Sr))r�r�r�r!r!r"r��szhgsubrepo.phasecCs0|j�td�t|��t�|j|jjd�dS)N�removing subrepo %s
F)rB�noterr8rorr�Znullidr�r!r!r"r��szhgsubrepo.removecs$|\}}}�jj}|�j��vr:t�j�dks6|��s:dS|�j_t�j����fdd�}t�j�dk�r��jj��|��r�t	�
��r�j�t
d�t���f�|�}z*t	j�jjj|�jjddd�}W|��n
|��0|���_n�|���r*�j�dd	�}	|	�rt�|	�}	|	�j�dd
�d�}
ni}
�j�t
d�t��t���f�|�}z0t	j�jjji|�jjd|
d
�\}}W|��n
|��0|���_�j||dd�����nh�j�t
d�t��t���f�����}
|�}zt��j|�W|��n
|��0|
�r ����dS)NrTcst��ji��Sr�)ro�peerr�r!�r/Zsrcurlr!r"�<lambda>�rxz hgsubrepo._get.<locals>.<lambda>ssharing subrepo %s from %s
F)r�Z	bookmarkssshare�pools
poolnaming)r2smode�cloning subrepo %s from %s
)r��	shareoptsr��pulling subrepo %s from %s
)r�rr�r��sharedrrr�rmtreeroZislocalrBr�rr8Zsharer�r^�closerEr�rrr�hidepasswordZcloner�rr�rZpull)r/rwr��revisionrkrZgetpeerr/r6Zpoolr4�otherZclonedZcleansubr!r0r"r&�s�


���

����	
��

zhgsubrepo._getc
Cs�|�|�}|\}}}|j}|j�d|j�|rn|��}||}	|	��rn|j�td�|dd�|jf�|}|r�t	�
||�nt	�||�dS)Nsgetting subrepo %s
s,revision %s in subrepository "%s" is hidden
rr$)r&r�rBr+r|r��hiddenrNrrZclean_updater�)
r/rwr�Zinrepor�r:rkraZureportr!r!r"ris"

��z
hgsubrepo.getcs������jd��j�d�����������fdd�}�jd}���r���krxt�j�|�����r~|�q�|�n|�dS)Nr*rcs���kr@������kr@�j�dt���t��j�d�n@��kr^�j�dt���n"�j�dt���tj�dd�dS)Nsupdating subrepository "%s"
rsskipping subrepository "%s"
smerging subrepository "%s"
F)Zremind)�branchrBr+r8ror�r�rr!�ZancZcur�dstr/rwr!r"�	mergefunc*s
�
�
�z"hgsubrepo.merge.<locals>.mergefunc)r&r�ZancestorrDrHrB)r/rwr@Zwctxr!r>r"r#s



zhgsubrepo.mergecCs|�d�}|�d�}|�d�}|jd}|j}t|�D]}|�|��|�dkr6dSq6t|jd�}|s�|�|�r�|j�	t
d�t|�t�
|�f�dS|j�	t
d	�t|�t�
|�f�t�|jd|i|�}	z tj|j|	||d
�}
W|	��n
|	��0|�|�|
jS)N�forces
new_branchssshr*rFTs4no changes made to subrepo %s since last push to %s
spushing subrepo %s to %s
)�	newbranch)rir�rr�sortedrCr�rr�rBr�rr8rr9ror/rr8rZcgresult)r/r�r�rBZssh�cZsubsr�Zdsturlr;r<r!r!r"r�Ds8




����
zhgsubrepo.pushcCsTd|vsd|vr2t�|�}|�dd�|�dd�t�|j�}tj||j|||d�S�Nsrevsbranch)r')rr,r�repo_rel_or_abs_sourcer�ror�)r/rBr�r�r'r!r!r"r�gs
zhgsubrepo.outgoingcCsTd|vsd|vr2t�|�}|�dd�|�dd�t�|j�}tj||j|||d�SrE)rr,rrFr�ror�)r/rBr�r�r'r!r!r"r�ps
zhgsubrepo.incomingcCs |jd}|j|}|����Sr�)r�r�Zmanifest�keys)r/rrtr!r!r"r�ys

zhgsubrepo.filescCs2|jd}|j||��}|r.|j�||�}|Sr�)r�r��dataZ
wwritedata)r/r�r�rrHr!r!r"r�s

zhgsubrepo.filedatacCs|jd}|j|}|�|�Sr�)r�r�r�)r/r�rrtr!r!r"r��s

zhgsubrepo.fileflagsc		CsD|j��dur|jd}n|jd}|j|}t�|||||||�Sr�)r{rr�r�rr�)	r/rBr�r�r�r�r�rtrr!r!r"r��s


zhgsubrepo.printfilescCs�|j��dur|jd}n|jd}|j|}|j|||d�g}|jD]t}|�|�}z.|j|||d�}	tj||	|d�}
|�	|
�WqFt
jy�|j�
td�|j�t|�|��YqF0qFt|�dkr�|dSt�|�S)Nrr�s#skipping missing subrepository: %s
r)r{rr�r�r�rrrCr�Zprefixdirmatcherr�r
�LookupErrorrBr�rr_rQr�r�Zunionmatcher)r/r�r�r�rtrZmatchersr'rCZsmZpmr!r!r"r��s(



��zhgsubrepo.matchfilesetcCs|jd}|�|�Sr�)r�rJ)r/r
rtr!r!r"rJ�s
zhgsubrepo.walkc
Cstj|j|j|||d||d�S)NT)r�r�)rr�rBr�r�r!r!r"r��s�zhgsubrepo.forgetc		Cst�|j|j|||||||�	Sr�)rr�rBr�r�r!r!r"r��s�zhgsubrepo.removefilescOsj|j�td�|d�|�d�sN|��}d|d<|d|d<|j|i|��|�d�sf|j|dd	�dS)
N�reverting subrepo %s
r�	no_backupr�rr�dry_runT�r�)rBr�rrir�
filerevertr�r!r!r"r��s

zhgsubrepo.revertcOsH|j|d}|�d�r dg}ng}tj|j|j|g|�Ri|��dS)Nr�allsset:modified())r�rirr�rB)r/r�r�rtr!r!r"rN�s

zhgsubrepo.filerevertcCs|dd�S)Nr$r!r�r!r!r"r��szhgsubrepo.shortidcCsDddlm}|a|j��r0|j�td�|j�t�|j|j�dS)Nrrnsunsharing subrepo '%s'
)	rqror�r6rBr�rr�r�)r/rvr!r!r"r��s

zhgsubrepo.unsharecCs�zd|jd}|j��|}|��r`td�|jt|j���f}|rNt	�
|��n|jj�d|�WdSt	j
y�td�|jt|j���f}|r�t	�
|��n|jj�d|�YdS0dS)Nrs%subrepo '%s' is hidden in revision %ss%s
rs%subrepo '%s' not found in revision %s)r�r�r�r<rr�rr{�noder
r-rBrNr!)r/r�rrtrGr!r!r"r�
s*
��zhgsubrepo.verifycCs|jjS)z.return own wvfs for efficiency and consistency)r�r_r�r!r!r"r_,szhgsubrepo.wvfscCs
t|j�Sr�)r�r�r�r!r!r"r�1szhgsubrepo._relpath)NT)FF)F)N)F)1r2r3r4r.rAr~r�rrr�rrrrr�r�r�r�r�r�r�rDr�r�r�r�r�r&rirr�r�r�r�r�r�r�r�rJr�r�r�rNr�r�r�r_r��
__classcell__r!r!rr"r��s�"














[
 
"










r�cs�eZdZ�fdd�Zd#dd�Zedd��Zd	d
�Zdd�Zd
d�Z	dd�Z
ed$dd��Zdd�Z
edd��Zedd��Zed%dd��Zedd��Zdd�Zedd ��Zd!d"�Z�ZS)&�
svnsubrepocsBtt|��||�||_t�d�|_|js>t�t	d�|j
��dS)Nres+'svn' executable not found for subrepo '%s')r�rRr.r�rZfindexe�_exer
r-rr|�r/rtrrwrurr!r"r.9s�zsvnsubrepo.__init__rxFc	Cs,|jg}i}|j��s6tj|d<|ddvr6|�d�|�|�|durl|j�|j	�
�j|j|�}|�|�t
tj�}|�d�}|r�||d<|d=d|d<tjt�tj|�fd	tjtjtjt�|�d
�|��}	ttj|	���\}
}|��}|�s$|	j�rt�|�p
d|	j��|�r$|j� |d�|
|fS)
N�stdinr)�update�checkout�commits--non-interactive�LC_ALLsLANG�CsLC_MESSAGES���)�bufsize�	close_fds�stdout�stderr�envsexited with code %d�
)!rSrBr��
subprocess�PIPEr��extendr_rQr{raZorigrootr|�dictr	�environri�Popenr�rapplyr�tonativestr�closefds�tonativeenv�maprZ
fromnativeeolZcommunicate�strip�
returncoder
r-rN)r/�commands�filename�failok�cmdZextrakwrr`Zlc_all�pr^r_r!r!r"�_svncommandBsN



�


���	�zsvnsubrepo._svncommandcCsP|jddgdd�\}}t�d|�}|s4t�td���t|�d��t|�d��fS)N�	--version�--quiet)rps
^(\d+)\.(\d+)s cannot retrieve svn tool versionrrp)rt�re�searchr
r-r�int�group)r/�output�errr�r!r!r"�_svnversionps�
zsvnsubrepo._svnversioncCs|j�d�S)N�.svn�r_r�r�r!r!r"�_svnmissingzszsvnsubrepo._svnmissingcCs�|�ddg�\}}tjj�|�}|�d�}d\}}|rxt�|d�d��pLd}|d�d�}|rxt�|d�d��pvd}||fS)	Nsinfo�--xml�entry)�0r�rr:r�r�)	rt�xml�dom�minidom�parseString�getElementsByTagNamer�bytestr�getAttribute)r/r{r|�doc�entries�lastrevrZcommitsr!r!r"�_wcrevs}s
�zsvnsubrepo._wcrevscCs|��dS)Nr)r�r�r!r!r"�_wcrev�szsvnsubrepo._wcrevc
Cs|�ddg�\}}ggg}}}tjj�|�}|�d�D]�}|�d�}|sNq:|d�d�}	|d�d�}
|�d��d	�}|	d
kr�|�|�n|	dkr�|�|�|	dvs�|
d
vr:|�|�q:|D]<}|D]2}||ks�|�	|t
j�r�ddt|�fSq�q�t|�dt|�fS)z�Return (changes, extchanges, missing) where changes is True
        if the working directory was changed, extchanges is
        True if any of these changes concern an external entry and missing
        is True if any change is a missing entry.
        �statusr�r�z	wc-statusr�item�propsr�utf8�externalr�)rq�normalZunversionedr�)rqZnoner�TF)
rtr�r�r�r�r�r��encoder�r]rZossep�bool)
r/r{r|Z	externalsZchangesr�r��er�r�r�r�extr!r!r"�
_wcchanged�s4

���
zsvnsubrepo._wcchangedcCsT|��r|jddkS|��}|dp0|o0|d}|sP|jd|��vsL|rPdSdS)NrrxrrpFT)r�r�r�r�)r/r�r�Z	wcchanged�changedr!r!r"rD�szsvnsubrepo.dirtycCsP|��\}}||krLz"|�dd|jd|fg�|WStjyJYn0|S)N�list�%s@%sr)r�rtr�r
r-)r/r�rr!r!r"r��s�zsvnsubrepo.basestatec
Cs�|��\}}}|s|��S|r,t�td���|r>t�td���|�dd|g�\}}|j�|�t�	d|�}	|	s�|�
�s�t�td���t�|��d��|	��d}	|j�|�d	d
|	g�d�|	S)Nscannot commit svn externalss!cannot commit missing svn entriesrX�-msCommitted revision ([0-9]+).sfailed to commit svn changesr[rrV�-r)
r�r�r
r-rrtrBr�rwrxrm�
splitlines�groups)
r/r�r�r�r�Z
extchangedr�Z
commitinfor|Znewrevr!r!r"r��s"zsvnsubrepo.commitcCs�|��r"|j�td�|j�dS|j�td�|j�|jjdd�z"|j�	�j}|�
|�|j��WntyzYn0dS)N�-not removing repo %s because it has changes.
r-T)Zforcibly)
rDrBrNrr|r.r_r7r{ra�
removedirsrS�OSError)r/Zpwvfsr!r!r"r��s��zsvnsubrepo.removecCs�|r|�ddg�dg}|jdkr,|�d�|�d|d|df�t�|d�|j|d	d
�\}}t|j|jd�t�	d|�s�d
|vr�|�
�dd�dkr�|��|j|dd�dSt
�|p�|��d��|j�|�dS)Nsrevert�--recursiverW)r��--forcer�rrT)rqr~sChecked out revision [0-9]+.s-is already a working copy for a different URLrp)FFFrMr[)rtr}r�r�checksafesshrYrBr_rwrxr�r�rir
r-r�r�)r/rwr�r0r�r|r!r!r"ri�s$

�zsvnsubrepo.getcCsX|jd}|d}|��}||krT||kp4|��d}t|j||||�rT|�|d�dS)NrrF)r�r�r�rHrBri)r/rw�old�newZwcrevrDr!r!r"rs
zsvnsubrepo.mergecCsdS)NTr!r�r!r!r"r�$szsvnsubrepo.pushcCs�|�gd��d}tjj�|�}g}|�d�D]N}t�|�d��}|dkrLq.d�	dd�|�d	�dj
D��}|�|�d
��q.|S)N)r�r�r�rr�rksfilerqcss |]}|j|jkr|jVqdSr�)ZnodeTypeZ	TEXT_NODErH)r�rDr!r!r"�	<genexpr>1s�z#svnsubrepo.files.<locals>.<genexpr>r�r�)
rtr�r�r�r�r�rr�r�rOZ
childNodesr�r�)r/r{r��pathsr�rkr�r!r!r"r�(s
�zsvnsubrepo.filescCs|�dg|�dS)Nscatr)rtr�r!r!r"r�9szsvnsubrepo.filedata)rxF)FF)F)r2r3r4r.rtr�r}r�r�r�r�rArDr�r�r�rirr�r�r�rQr!r!rr"rR8s.	
.
	%



	
rRcs\eZdZ�fdd�Zdd�Zedd��Zedd��ZdFdd�ZdGd
d�Z	dHdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�ZedId)d*��Zd+d,�ZedJd-d.��Zed/d0��Zed1d2��Zed3d4��Zed5d6��Zed7d8��ZdKd:d;�Z ed<d=��Z!ed>d?��Z"ed@dA��Z#edBdC��Z$dDdE�Z%�Z&S)L�
gitsubrepocs>tt|��||�||_|���|�|_|��|_|��dSr�)	r�r�r.r�rar��_abspathr�
_ensuregitrTrr!r"r.>s

zgitsubrepo.__init__c
Cs~zd|_|�dg�\}}W�nt�y}z�td�}td�}|jtjkrht�||jt	�
|j�f��n�tj
r�zd|_|�dg�\}}Wnfty�}zN|jtjkr�tjtd�|j|d��nt�||jt	�
|j�f��WYd}~n
d}~00ntjtd�|j|d��WYd}~n
d}~00|�|�}|d	k�rF|j�td
��n4|dk�r`t�td���n|d
k�rz|j�td��dS)Nrdrus(error executing git for subrepo '%s': %ss'check git is installed and in your PATHsgit.cmds1couldn't find 'git' or 'git.cmd' for subrepo '%s'rgs"couldn't find git for subrepo '%s'�unknownscannot retrieve git version
�aborts,git subrepo requires at least 1.6.0 or later�warnings-git subrepo requires at least 1.6.0 or later
)�_gitexecutable�	_gitnodirr�r�errno�ENOENTr
r-r|r	Z
strtolocal�strerrorrZ	iswindows�
_checkversionrBrN)r/�outr|r�ZgenericerrorZnotfoundhint�e2Z
versionstatusr!r!r"r�EsT����	���


�
zgitsubrepo._ensuregitcCsjt�d|�}|r8t|�d��t|�d��t|�d��fSt�d|�}|rft|�d��t|�d��dfSdS)Ns ^git version (\d+)\.(\d+)\.(\d+)rrp�s^git version (\d+)\.(\d+)rr[)rwrxryrz)r�r�r!r!r"�_gitversionrs(zgitsubrepo._gitversioncCs2t�|�}|dkrdS|dkr"dS|dkr.dSdS)a�ensure git version is new enough

        >>> _checkversion = gitsubrepo._checkversion
        >>> _checkversion(b'git version 1.6.0')
        'ok'
        >>> _checkversion(b'git version 1.8.5')
        'ok'
        >>> _checkversion(b'git version 1.4.0')
        'abort'
        >>> _checkversion(b'git version 1.5.0')
        'warning'
        >>> _checkversion(b'git version 1.9-rc0')
        'ok'
        >>> _checkversion(b'git version 1.9.0.265.g81cdec2')
        'ok'
        >>> _checkversion(b'git version 1.9.0.GIT')
        'ok'
        >>> _checkversion(b'git version 12345')
        'unknown'
        >>> _checkversion(b'no')
        'unknown'
        r[r�)rr�rr�)r�rr�sok)r�r�)r��versionr!r!r"r�~s
zgitsubrepo._checkversionNFcCs|j|||d�dS)N)r`�streamr��_gitdir�r/ror`r�r!r!r"�_gitcommand�szgitsubrepo._gitcommandcCs|j||||jd�S)N)r`r�r�)r�r�r�r!r!r"r��s
�zgitsubrepo._gitdirc		CsD|j�d|jd�|�f�|dur.tj��}d|d<d|vrFd|d<d}|jjr`t�	t
jd�}|jjr�t
|�r�|d	d
kr�|�dd�tjt�tj|jg|�d
t�tj|�t�|�tjtj|d�}|r�|jdfS|j����}|��|jd	k�r:|jdk�r:|d	}|dv�r||jfSt�td�||j|jf��||jfS)z�Calls the git command

        The methods tries to call the git command. versions prior to 1.6.0
        are not supported and very probably fail.
        s%s: git %s
r6NrZrYsGIT_ALLOW_PROTOCOLsfile:git:http:https:ssh�wr�diffrs--colorr[)r\r�r`r]r^r_)�cat-file�symbolic-refsgit %s error %d in %s) rBr+r�rOr	rfr�quietr�openr��devnullZ
_colormoder��insertrbrgrhrrir�rkrjrcr^�readrm�waitrnr
r-r)	r/ror`r�r�ZerrpipersZretdata�commandr!r!r"r��sH
��


��zgitsubrepo._gitnodircCs|j�d�S)N�.gitrr�r!r!r"�_gitmissing�szgitsubrepo._gitmissingcCs|�ddg�S)Ns	rev-parse�HEAD�r�r�r!r!r"�	_gitstate�szgitsubrepo._gitstatecCs|�gd��\}}|rd}|S)N)r�r�rvr�)r/�currentr|r!r!r"�_gitcurrentbranch�szgitsubrepo._gitcurrentbranchcCs>|�ddd|g�}|�d�d}|�d�td�}||d�S)Nsremote�shows-nrarsURL: )r��split�indexr�)r/rFr��linerVr!r!r"�
_gitremote�szgitsubrepo._gitremotecCs|�dd|g�\}}|dkS)Nr�s-err�)r/r:r��coder!r!r"�_githavelocally�szgitsubrepo._githavelocallycCs|�d||g�}||kS)N�
merge-baser�)r/Zr1Zr2�baser!r!r"�_gitisancestor�szgitsubrepo._gitisancestorcCs|�gd��dkS)N)�configs--bool�	core.bare�truer�r�r!r!r"�
_gitisbare�szgitsubrepo._gitisbarecCs|�gd��dS)z�This must be run before git diff-index.
        diff-index only looks at changes to file stat;
        this command looks at file contents and updates the stat.)supdate-index�-qs	--refreshNr�r�r!r!r"�_gitupdatestat�szgitsubrepo._gitupdatestatcCs�i}i}|�gd��}|�d�D]X}|�d�\}}|�d�sH|�d�sHq |�d�r^|�d�r^q |||<|�|g��|�q ||fS)zcreturns 2 things:
        a map from git branch to revision
        a map from revision to branches)sfor-each-refs--formats%(objectname) %(refname)rar6srefs/heads/�
refs/remotes/s/HEAD)r�r�r]�endswith�
setdefaultr�)r/�
branch2rev�
rev2branchr�r�r:�refr!r!r"�
_gitbranchmaps ��zgitsubrepo._gitbranchmapc	Csri}|D]d}|�d�rq|�dd�d}|�dd|g�}|r|�dd|g�}||d||�dd�df<q|S)z4return map of remote branch to local tracking branchr�r%rpr�sbranch.%s.remotesbranch.%s.mergesrefs/remotes/%s/%s)r]r�r�)r/�branches�tracking�b�bnamerFr�r!r!r"�_gittrackings
��zgitsubrepo._gittrackingcCs<d|vr.|�d�}|dkr.d|d|�vr.|S||_t|�S)Ns://�:r[r%)�findrr)r/r��colonr!r!r"r)s
zgitsubrepo._abssourcecCs�|��rHt�|�|�|�}|j�td�|j|f�|�d||j	g�|�
|�rVdS|j�td�|j|�d�f�|�dg�|�
|�s�t
�td�||jf��dS)Nr3scloner5�originsfetchs1revision %s does not exist in subrepository "%s"
)r�rr�rrBr�rr�r�r�r�r�r�r
r-)r/r�r:r!r!r"�_fetch2s*

�
��
��zgitsubrepo._fetchcCs^|��r|jddkS|��r"dS|s<|jd|��kr<dS|��|�gd��\}}|dkS)NrrxT��
diff-indexrvr�)r�r�r�r�r�r�)r/r�r�r�r�r!r!r"rDJszgitsubrepo.dirtycCs|��Sr�)r�r�r!r!r"r�Xszgitsubrepo.basestatecs�|\}�}�s���dS��|�����r\��gd������kr���gd��dSn0����kr��r���ddg���gd��dS���\}}��fdd�����fdd�}�|vr�|�dS|�}d}	|D].}
|
d	kr�d	g�dS|	s�|
�d
�s�|
}	q�|	�r�|	g�dS��|���}|d}||v�r\|D]}
|
|v�r@|
}�q\�q@||v�r�|�	dd
�d
}
�d|
|g�n^��
||||��r�||���k�r��||g���dd|g�t�j
�jd�n|�dS)N)r�r�sfalse)�resets--hardr�r�r�csDdg}�r"��ddg�|�d���||�t�j�jd�dS)NrWr�r��-fr�)r�r�rYrBr_)r0rr)r�r/r!r"�checkoutrs
z gitsubrepo.get.<locals>.checkoutcs6�j�td��j��j�td���d�g�dS)Ns1checking out detached HEAD in subrepository "%s"
s5check out a git branch if you intend to make changes
r�)rBrNrr�r!)r�r:r/r!r"�rawcheckout}s���z#gitsubrepo.get.<locals>.rawcheckoutsrefs/heads/masterr�rr%r�s-b�merges--ffr�)r�r�r�r�r�r�r]r�rGr�r�r�rYrBr_)r/rwr�r�rkr�r�r�r�Zfirstlocalbranchr�r�rFrEr!)r�r�r:r/r"ri[s`






zgitsubrepo.getcCsl|��rt�td�|j��ddd|g}tj��}|rB|d|g7}|rVt�	|d�|d<|j
||d�|��S)	N�subrepo %s is missingrXs-ar�s--authors%Y-%m-%dT%H:%M:%S %1%2sGIT_AUTHOR_DATE)r`)r�r
r-rr�r	rfrrZdatestrr�r�)r/r�r�r�rrr`r!r!r"r��s
�zgitsubrepo.commitcs��\}�}��|����d��jdg�������gd��\}}����fdd�}���r�����kr�����jdkp�|dk}t�j�|�jddd��dd��r�|�n|�dS)Nr�rr�csF��kr����n��jdkr2��dd�g�t�j�jd�dS)Nrr�s--no-commitr�)rir�r�rYrBr_r!�r�r:r/rwr!r"r@�s
z#gitsubrepo.merge.<locals>.mergefuncr�)	r�r�r�r�r�rDr�rHrB)r/rwr�rkr�r�r@rDr!r�r"r�s
"�zgitsubrepo.mergec
Csb|�d�}|jdsdS|��r4t�td�|j��|��\}}|jd|vrr||jdD]}|�d�r\dSq\t	�
|�D]*\}}|�d�r||�|jd|�r|dSq|dg}|r�|�d�|�
�}|�r:|�|jd|�s�|j�td�|j�d	S|j�td
�|�dd�d|jf�|�|d
|g�}	|	ddkS|j�td�|j|jdf�d	SdS)NrArTr�srefs/remotes/origin/spushr�s7unrelated git branch checked out in subrepository "%s"
Fs(pushing branch %s of subrepository "%s"
r%rpr�rsDno branch checked out in subrepository "%s"
cannot push revision %s
)rir�r�r
r-rr�r�r]rZ	iteritemsr�r�r�rBrNr�r�r�)
r/r�r�r�r�r�r:rrr��retr!r!r"r��sV




��������zgitsubrepo.pushcs|��rgS|jdddd�}t�}|j|j|j|jfD]}	|�|	�q6|j}
|
�	��
��g}�fdd�tt|
��D�}
|
D]t}��|�}
dg}|
r�|�
d�|js�|
s�|�td�||��||vr�|
r||�
|�q||�d�s||�||g�q||D]}|�td	�||��q�|S)
NT)�unknownrcsg|]}�|�r|�qSr!r!r�r�r!r"r�%rxz"gitsubrepo.add.<locals>.<listcomp>saddr�s
adding %s
rLs%s already tracked!
)r�r��set�modified�added�deletedrr�rrdr�rC�exactr��verboserrir�rN)r/rBr
r�r�r�r�r�Ztracked�lr�ZrejectedrXrr�r!r�r"r�s4




zgitsubrepo.addcCs�|��rdS|��r.|j�td�|j�dS|j�td�|j�|�gd��|j�	�D]6\}}|dkrnq\|t
jkr�|j�|�q\|j�
|�q\dS)Nr�r-)r�r�r�r�)r�rDrBrNrr�r.r�r_Zreaddir�stat�S_IFDIRr7rP)r/rXrkr!r!r"r�:s"��
zgitsubrepo.removeTcCsd}|j\}}|s|S|�||�|jd|gdd�}tj|dd�}	t|�}
|jjtd�|
td�d	�}|�	d�|	D]�}|�
�r�qtt�|j
�}
|r�||
�s�qt|��r�|j}n.|	�|�}|r�|��}n|j�td
�|
�qt|�||
|j|��|�|d7}|��qt|��|S)NrsarchiveT)r�zr|)Zfileobjr�r�r�)r�sskipping "%s" (unknown type)r)r�r�r��tarfiler�r8rBr�rr��isdirr�fsencoder�ZissymZlinknameZextractfiler�rNr�r�r�r�)r/r�r�r
r�r�r�r:Z	tarstream�tarr�r��infor�rHrXr!r!r"r�Ps<
�



zgitsubrepo.archivec
Ksx|jd}|��rdS|��s"dS|��D]H}|�dd||fg�}tj|j||j�||�d�}	|	�	|�|	�
�q*dS)Nrr�s%s:%s)�pathnamer)r�Zanypatsr�r�rZmakefileobjr{r_rQrr8)
r/r
r�r�r�r�rrXr{�fpr!r!r"r�vs
�

zgitsubrepo.catc	KsZ|jd}|��s|s,t�ggggggg�Sggg}}}|��|rXddd||g}n
dd|g}|�|�}|�d�D]t}	|	�d�}
|
dkr�qv|	|
d|
�|	|
dd�}}|d	kr�|�|�qv|d
kr�|�|�qv|dkrv|�|�qvggggf\}
}}}gd�}|�	d
��r|dg7}|�	d��r4|dg7}|�|�}t
�}|�|�|�|�|�|�|�d�D]�}	|	�sz�ql|	dd�}|	�d�dk�r�|	dd��d�\}}n|	dd�}d}|�|�|�r�|�|�|dk�r�|�|�n|dk�rl|�|��ql|�	d��rD|�dg�}|�d�D]}||v�r(|�|��q(t�||||
|||�S)Nrs	diff-tree�--no-renamesr�r�ra�	r[�M�A�D)r�s--porcelains-zrs--untracked-files=all�ignoreds	--ignored�rrpr�s??s!!rsls-files)
r�r�rr�r�r�r�r�r�rirr�r�)r/r�r�r"rr�removedr�r�r�Ztabr�rXrrrrZchangedfiles�stZ	filename1�	filename2r!r!r"r��sl



"










�zgitsubrepo.statusc
KsT|jd}ddg}|dr&|�d�n|�d|j�|jrT|�d|d|g�n|�d	|d
|g�|jrz|�d�|jr�|�d�|�|�d
g��dkr�|j	r�|�d�|�|�|r�|�|�d}	|�
�r�|	|�|�d7}	nT|�|�}
dd�|
j|
j
|
jfD�}|D]*}||��r|	|�|d|g�d7}	�q|	���rP|�|	�dS)Nrr�rr
s--stats-U%ds--src-prefix=%s/s--dst-prefix=%s/s--src-prefix=a/%s/s--dst-prefix=b/%s/s--ignore-all-spaces--ignore-space-changeru)r��s--ignore-blank-linesrxracSsg|]}|D]}|�qqSr!r!)r�ZsublistrXr!r!r"r��s�z#gitsubrepo.diff.<locals>.<listcomp>s--)r�r��contextZnoprefixrdZignorewsZignorewsamountr�r�Zignoreblanklines�alwaysr�rrrrmr)
r/rBr�r�r
r�r�r$rrr{rr�rXr!r!r"r��sH
��

��



�

zgitsubrepo.diffc	Os�|j�td�|d�|�d�s�|�d�}|j}|D]Z}tj�|j|�}t	�
|j|j|�}|j�td�|tj�
|�f�t�|j�|�|�q6|�d�s�|j|dd�gS)NrJrrKs#saving current version of %s as %s
rLTrM)rBr�rrirr�rrOr|rZ
backuppathrr.r�r�renamer_)	r/rrr�r�r�rUr�Z
parentnameZbaknamer!r!r"r��s$


���
zgitsubrepo.revertcCs|dd�S)Nrr!r�r!r!r"r�szgitsubrepo.shortid)NF)NF)NFN)FF)F)NT)'r2r3r4r.r��staticmethodr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�rArDr�rir�rr�r�r�r�r�r�r�r�r�rQr!r!rr"r�=s\-

#


6	
X


2
&

&

C
1
r�)rcrerd)FT)?Z
__future__rrr�r�rwr
rbr:rZxml.dom.minidomr�Zi18nrrPrrrrqrr	r
rrr
r�rrrrrrrrr�Zutilsrrrrror�r8rr�r#r(r-r)rArHrYrbrhrmr*ry�objectrzr�rRr�rjr!r!r!r"�<module>sh@	
�
exc�

Youez - 2016 - github.com/yon3zu
LinuXploit