Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/hgext/transplant.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��c@s�dZddlmZddlZddlZddlmZddlmZm	Z	m
Z
mZddlmZm
Z
mZmZmZmZddlmZmZdejfd	��YZiZeje�Zd
Zdefd��YZd
efd��YZdefd��YZd�Zd�Zedddded�ed�fddged�ed�fddeed�fd d!ged"�ed�fd#d$ged%�ed�fdd&ded'�ed�fd(d)e ed*�fdd+eed,�fd-d.eed/�fdd0ded1�ed2�fg
ed3��d4��Z!d5�Z"d6�Z#d7�Z$e"e#gZ%dS(8sVcommand to transplant changesets from another branch

This extension allows you to transplant changes to another parent revision,
possibly in another repository. The transplant is done using 'diff' patches.

Transplanted patches are recorded in .hg/transplant/transplants, as a
map from a changeset hash to its hash in the source repository.
i�(t_N(tshort(t
bundlerepothgtmergetmatch(tpatchtrevlogtscmutiltutilterrortcmdutil(trevsett
templatekwtTransplantErrorcBseZRS((t__name__t
__module__(((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyRstinternalttransplantentrycBseZd�ZRS(cCs||_||_dS(N(tlnodetrnode(tselfRR((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyt__init__ s	(RRR(((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyRsttransplantscBsGeZdddd�Zd�Zd�Zd�Zd�Zd�ZRS(cCsY||_||_||_|s9tj|j�|_ni|_t|_|j�dS(N(tpathttransplantfiletopenerRRtFalsetdirtytread(RRRR((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyR%s					cCs�tjj|j|j�}|jr�tjj|�r�xr|jj|j�j�D]R}tt	j
|jd��\}}|jj
|g�}|jt||��qRWndS(Nt:(tosRtjoinRtexistsRRt
splitlinestmapRtbintsplitRt
setdefaulttappendR(RtabspathtlineRRtlist((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyR0s"!cCs�|jr�|jr�tjj|j�s:tj|j�n|j|jd�}xe|jj�D]T}xK|D]C}t	t
j|j|j
f�\}}|j|d|d�qlWq_W|j�nt|_dS(NtwRs
(RRRRtisdirtmkdirRRt
itervaluesR#RthexRRtwritetcloseR(RtfpR*tttltr((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyR08s
$!
cCs|jj|�pgS(N(Rtget(RR((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyR6DscCs8|jj|g�}|jt||��t|_dS(N(RR&R'RtTrueR(RRRR*((s4/sys/lib/python2.7/site-packages/hgext/transplant.pytsetGscCs;|jj|j�}|r7||j|�=t|_ndS(N(RR6RtindexR7R(Rt
transplantR*((s4/sys/lib/python2.7/site-packages/hgext/transplant.pytremoveLsN(	RRtNoneRRR0R6R8R;(((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyR$s				ttransplantercBs�eZd�Zd�Zid�Zd�Zeedd�Zd�Z	d�Z
d�Zd�Zd	�Z
ed
�Zd�Zd�Zd
�ZRS(cCs[||_|jd�|_tj|j�|_t|jdd|j�|_d|_dS(NR:RR(tuiR RRRRR<teditor(RR>trepo((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyRSs	c	Cs�t||�r$|jj|�}nt||�rv|jj|�}|jj|g|dt�}||krvtSnx}|jj|�D]i}t||j�s�|jj|�t	S|jj|j�}||jj|g|dt�kr�tSq�Wt	S(smreturns True if a node is already an ancestor of parent
        or is parent or has already been transplantedt	inclusive(
thasnodet	changelogtrevt	ancestorsR7RR6RR;R(	RR@tnodetparentt	parentrevRDt	reachableR3tlnoderev((s4/sys/lib/python2.7/site-packages/hgext/transplant.pytapplied[s"	cCs�t|�}|jj�\}}g}	tj|j|�}
t|
_d}}}
z|j	�}|j
�}|jd�}
x�|D]�}||}d|t|�f}|j
|||�r�|jjtd�|�q�n|jj|�}|jd�p|jd�s�|d|kr8|	j|�|}q�n|	r�||krf|j|j�d|	�ntj||	dttd�|jj�\}}g}	q�nt}||kr�}t||�s�j|d|g�q�t}|d	tjkr�|jd
�s>|jjtd�|t|�f�t}q�|j|d
�}||kr�tjtd�t|�t|�f��q�n
|d}|r�d}nmtj d
d�\}}t!j"|d�}tj#|||d|
�}x|D]}|j$|�q�j%�||=|s'|r�z�yL|j&|||jj'|�|d|d|jd�d|jd��}Wnt(k
r�|
j%��nX|r�|r�|jj)td�|t|�f�n5|r|jj)td�t|�t|�f�nWd|rt!j*|�nXq�q�W|
j%�|	rl|j|j�d|	�tj||	dttd�nWd|j+||�|j,j$�|
r�|
j-�n|j-�|j-�XdS(s:apply the revisions in revmap one by one in revision orderR:s%s:%ss%skipping already applied revision %s
tfiltertlogitheadsi�iRGsskipping merge changeset %s:%s
s%s is not a parent of %stprefixshg-transplant-R+toptsRs%s merged at %s
s%s transplanted to %s
N(.tsortedtdirstatetparentsRtdiffoptsR>R7tgitR<twlocktlockttransactionRRKtwarnRRCR6R'tpulltpeerRtupdateRRBRtnullidtnotetlookupR	tAbortttempfiletmkstempRtfdopentdiffR0R1tapplyoneRRtstatustunlinkt
saveseriesRtrelease(RR@tsourcetrevmaptmergesRPtrevstp1tp2tpullsRTRWRVttrRDRFtrevstrRStdomerget	skipmergeRGt	patchfiletfdR2tgentchunktn((s4/sys/lib/python2.7/site-packages/hgext/transplant.pytapplyqs�	


	"
	



	
$


c
Csc|jjtd�|�|d|d|d}}}tjdd�\}}	tj|d�}
|
jd�|
jd	|�|
jd
|�|
j|d�|
j�z�t	j
d|t	j|	�t	j|�fd
i|dd6tj
|�d6dt	jdtd�d|jj�|jt|	��dd!\}}}Wdtj|	�X|||fS(s0arbitrarily rewrite changeset before applying its
filtering %s
iiiROshg-transplant-R+s# HG changeset patch
s
# User %s
s
# Date %d %d
s
s%s %s %stenvirontHGUSERt
HGREVISIONtonerrt	errprefixs
filter failedtoutN(R>RfRRaRbRRcR0R1R	tsystemt
shellquoteRR/R`tfouttparselogtfileRg(RRLRFRCRutusertdatetmsgRvt
headerfileR2((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyRL�s& 


)cCs�|d \}}	\}
}}}
d|
|f}i|d6}|rf|j||||�\}	}}
n|r�|
dtj|�7}
n|jjtd�t|��|jjd|	||
f�|r�r�j	td���n|r�y;t
�}tj|j||d|d	d�t
|�}Wq�tk
r�}tjj|jd
�}tjj|�rvtj|�n|jj�}|}|j|	||
||d|�|jjt|�d�ttd
���q�nd}|r&|jj�\}}|j||�tj|jd�}ntj|jd|�}|j |
|	|d|d|d|j!�}|s�|jj"td�t|��dS|s�|j#j
||�n|S(s>apply the patch in patchfile to the repository as a transplantis%d %dttransplant_sources
(transplanted from %s)sapplying %s
s	%s %s
%s
s"can only omit patchfile if mergingtfilesteolmodetseriesRs
s1fix up the merge and run hg transplant --continuettextraRR?sskipping emptied changeset %s
N($RLRR/R>RfRRR^R	R`R8RR<R*t	ExceptionRRR R!RgRRRnRMR0tstrRRSt
setparentsRtalwaystroottexacttcommitR?RYR(RR@RFtclRuRRMRLtmanifestR�ttimettimezoneR�tmessageR�R�tinstt
seriespathRnRotmRy((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyRe�sN
$ 	" c
Cstjjtjj|jd��rn|j|||�\}}|jjtd�t|�t|�f�ntjj|jd�}tjj|�s�|j	j
�dS|j�\}}i}	x$|D]}||	|jj
|�<q�Wtj|�|j|||	||�dS(s7recover last transaction and apply remaining changesetstjournals%s transplanted as %s
R�N(RRR!R trecoverR>RfRRRR0t
readseriesRCRDRgRz(
RR@RjRPRyRFR�tnodesRlRk((s4/sys/lib/python2.7/site-packages/hgext/transplant.pytresume*s$


cCs�|j�\}}}}}t}	|sA|sA|sA|drYtjtd���n|d}
t|�dkr�|jd�r�|j|d�}
|
|kr�tjtd�t|
�t|�f��q�q�t	}	ni|d6}|j
�}z�|jj�\}
}|
|
kr?tjtd�t
j|
���n|	r\|j|
|d�n|j|||d|d	|j�}|s�tjtd
���n|	s�|jj||�n|j�||fSWd|j�XdS(s/commit working directory using journal metadataistransplant log file is corruptiRGs%s is not a parent of %sR�s'working dir not at transplant parent %sR�R?s
commit failedN(treadlogRR	R`RtlenR6R_RR7RVRRRSRR/R�R�R?RR8tunlogRi(RR@RjRPRFR�R�R�RSRRGR�RVRnRoRy((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyR�<s> 
"	
	
cCspg}g}|}xQ|jjd�j�D]7}|jd�rL|}q+n|jtj|��q+W||fS(NR�s# Merges(RRR"t
startswithR'RR$(RR�RltcurR)((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyR�dscCs�|s
dStjj|j�s2tj|j�n|jdd�}x2t|�D]$}|jtj||�d�qQW|r�|jd�x+|D] }|jtj|�d�q�Wn|j	�dS(NR�R+s
s	# Merges
(
RRR,R-RRQR0RR/R1(RRkRlR�RDR�((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyRhps"

!c	CsNg}g}tj}t}d}d}x�|j�j�D]�}|rV|j|�q:|jd�rr|d}q:|jd�r�|d}q:|jd�r�tj|d�}q:|jd�r�|jtj|d��q:|jd�s:t	}|j|�q:q:Wd||fkr2t
jtd	���n|||d
j
|�|fS(Ns# User is# Date s
# Node ID i
s	# Parent i	s# s,filter corrupted changeset (no user or date)s
(RR]RR<RR"R'R�R$R7R	R`RR (	RR2RSR�RFtinmsgR�R�R)((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyR�s.	

cCs�tjj|j�s(tj|j�n|jdd�}|jd|�|jd|�|jdtj|��|jdtj|�d�|r�|jdtj|�d�n|j|j�d�|j	�dS(	s,journal changelog metadata for later recoverR�R+s
# User %s
s
# Date %s
s
# Node ID %s
s	# Parent s
N(
RRR,R-RR0RR/trstripR1(RR�R�R�RnRoRR2((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyRM�s!cCs|j|jd��S(NR�(R�R(R((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyR��scCs>tjj|jd�}tjj|�r:tj|�ndS(sremove changelog journalR�N(RRR R!Rg(Rtabsdst((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyR��scs����fd�}|S(Ncs��j�|��rtS�jj|�dtjkr<tS�jj|�d}|jd�}|r��j�|��r�tStS(NiiR�(	RKRRCRSRR]RR6R7(RFR�tcnode(R@R�RRj(s4/sys/lib/python2.7/site-packages/hgext/transplant.pytmatchfn�s((RR@RjR�R�((R@R�RRjs4/sys/lib/python2.7/site-packages/hgext/transplant.pyttransplantfilter�sN(RRRRKRzRLRR<ReR�R�R�RhR�RMR�R�R�(((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyR=Rs		j	3		(					cCs6y|jj|�dk	SWntjk
r1tSXdS(N(RCRDR<R
tRevlogErrorR(R@RF((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyRB�scCs�d�}tj|||�}g}g}xJ|D]B}|j||�d}	x�|	s|jtd��}	|	dkr�||�d}	qQ|	dkr�jj|�d}
x*tj	||
|�D]}|j
|�q�Wd}	qQ|	d
krQ|j
td��d}	qQqQW|	dkr+|j|�q1|	dkrG|j|�q1|	d	krWPq1|	d
kr1d}d}Pq1q1W|j�||fS(s#interactively transplant changesetscSs|jtd��dS(Ns�y: transplant this changeset
n: skip this changeset
m: merge at this changeset
p: show patch
c: commit selected changesets
q: cancel transplant
?: show this help
(R0R(R>((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyt
browsehelp�ssapply changeset? [ynmpcq?]:t?tpityRyR�tctqsno such option
N(R�RyR�R�R�(((
Rtshow_changesettshowR<tpromptRRCRSRRdR0R'R1(R>R@R�RPR�t	displayerRRlRFtactionRGRx((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyt
browserevs�s@		
	
		

R:tsRjR�stransplant changesets from REPOtREPOtbtbranchs!use this source changeset as headtREVtatalls0pull all changesets up to the --branch revisionsR�tprunes
skip over REVR�Rsmerge at REVRGs)parent to choose when transplanting mergetetedits invoke editor on commit messagesRMs%append transplant info to log messageR�tcontinues7continue last transplant session after fixing conflictsRLs!filter changesets through commandtCMDsChg transplant [-s REPO] [-b BRANCH [-a]] [-p REV] [-m REV] [REV]...cs=tjd�}tjd�}d�}|||�|jd�s\|jdd�|d<n|jd�s�|jdd�|d<nt||�}|jd�r�tj|_n|jj	�\}}	t
|�dkr�tjkr�j
td	���n|jd
�s�|	tjkr5tj
td���n|j�d \}
}}}
|
si|si|si|
r�tj
td
���q�n|jd�}|rtj|||j|��}t|j|jdd��}tj|||d|dt�\�}}n*|�t�j|jdd��}d}z�jd
�rU|j|�|�dS|j|�|��|jd�r�t�fd�tj�|jd��D�����fd�}n�}t�j|jdd��}i}|r(x�j�|�D]}�j|�|t|�<qWn�|jd�s>|r�|krb|�|d|�}n|�||d|�}|jd�r�|}n(t|�||�\}}|j |�x'|D]}||�j!j"|�<q�Wnx$|D]}||�j!j"|�<q�|j#|�|||�Wd|r8|�nXdS(s�transplant changesets from another branch

    Selected changesets will be applied on top of the current working
    directory with the log of the original changeset. The changesets
    are copied and will thus appear twice in the history with different
    identities.

    Consider using the graft command if everything is inside the same
    repository - it will use merges and will usually give a better result.
    Use the rebase extension if the changesets are unpublished and you want
    to move them instead of copying them.

    If --log is specified, log messages will have a comment appended
    of the form::

      (transplanted from CHANGESETHASH)

    You can rewrite the changelog message with the --filter option.
    Its argument will be invoked with the current changelog message as
    $1 and the patch as $2.

    --source/-s specifies another repository to use for selecting changesets,
    just as if it temporarily had been pulled.
    If --branch/-b is specified, these revisions will be used as
    heads when deciding which changsets to transplant, just as if only
    these revisions had been pulled.
    If --all/-a is specified, all the revisions up to the heads specified
    with --branch will be transplanted.

    Example:

    - transplant all changes up to REV on top of your current revision::

        hg transplant --branch REV --all

    You can optionally mark selected transplanted changesets as merge
    changesets. You will not be prompted to transplant any ancestors
    of a merged transplant, and you can merge descendants of them
    normally instead of transplanting them.

    Merge changesets may be transplanted directly by specifying the
    proper parent changeset by calling :hg:`transplant --parent`.

    If no merges or revisions are provided, :hg:`transplant` will
    start an interactive changeset browser.

    If a changeset application fails, you can fix the merge by hand
    and then resume where you left off by calling :hg:`transplant
    --continue/-c`.
    css)x"|D]}||�r|VqqWdS(N((R@tcsetsRRF((s4/sys/lib/python2.7/site-packages/hgext/transplant.pytincwalk2s
css�|s|j�}ng}x*|D]"}|j|jj||��q"Wx5|jj||�dD]}||�rb|VqbqbWdS(s�Yield all nodes that are ancestors of a head but not ancestors
        of dest.
        If no heads are specified, the heads of repo will be used.iN(RNR'RCtancestortnodesbetween(R@tdestRNRREtheadRF((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyttransplantwalk7s
  cSs�|jd�rX|jd�s<|jd�s<|jd�rTtjtd���ndS|jd�p�|p�|jd�p�|jd�s�tjtd���n|jd�r�jd�s�tjtd���n|r�jtd	���q�dS(
NR�R�R�Rs;--continue is incompatible with --branch, --all and --mergeRjs8no source URL, branch revision or revision list provideds --all requires a branch revisions*--all is incompatible with a revision list(R6R	R`R(RPRm((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyt	checkoptsDs-RMR:RLR�isno revision checked outR�soutstanding uncommitted mergesisoutstanding local changesRjR�t	onlyheadstforceNR�c3s|]}�j|�VqdS(N(R_(t.0R5(Rj(s4/sys/lib/python2.7/site-packages/hgext/transplant.pys	<genexpr>|scs�|�o|�kS(N((tx(R�ttf(s4/sys/lib/python2.7/site-packages/hgext/transplant.pyt<lambda>~sRR�R(((($R	R�R6tconfigR=RtcommitforceeditorR?RRRSR�RR]R`RRfRR[t
expandpathR#R_RtgetremotechangesR7R<R�R�R8RtrevrangetintR�textendRCRDRz(R>R@RmRPR�R�R�ttpRnRoR�R�R5tdt
sourcerepoR[RNR�t	cleanupfnR�RlRktalltransplantst	newmerges((R�RjR�s4/sys/lib/python2.7/site-packages/hgext/transplant.pyR:�sxC
	
!" 		


cCsT|rtj|||�}n|}g|D]%}||j�jd�r+|^q+S(s```transplanted([set])``
    Transplanted changesets in set, or all transplanted changesets.
    R�(RtgetsetR�R6(R@tsubsetR�R�R5((s4/sys/lib/python2.7/site-packages/hgext/transplant.pytrevsettransplanted�scKs.|j�jd�}|r*tj|�p-dS(sT:transplanted: String. The node identifier of the transplanted
    changeset if any.R�R�(R�R6RR/(R@tctxtargsRy((s4/sys/lib/python2.7/site-packages/hgext/transplant.pytkwtransplanted�scCsttjd<ttjd<dS(Nttransplanted(R�RtsymbolsR�R
tkeywords(R>((s4/sys/lib/python2.7/site-packages/hgext/transplant.pytextsetup�s
(&t__doc__tmercurial.i18nRRRatmercurial.nodeRt	mercurialRRRRRRRR	R
RRR
R`Rtcmdtabletcommandt
testedwithtobjectRRR=RBR�R<RR:R�R�R�t
i18nfunctions(((s4/sys/lib/python2.7/site-packages/hgext/transplant.pyt<module>sD"..�	+		�
		

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.