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

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


��c@sdZddlmZmZmZmZmZmZmZddlm	Z	m
Z
mZmZm
Z
mZddlmZddlmZddlmZddlmZddlZddlZd	Zd
ZiZeje�ZdZedd
dded�ed�fddded�ed�fddged�ed�fddded�ed�fddeed�fddded�ed �fd!d"eed#�fd$d%ded&�ed'�fdd(eed)�fdd*eed+�fd,d-eed.�fd/d0ded1�fd2d3eed4�fd5d6eed7�fgeed8��d9��Zd:�Z e!e!e!d;�Z"d<�Z#d=�Z$d>�Z%d?�Z&d@�Z'dA�Z(dB�Z)dC�Z*dD�Z+dE�Z,dF�Z-e!dG�Z.dH�Z/dI�Z0dS(Js�command to move sets of revisions to a different ancestor

This extension lets you rebase changesets in an existing Mercurial
repository.

For more information:
http://mercurial.selenic.com/wiki/RebaseExtension
i�(thgtutiltrepairtmergetcmdutiltcommandst	bookmarks(t
extensionstpatchtscmutiltphasestobsoleteterror(ttemplateopts(tnullrev(trelease(t_Ni�i�tinternaltrebasetstsourcets#rebase from the specified changesettREVtbtbasesarebase from the base of the specified changeset (up to greatest common ancestor of base and dest)trtrevsrebase these revisionstdtdests#rebase onto the specified changesettcollapsescollapse the rebased changesetstmtmessages#use text as collapse commit messagetTEXTtetedits invoke editor on commit messagestltlogfiles&read collapse commit message from filetFILEtkeepskeep original changesetstkeepbranchesskeep original branch namestDtdetachs(DEPRECATED)ttttoolsspecify merge tooltctcontinuescontinue an interrupted rebasetatabortsabort an interrupted rebases#[-s REV | -b REV] [-d REV] [OPTION]c1KsM
d3}}d3}t}i}t�}t�}	d3}
|jd�rOtj}
nd3}}z�|j�}|j�}|jdd3�}
|jdd3�}|jdd3�}|jdg�}|jd�}|jd�}|jdt�}tj	||�}|jd	�}|jd
t�}|jdt�}|jdt�}|rh|rht
jtd
���n|st|rK|r�|r�t
jtd���n|r�t
jtd���n|s�|s�|
r�
jtd���n|jdt�r|j
td��nt|�\	}}}}}}}}}|r�t||||�Snj|ro|rot
jtd���n|r�|r�t
jtd���n|r�|r�t
jtd���ntj|�|
s�d3j�}||}ntj||
�}|r|jd|�}nc|rDtj||g�}|jd|�}n3tj||pVdg�}|jd|||�}|r�t|�}nd3}|s�|jjd�d3}n^|p�tjr�jd||�r�jtd�dtd���nt||||�}|s,|jtd��d S|rp||j�rpt
jtd!�||dtd"���nE|\}}}|r�|jj|gd#t �}	t!|||	�}n|r>|s�t"d$��d%�}|r>t�} xR|D]G}!| j#||!j��t$| �d kr�
jtd&���q��q>n|	sb|jj|gd#t �}	n|j%j&�}"|p}|j'}|r�t(j)|�nt*|�}#t$|#�}$d'}%x|#D]}!|%d 7}%||!d(kr�|j+td)�|%d*|!||!ftd+�|$�t,|||||||||�t-||!|||	�\}&}'t$|j.��d,kry|jjd-�n�zi|j/d.d/|jdd0��t0||!|&||�}(|(r�(d1d'kr�1j2td2���nWd3|j/d.d/d0�Xtj3||!|�|s6t4||!|&|'d	|d4|
�})n|j5||&j6��d3})|)d3k	rv||)j7�||!<q�|s�|j8td5�|!�|jd6|&�|j#|!�n|&||!<q�q�W|j+td)�d3�|j8td7��|r�|r�t-|t|�|||	�\}&}'|r.|}*nid8}*xE|D]=}+|+|kr;||+t9kr;|*d9||+j:�7}*q;q;W|j;|*|jj<��}*t4||!|&|d:|*d	|d4|
�})nd;|j=�kr�>||||�n|"rR	i},xG|j?�D]9\}-}.|.t9kr	||.j6�|,||-j6�<q	q	W||j6�}/n|s�d3}0|rm	|)}0nt@|||||0�n|"r�tA||/|,|"�ntB|�|j8td<��t
jC|jDd=�d>t �|r
|j8td?�t$|��n|r7
|d@j6�|j%|kr7
t(jE||�nWd3tF||�Xd3S(As�move changeset (and descendants) to a different branch

    Rebase uses repeated merging to graft changesets from one part of
    history (the source) onto another (the destination). This can be
    useful for linearizing *local* changes relative to a master
    development tree.

    You should not rebase changesets that have already been shared
    with others. Doing so will force everybody else to perform the
    same rebase or they will end up with duplicated changesets after
    pulling in your rebased changesets.

    In its default configuration, Mercurial will prevent you from
    rebasing published changes. See :hg:`help phases` for details.

    If you don't specify a destination changeset (``-d/--dest``),
    rebase uses the tipmost head of the current named branch as the
    destination. (The destination changeset is not modified by
    rebasing, but new changesets are added as its descendants.)

    You can specify which changesets to rebase in two ways: as a
    "source" changeset or as a "base" changeset. Both are shorthand
    for a topologically related set of changesets (the "source
    branch"). If you specify source (``-s/--source``), rebase will
    rebase that changeset and all of its descendants onto dest. If you
    specify base (``-b/--base``), rebase will select ancestors of base
    back to but not including the common ancestor with dest. Thus,
    ``-b`` is less precise but more convenient than ``-s``: you can
    specify any changeset in the source branch, and rebase will select
    the whole branch. If you specify neither ``-s`` nor ``-b``, rebase
    uses the parent of the working directory as the base.

    For advanced usage, a third way is available through the ``--rev``
    option. It allows you to specify an arbitrary set of changesets to
    rebase. Descendants of revs you specify with this option are not
    automatically included in the rebase.

    By default, rebase recreates the changesets in the source branch
    as descendants of dest and then destroys the originals. Use
    ``--keep`` to preserve the original source changesets. Some
    changesets in the source branch (e.g. merges from the destination
    branch) may be dropped if they no longer contribute any change.

    One result of the rules for selecting the destination changeset
    and source branch is that, unlike ``merge``, rebase will do
    nothing if you are at the latest (tipmost) head of a named branch
    with two heads. You need to explicitly specify source and/or
    destination (or ``update`` to the other head, if it's the head of
    the intended source branch).

    If a rebase is interrupted to manually resolve a merge, it can be
    continued with --continue/-c or aborted with --abort/-a.

    Returns 0 on success, 1 if nothing to rebase.
    R"RRRRR-R/RtextrafnR&R'tkeepopens+message can only be specified with collapses"cannot use both abort and continues*cannot use collapse with continue or aborts4abort and continue do not allow specifying revisionsR+stool option will be ignored
s'cannot specify both a source and a bases)cannot specify both a revision and a bases+cannot specify both a revision and a sources%lrs(%ld)::t.s+(children(ancestor(%ld, %d)) and ::(%ld))::s base is ancestor of destination
sfirst(children(%ld) - %ld)s;can't remove original changesets with unrebased descendantsthints&use --keep to keep original changesetssnothing to rebase
is#can't rebase immutable changeset %sssee hg help phases for detailst	inclusives(cannot use both keepbranches and extrafncSs|j�|d<dS(Ntbranch(R5(tctxtextra((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyR0�ss'cannot collapse multiple named branchesii�trebasings%d:%st
changesetsisresuming interrupted rebase
tuit
forcemergeRis@unresolved conflicts (see hg resolve, then hg rebase --continue)Nteditors no changes, revision %d skipped
snext revision set to %s
srebase merging completed
sCollapsed revisions
* %st	commitmsgtqtipsrebase completed
tundot
ignoremissings%d revisions have been skipped
ttip(GtNoneRtsettgetRtcommitforceeditortwlocktlocktFalset
logmessageRtAbortRtwarnt
restorestatusR/t
bailifchangedR5R	t	revsingletrevstrevrangetminR:tdebugRt_enabledt
buildstatetstatustmutablet	changelogt	ancestorstTruet
checkexternaltAssertionErrortaddtlent
_bookmarkstcopyt_bookmarkcurrentRtunsetcurrenttsortedtprogresststorestatust
defineparentstparentst	setconfigt
rebasenodeRtInterventionRequiredtduplicatecopiestconcludenodet
setparentstnodeRtnotet	nullmergetdescriptionR"tusernamettagstupdatemqt	iteritemstclearrebasedtupdatebookmarkstclearstatust
unlinkpathtsjoint
setcurrentR(1R:trepotoptst
originalwdttargettactivebookmarktexternaltstatetskippedttargetancestorsR<RGRFtdestftsrcftbaseftrevftcontftabortft	collapseftcollapsemsgR0tkeepft
keepbranchesfR1R5Rt	rebasesettsrcRtroottresulttbranchesRtcurrentbookmarkstsortedstatettotaltpostp1tp2tstatstnewrevR=trebasedtnstatetktvt
targetnodetcollapsedas((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyR s\R
		

'

					
"

#

	
%	
 cCs�t}t|�}x�|D]�}||kr1qnxo||j�D]]}|j�|krB|j�|krB|tkr�tjtd���n|j�}qBqBWqW|S(ssCheck whether one or more external revisions need to be taken in
    consideration. In the latter case, abort.
    s:unable to collapse, there is more than one external parent(RRQRfRRRJR(R{R�R�R�RRtp((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyRZ[s
cCs<y|j||j�||j��||}|dkrL|j�}ni|j�d6}|ru|||�n|jd|d|j�d|j�d|d|�}	|jj	||	j
��t|j�t
j�}
||	j�}|rt
j||
|g�n|	SWn$tjk
r7|jj��nXdS(s8Commit the changes and store useful information in extrat
rebase_sourcettexttusertdateR7R<N(RlRmRBRpthextcommitR�R�tdirstatet	setbranchR5tmaxtphaseR
tdrafttretractboundaryRRJt
invalidate(R{RR�R�R=R<R0R6R7R�ttargetphasetnewnode((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyRkns&$

cCs
|dj�||j�krd|jjd||j�||f�tj||ttt�n|jjd�|jj�|jjd||j�||f�d}||j�|t
|�j�kr�|j�j�}ntj||ttt||�S(sRebase a single revisionR2s update to %d:%s
s already in target
s merge against %d:%s
N(
RR:RRRtupdateRHRYR�twriteRBRQR�Rm(R{RR�R�RR((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyRh�s (
(&cCsXg|D]}||tkr|^q}|jd||�}|rP||dSdSdS(s8return the nearest ancestors of rev in the rebase resultsmax(%ld  and (::%d))iN(RoRORB(R{RR�RR�t
candidates((s0/sys/lib/python2.7/site-packages/hgext/rebase.pytnearestrebased�s
)c
Cs�||j�}t}}|dj�}||kr?|}nx||kr�||tkrd|}q�||tkr�t|||�}|dkr�|}q�q�||}n|}|}t|�dkr�|dj�|kr�|dj�}	|	|kr[||kr||	}q�||	tkrNt||	|�}|dkrX|}qXq�||	}q�|tkr�tj	t
d�|��n|	}n|jjd||j�||j�f�||fS(sGReturn the new parent relationship of the revision that will be rebasediiis;cannot use revision %d as base, result would have 3 parentss future parents are %d and %d
N(
RfRRRot
revignoredR�RBR]RRJRR:RR(
R{RR~R�R�RfR�R�tP1ntP2n((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyRe�s@
		
(


	"cCsUtjj|jj|�}x3tjt|d��D]}|jd�r4tSq4Wt	S(s/Return true if the given patch is in git formattrbs
diff --git(
tostpathtjointmqRt
linereadertfilet
startswithRYRH(R{t	patchnametmqpatchtline((s0/sys/lib/python2.7/site-packages/hgext/rebase.pytisagitpatch�s
cKs�i}|j}|j}t�}x|jD]t}||jj�}	|	|kr�|jjd|	|jf�|jt	||j�f||	<q,|j
|j�q,W|r�|j||j��x�t
|dt�D]�}	|	|krE||	\}
}|jjd||	|
f�|j|d
d|
d|dt||	�g�q�|j
||	d�q�Wg|D]+}|jj|d�d|kre|^qe}
|
|j(t|_|j�nd	S(s9Update rebased mq patches - finalize and then import thems.revision %d is an mq patch (%s), finalize it.
treversesimport mq patch %d (%s)
R�tgitRiiN((R�t
fullseriesRCtappliedRmRR:RRtnameR�R\tfinishtkeysRbRYtqimporttstrtguard_retsplittseriesdirtyt	savedirty(R{R�R�R|tmqrebaseR�toriginal_seriestskippedpatchesR�RR�tisgitRt	newseries((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyRs�s2	
	"
+
	cCsg|j}xM|j�D]?\}}||kr||||<tj||g|�qqW|j�dS(sEMove bookmarks to their correct changesets, and delete divergent onesN(R^RtRtdeletedivergentR�(R{R�R�toriginalbookmarkstmarksR�R�((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyRv�s	c	CsF|jdd�}	|	j||j�d�|	j||j�d�|	j||j�d�|	jdt|��|	jdt|��|	jdt|��|	jd|p�d�xf|j�D]X\}
}||
j�}|tkr||j�}
n|}
|	jd||
f�q�W|	j�|jjd�d	S(
s*Store the current status to allow recoverytrebasestatetws
s%d
s%s
Rs%s:%s
srebase status stored
N(	topenerR�R�tintRtRotcloseR:RR(R{R}R~R�RR&R'R�RtfRR�toldrevR�((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyRds 
cCs tj|jd�dt�dS(sRemove the status filesR�R@N(RRxR�RY(R{((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyRwsc	Cs�yxd}t}t}d}i}|jd�}x�t|j�j��D]n\}}|dkrt||j�}	qI|dkr�||j�}qI|dkr�||j�}qI|dkr�tt	|��}qI|dkr�t	|��}
qI|dkrtt	|��}qI|dkrIt
|�d	ko<d
|krI|}qI|jd
�\}}
|
tt
�tt�fkr�t	|
�|||j�<qI||
j�|||j�<qIWt�}|s4t|g�}xXt|j��D]A\}}|tkr ||kr |j|�n|j|�q�n|jjd|�|jjd�|	|||||
|||f	SWn@tk
r�}|jtjkr��ntjtd
���nXdS(s"Restore a previously stored statusR�iiiiiiiiQt:scomputed skipped revs: %s
srebase status resumed
sno rebase in progressN(RBRHRR�t	enumeratetreadt
splitlinesRtboolR�R]R�R�RoR�RCRbtitemsR\R:RRtIOErrorterrnotENOENTRRJR(R{R~RR�RR�R�tiR#R}R&R'R�R�R�tseentoldtnewterr((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyRL!sR%+	"	cs�g|j�D]}|tkr
|^q
}g|D]}�|j�s2|^q2}|r�tjtd�dj�fd�|D��dtd���nt�}|r�t�jj	|��}n|t|�r�j
jtd��dStj
��|j�ttt�t�fd�|j��}	|	rzg�jd	|	�D]}
|
j�^qI}tj�j
�|�nt���j
jtd
��dSdS(
s,Restore the repository to its original states1can't abort rebase due to immutable changesets %ss, c3s|]}t�|�VqdS(N(R�(t.0R(R{(s0/sys/lib/python2.7/site-packages/hgext/rebase.pys	<genexpr>XsR3ssee hg help phases for detailss?warning: new changesets detected on target branch, can't abort
i�cs|dko|�kS(Ni�((tx(R~(s0/sys/lib/python2.7/site-packages/hgext/rebase.pyt<lambda>ess
roots(%ld)srebase aborted
iN(tvaluesRRVRRJRR�RCRWtdescendantsR:RKRR�RRHRYtfilterRmRtstripRw(R{R}R~R�RtdstatesRt	immutableR�R�R,tstrippoints((R{R~s0/sys/lib/python2.7/site-packages/hgext/rebase.pyR/Rs(+) 	#+
cCscd|j�krX|j�g|jjD]}|j^q(krXtjtd���nt|jd|��}|s�tjtd���n|j	�i}t�}x|D]}|j
|�}	|	|kr�jtd���n|	|krA|j�|j�k}
|rA|
rA||j�krA|j
jd�dSn|j
jd||f�|jtj|t��t|j��dkr�|j|jj|	j�g|j�g��q�q�Wx'|D]}||kr�t||<q�q�Wt|�dkrFt|jd	||��}x+t|�t|�D]}
t||
<q/Wn|d
j�|j�|fS(syDefine which revisions are going to be rebased and where

    repo: repo
    dest: context
    rebaseset: set of rev
    R>s&cannot rebase onto an applied mq patchs
roots(%ld)sno matching revisionss!source is ancestor of destinations!source is a child of destination
s rebase onto %d starting from %s
is%ld::%ldR2N(RrRmR�R�RRJRtlistRCtsorttancestorR5tchildrenR:RRRBR�tdicttfromkeysRR]RfRWtfindmissingrevsRRoROR�(R{RR�RRtrootsR�t	detachsetR�t
commonbaset
samebranchRtrebasedomaintignored((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyRTns>%
	
&
cCs~tjr�g}x�t|j��D]p\}}|dkr"||krOd}n)|dk	rk||f}n
||f}|j|||f�q"q"W|rztj||�qzn�g|D]}||tkr�|^q�}	|	rzg}
xn|jd|	�D]Z}t|j	j
|j�g��t|�rA|jt
d��q�j|j��q�
rztj|||
d�qzndS(s�dispose of rebased revision at the end of the rebase

    If `collapsedas` is not None, the rebase was a collapse whose result if the
    `collapsedas` node.is
roots(%ld)sAwarning: new changesets detected on source branch, not stripping
tallN((RRSRbR�RBtappendt
createmarkersRoRCRWR�RRKRRmRR�(R:R{R�R�R�tmarkersRR�tsuccsR�tstrippedR�((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyRu�s*		
)+cOs�|jd�ri|jd�r5|d=|jd�n|dj�}tj|�t|�}tj}d�}|t_z|||||�Wd|t_Xt|�}	|	|kr�d|kr�|d=nt|||�|dj
�}
||
j�}||dj�krftj
||�tj
||g|dj��rc|jtd�|j�qcqfq�n:|jd	�r�tjtd
���n|||||�dS(sCCall rebase after pull if the latter has been invoked with --rebaseRR�sC--update and --rebase are not compatible, ignoring the update flag
R2c_sdS(N((targstkwargs((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyt_dummy�sNRsupdating bookmark %s
R+s%--tool can only be used with --rebase(RDRRRmRRMR]RtpostincomingRRBR5RRR�RRURR`RRJ(torigR:R{RR|tmovemarkfromtrevsprepulltorigpostincomingR
trevspostpullR5R((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyt
pullrebase�s8
			

"cCsbtjtjdt�}|djddd	td�f�|djdddtd�f�d	S(
s8Replace pull with a decorator to provide --rebase optiontpulliRRs'rebase working directory to branch headR*R+sspecify merge tool for rebaseN(RtwrapcommandRttableRRRBR(R:tentry((s0/sys/lib/python2.7/site-packages/hgext/rebase.pytuisetups
(1t__doc__t	mercurialRRRRRRRRRR	R
RRtmercurial.commandsR
tmercurial.nodeRtmercurial.lockRtmercurial.i18nRR�R�RoR�tcmdtabletcommandt
testedwithRHRRZRBRkRhR�ReR�RsRvRdRwRLR/RTRuRR(((s0/sys/lib/python2.7/site-packages/hgext/rebase.pyt<module>sl4.								�				+		(				1		X!	'

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.