
    6hG                      S r SSKJ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&  Sr'Sr(1 S	kr)0 r*\RV                  " \*5      r+0 r,\RZ                  " \,5      r-\-" S
SSS9  Sr.S r/S r0SjS jr1\Rd                  " 5       r2\2" S5      S 5       r3\2" S5      S 5       r4S r5 " S S5      r6\+" SSS/ \" S5      \" S5      4SS/ \" S 5      \" S5      4S!S"/ \" S#5      \" S5      4S$S%S&\" S'5      \" S5      4S&S(S\" S)5      4S*S+S&\" S,5      \" S-5      4S.S/S\" S05      4S1S2S&\" S35      \" S45      4S5S6S\" S75      4S&S8S\" S95      4S:S;S\" S<5      4S=S>S\" S<5      4S?S@S&\" SA5      4S&SBS\" SC5      4SDSES\" SF5      4SGSHS\" SI5      4S&SJS&\" SK5      4/\Rn                  -   \Rp                  -   \Rr                  -   \" SL5      \+Rt                  SM9SN 5       r;SO r<SkSP jr=SQ r>SR r?SS r@ST rASU rBSV rCSW rDSX rESY rFSZ rGS[ rHS\ rIS] rJS^ rKS_ rLS` rMSa rNSb rO    SlSc jrPSd rQSe rRSf rSSg rTSh rUSi rVg)mzcommand to move sets of revisions to a different ancestor

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

For more information:
https://mercurial-scm.org/wiki/RebaseExtension
    )annotationsN)_)nullrevshortwdirrev)	bookmarkscmdutilcommandscopiesdestutilerror
extensions
logcmdutilmerge
mergestate	mergeutilobsoleteobsutilpatchphasespycompat	registrarrepairrevset
revsetlangrewriteutilscmutilsmartsetstateutils   -1>      -2   -3   -4   -5   devel   rebase.force-in-memory-mergeF)defaults   ships-with-hg-corec                     g)N    r+       ./usr/lib/python3/dist-packages/hgext/rebase.py_nothingtorebaser.   T   s    r,   c                *    U R                  5       US'   g )N   branch)branch)ctxextras     r-   _savebranchr4   X   s    zz|E)r,   c                2    [         R                  " U SUSUS9$ )zdsmall wrapper around destmerge to pass the right extra args

Please wrap destutil.destmerge instead.   rebaseF)action	sourcesetonheadcheck	destspace)r   	destmerge)repor8   r:   s      r-   _destrebaser=   \   s&      r,   s   _destrebasec                    S nUb,  [         R                  " U [        R                  " U 5      U5      nU[        R                  " [        X5      /5      -  $ N)r   getsetr   fullreposetbasesetr=   )r<   subsetxr8   s       r-   _revsetdestrebaserE   l   sI     I}MM$(<(<T(BAF	H$$k$&B%CDDDr,   s   _destautoorphanrebasec                   U R                  5       nUR                  S5      n[        R                  " XU5      R	                  5       nU(       a  XT;   a  [
        R                  " 5       $ [        R                  " X5      n[        U5      S:  a#  [        R                  " [        S5      XV4-  5      e[
        R                  " U5      $ )Ns
   obsolete()r*   s8   ambiguous automatic rebase: %r could end up on any of %r)
unfilteredrevsr   r@   firstr   rB   r   orphanpossibledestinationlenr   
StateErrorr   )r<   rC   rD   unfi	obsoletedsrcdestss          r-   _revsetdestautoorphanrebaserQ   z   s    
 ??D		-(I
--a
(
.
.
0C #"!!..t9E
5zA~IJl
 	

 E""r,   c                ^    [         R                  " U R                  5       R                  U SS9$ )zshort description for a contextr6   )command)r	   format_changeset_summaryr<   ui)r2   s    r-   _ctxdescrV      s&    ++
sI r,   c                      \ rS rSrSrSS jr\S 5       rSS jrS r	S r
S	 rS
 r SS jrS rS rS rSS jrS rS rSS jrSrg)rebaseruntime   z2This class is a container for rebase runtime stateNc                4   Uc  0 nSU l         SU l        Xl        X l        XPl        S U l        [        U l        0 U l        S U l	        0 U l
        [        5       U l        UR                  SS5      U l        [        R                   " U["        R$                  " U5      5      U l        UR                  SS 5      U l        UR                  S5      n[*        R,                  /U l        U(       a  U/U l        UR1                  SS5      U l        UR                  SS5      U l        UR                  SS5      U l        [*        R8                  " UR                  S	5      U l        0 U l        [        5       U l        X0l         X@l!        [D        RF                  " US
5      U l$        g )NFcollapsedateextrafns   rewrites   backup-bundlekeepkeepbranchesr6      rebasestate)%preparedresume_reporU   opts
originalwdr   externalr   activebookmarkdestmapsetskippedget	collapsefr	   
logmessager   byteskwargscollapsemsgr\   r   preserve_extras_on_rebaseextrafns
configboolbackupfkeepfkeepbranchesfskip_empty_successorskipemptysuccessorf&obsolete_with_successor_in_destination%obsolete_with_successor_in_rebase_setinmemorydryrunstatemodcmdstatestateobj)selfr<   rU   rz   r{   rd   es          r-   __init__rebaseruntime.__init__   sN   <D 
	 
"u*e4"--b(2F2Ft2LMHHVT*	HHY$>>?CDM}}Z1ABXXfe,
!XXne<#.#C#CGGY$
  79358U2  ))$?r,   c                p    U R                   (       a  U R                  R                  5       $ U R                  $ r?   )ra   rc   rG   )r   s    r-   r<   rebaseruntime.repo   s&    ==::((**::r,   c                    U(       a  UR                  SSU R                  SS9  gU R                  R                  SS5       nU R                  U5        SSS5        g! , (       d  f       g= f)z*Store the current status to allow recoveryr`   )r`   s   plain)location   wN)addfilegenerator_writestatusr<   vfs)r   trfs      r-   storestatusrebaseruntime.storestatus   sZ    !!!!	    ~t4!!!$ 544s   A
A*c                   U R                   nUR                  b   eUR                  X R                     R	                  5       S-   5        UR                  S5        UR                  X R
                     R	                  5       S-   5        UR                  S[        U R                  5      -  5        UR                  S[        U R                  5      -  5        UR                  S[        U R                  5      -  5        UR                  SU R                  =(       d    S-  5        U R                  nU R                  R                  5        H`  u  pEX$   R	                  5       nUS:  a  X%   R	                  5       nOSU-  nX#U      R	                  5       nUR                  SXgU4-  5        Mb     UR                  R                  S5        g )	N   
s   %d
   %s
r,   r      %ds	   %s:%s:%s
s   rebase status stored
)r<   
filternamewritere   hexrf   intrl   rt   ru   rg   rh   r   itemsrU   debug)	r   r   r<   rh   dvoldrevnewrevdestnodes	            r-   r   rebaseruntime._writestatus   s]   yy&&&	__%))+e34		]]#'')E12	#dnn--.	#djj/)*	#d00112	4..5#67,,JJ$$&DAW[[]FAvAJ'++-HGGMVX$>>? ' 	/0r,   c                   U R                   R                  5       (       d*  [        R                  " U R                  [        S5      5        U R                  5       nU R                  R                  R                  S5        US   U l	        US   U l
        US   U l        US   U l        US   U l        US   U l        US	   U l        US
   U l        US   U l        g)z"Restore a previously stored statusr6   s   rebase status resumed

   originalwd   destmap   state   skipped   collapse   keep   keepbranches   external   activebookmarkN)r~   existsr	   wrongtooltocontinuer<   r   _readrU   r   re   rh   r   rj   rl   rt   ru   rf   rg   )r   datas     r-   restorestatusrebaseruntime.restorestatus   s    }}##%%''		1Y<@zz|		56}-J'(^
J'k*']
!/2[)"#45r,   c           	        SU l         U R                  nUR                  b   eS S S [        S S S.nS n0 n0 n UR	                  S5      n[        UR                  5       R                  5       5       GHm  u  pxUS:X  a  X   R                  5       US'   M#  US:X  a  U(       a  X   R                  5       nMD  MF  US:X  a  X   R                  5       US'   Mc  US	:X  a  [        [        U5      5      US
'   M  US:X  a  [        [        U5      5      US'   M  US:X  a  [        [        U5      5      US'   M  US:X  a  [        U5      S:X  a  SU;   d  XS'   M  UR                  S5      n	XS      R                  5       n
U	S   nU[        ;   a  GM  [        U	5      S:  a  XS      R                  5       nOUnXU
'   U[        :X  a  [        XJ'   GMY  X   R                  5       XJ'   GMp     US   c  [         R"                  " [%        S5      5      eXRS'   XBS'   ['        5       nUS
   (       dn  ['        UR)                  5       5      n[+        UR-                  5       5       H8  u  nnU[        :w  a  UU;   a  UR/                  U5        UR/                  U5        M:     XS'   UR0                  R3                  SSR5                  S [+        U5       5       5      =(       d    S-  5        U$ )NT)r   r   r   r   r   r   r`   r   r   r*      r      r      r      r      Q      :r   s   .hg/rebasestate is incompleter   r   r   s   computed skipped revs: %s
    c              3  ,   #    U  H
  nS U-  v   M     g7fr   Nr+   .0rs     r-   	<genexpr>&rebaseruntime._read.<locals>.<genexpr>P  s     <OqO   r,   )ra   r<   r   r   r   	enumerateread
splitlinesrevboolr   rK   splitlegacystates
revtodostrrevtodor   Abortr   ri   valuessortedr   addrU   r   join)r   r<   r   
legacydestr   rh   r   ilargsr   r   destrevrj   seenoldnews                    r-   r   rebaseruntime._read  s   yy&&&!# 
 
(A!!&&("5"5"786*.'++-D'!V %)W[[]
 !V(,D%!V(,SVD%!V$(QLDM!V,0QLD)!VSVr\dai /0*+774=D!q']..0F!!WF- 4y1}"&Aw-"3"3"5",&-FO+(/ )-(8(8(:I 9L  (++a @ABB"ZX%K w~~'(D"5;;=1S'>cTkKK$ 2 #Z*yy<F7O<<CE	

 r,   c                X   U R                   (       a  gU R                  R                  SS5      (       d  gU R                   Vs1 s H(  oR                  U   R                  5       (       d  M&  UiM*     nn[        U R                  X R                  5      u  U l        U l	        [        U R                  5      nUR                  U R                  5        [        U R                  U R                  X#5        [
        R                  " U R                  [
        R                  5      (       a  [        5       U l	        gU R                  R                  SU R                  U R                  5       H;  nU R                  R!                  US5        U R                  R!                  US5        M=     gs  snf )z<Compute structures necessary for skipping obsolete revisionsN   experimentals   rebaseskipobsoletes   descendants(%ld) and not %ld)rt   rU   rr   r   r<   r   _compute_obsolete_setsrh   rx   ry   ri   update_checkobsrebase	isenabledallowdivergenceoptrH   pop)r   r   obsoleteset
skippedsetr   s        r-   _handleskippingobsolete%rebaseruntime._handleskippingobsoleteU  s.   ::ww!!/3HII"&**H*Q		!0E0E0Gq*H #499k<<H	
76DDE
$DDE		477KDdii)D)DEE9<D6yy~~/::::
 

sD)  d+ Is   %F',F'c                ,   SU l          U R                  5         U R                  5         [        U R                  U5      U l        U(       a'  U=(       a    U R                  nU R                  UUUUS9$ g ! [        R                   a    U(       aZ  [        U R                  5        [        U R                  5        U R                  R                  R                  [        S5      5         g[        S5      n[        S5      n[        R                  " XgS9ef = f)NTsF   rebase aborted (no revision is removed, only broken state is cleared)
r   s#   cannot continue inconsistent rebases-   use "hg rebase --abort" to clear broken statehint)backup	suppwarnsr{   confirm)rb   r   r   restorecollapsemsgr<   ro   r   RepoLookupErrorclearstatusclearcollapsemsgrU   warnr   r   rs   _abort)r   isabortr   r   r{   r   msgr   s           r-   _prepareabortorcontinue%rebaseruntime._prepareabortorcontinuen  s     	2 ((*1$))WED" ,F;;#	    ! $$ 	2DII& +		!!< >?IJkk#11	2s   ;A3 3A3D(+Dc                   U(       d
  [        5       $ [        U R                  XR                  5      nU(       d.  U R                  R                  [        S5      5        [        5       $ Uu  U l        U l        U l	        U R                  (       a  [        U R                  R                  5       5      n[        U5      S:w  a  [        R                  " [        S5      5      e[        [!        U5      5      nU R                  R"                  R%                  U/SS9n['        U R                  U R                  U5      U l        [+        [        UR                  5       5      5       Hc  nU R                  U   nUR-                  5       (       d  M)  U R.                  (       a  M<  U R                  R                  [        S5      U-  5        Me     U R1                  5         U R2                  (       d  [        UR5                  5       5      nU[        U R6                  5      -  nXpR8                  -  n0 n[:        R<                  " U R                  [:        R>                  5      (       a  SS0n U R                  RA                  U5         [B        RD                  " U R                  US	S
9  S S S 5        SU l%        g ! , (       d  f       N= f! [        RF                   a$  n	U	RH                  c  [        S5      U	l$        U	eS n	A	ff = f)N   nothing to rebase
r*   s3   --collapse does not work with multiple destinationsT)	inclusives    reopening closed branch head %s
)r   s   evolution.allowdivergences   truer6   )r7   s&   use --keep to keep original changesets)&r.   
buildstater<   rl   rU   statusr   re   rh   r   ri   r   rK   r   
InputErrornextiter	changelog	ancestorsexternalparentrf   r   closesbranchru   r   rt   keysrx   ry   r   r   createmarkersoptconfigoverrider   precheckr   r   ra   )
r   rh   resultrP   r   destancestorsdest	rebaseset	overridesr   s
             r-   _preparenewrebaserebaseruntime._preparenewrebase  s1   #%%DIIw?GGNN1345#%%6<3$,
>>++-.E5zQ&&LM  4;'G II//99	T : M +499djj-PDMc'.."234G99W%D  ""4+=+=+=q!EFMN 5 	$$&zzGLLN+ITHHIIICCCII!!$))X-F-FGGCW	WW++I6((IiP 7  76;; 66>HIAFs6   !J> <!J-J> -
J;7J> ;J> >K6K11K6c                   U R                   (       aC  SSKJn  U" U R                  5      U l        U R                  R
                  R                  S5        O9U R                  S    U l        U R                  R
                  R                  S5        U R                  R
                  R                  SSU R                   U R                   S9  g )Nr   )overlayworkingctxs   rebasing in memory
s   rebasing on disk
r6   s   using in-memory rebase: %r
)rebase_imm_used)rz   mercurial.contextr  r<   wctxrU   r   log)r   r  s     r-   _assignworkingcopy rebaseruntime._assignworkingcopy  s    ==;)$))4DIIILL67		$DIIILL45		+MM MM	 	 	
r,   c                  ^ U R                  5         U R                  U R                  p2U R                  (       a  U R                  R                  S[        5        U R                  (       al  [        5       nU R                   HR  nUR                  X%   R                  5       5        [        U5      S:  d  M5  [        R                  " [        S5      5      e   U R                   =(       d    UR"                  U l        U R                   (       a  [$        R&                  " U5        U R)                  5         U(       a  U R)                  U5        U R                  R+                  5        VVs/ s H  u  pgU[,        :X  d  M  UPM     nnnUR                  R/                  [        S5      [        S5      [        U5      S9mU4S jn	[1        U R2                  5       H:  n
U R                  R5                  SU
5      nU H  nU R7                  XU	5        M     M<     TR9                  5         UR;                  [        S	5      5        g s  snnf )
Nr   r*   s'   cannot collapse multiple named branchess   rebasings
   changesets)unittotalc                J   > TR                  SU R                  5       U 4-  S9  g )N   %d:%s)item)	incrementr   )r2   ps    r-   progress.rebaseruntime._performrebase.<locals>.progress  s!    KKh#'')S)99K;r,   s   sort(%ld, -topo)s   rebase merging completed
)r  r<   rU   ru   rq   insertr4   rl   ri   r   r   r1   rK   r   r   r   rg   _activebookmarkr   
deactivater   r   r   makeprogress
sortsourcerh   rH   _rebasenodecompletenote)r   r   r<   rU   branchesr   kr   candsr  rC   
sortedrevsr  s               @r-   _performrebaserebaseruntime._performrebase  s   !99dggb MM  K0~~5::CLL!1!1!348}q(#..HI  & #11IT5I5I  & 	 R #zz//1B1tqQ'\1BGG  kN=!1U ! 
	< !.F(;VDJ!  (3 " / 	



/01 Cs   'H>;H>c                   U R                   nXA   nUc  UR                  5       nU R                  (       d}  UR                  n[        R
                  " UUU R                  R                  5        VVs0 s H3  u  pxU[        :w  d  M  UR                  U5      UR                  U5      /_M5     snn5      nU R                  n	U	c  UR                  5       n	0 n
UR                  R                  SS5      (       a  SUR                  5       0n
U R                   H  nU" XZ5        M     [        UR!                  5       ["        R$                  5      nUU R&                  (       + S.nUR                  R)                  US5         U R*                  (       a(  [-        UU R.                  U
UUUR1                  5       U	S9nO[3        UU
UUUR1                  5       U	S9nUsSSS5        $ s  snnf ! , (       d  f       g= f)zCommit the wd changes with parents p1 and p2.

Reuse commit info from rev but also store useful information in extra.
Return node of committed revision.Nr6   s   store-sources   rebase_source))s   phasess
   new-commit)   ui   allowemptycommit)r  r3   	commitmsgeditoruserr\   )r3   r-  r.  r/  r\   )r<   descriptionrl   r   r   update_hash_refsr   r   r   noder\   rU   rr   r   rq   maxphaser   draftrw   r  rz   commitmemorynoder  r/  
commitnode)r   r   r.  r-  r<   r2   clr   r   r\   r3   c	destphaser  newnodes                  r-   _concludenoderebaseruntime._concludenode  s   
 yyi)I ~~B#44 +/***:*:*<*<( 7BGGFObggfo%66*<I yy<88:D77i99%swwy1EAcM 		V\\2	(1.2.F.F*F
	 WW##Iy9}}*'! %'! + :9)( :9s   0G&G9AG  
G.c                "   U R                   U R                  U R                  penXB   n[        U5      nU R                  U   U:X  a  UR                  [        S5      U-  5        GOX R                  ;   aF  [        S5      U-  n	UR                  R                  U	5        U R                  R                  U5        GOX R                  ;   a  U R                  U   n
U
c  [        S5      U-  n	O[        XJ   5      n[        S5      X4-  n	UR                  R                  U	5        U R                  R                  U5        [        [        XBU R                  U R                  U R                  5      5      nXR                  U'   GOU R                  U   [        :X  Ga  UR                  [        S5      U-  5        U" U5        [        UUU R                  U R                  U R                  U R                  5      u  pnU R                   (       aO  U R"                  R%                  5       R'                  5       U:X  a#  UR                  R)                  S5        SU l        OSSUR+                  S	S
5      0nUR-                  US5          [/        UUUUUU R0                  U R"                  S9  S S S 5        U R0                  (       d  U[L        :g  n[:        RN                  " US5      n[:        RP                  " SSU0UD6nU R"                  RS                  XM   RU                  5       XN   RU                  5       5        U RW                  UU5      nOS nUbs  UU   R'                  5       U R                  U'   UR)                  S[Y        U5      -  5        UU   R[                  5       (       a  UR]                  [        S5      U-  5        OU R0                  (       d8  UR]                  [        S5      U-  5        U R                  R                  U5        XR                  U'   UR)                  SU-  5        O.UR                  [        S5      XU R                  U      4-  5        U(       d  U R_                  5         g g ! [2        R4                   a    U R6                  (       a  [2        R8                  " S5      eU R0                  (       a  e UR                  [        S5      5         [:        R<                  " U5        O/! [2        R>                   a    [A        U5        [C        U5        e f = fSU l"        U RG                  5         [H        RJ                  " XM   U R"                  S9  [/        UUUUUU R0                  U R"                  S9   GNf = f! , (       d  f       GN= f)Ns   already rebased %s
sI   note: not rebasing %s and its descendants as this would cause divergence
s+   note: not rebasing %s, it has no successor
s4   note: not rebasing %s, already in destination as %s
s   rebasing %s
s   resuming interrupted rebase
F)r+  s
   forcemergetoolr,   r6   )r  sD   hit merge conflicts; rebasing that commit again in the working copy
)wceditforms   rebased as %s
sR   note: created empty successor for %s, its destination already has all its changes
sC   note: not rebasing %s, its destination already has all its changes
s   next revision set to %d
s   already rebased %s as %s
r+   )0r<   rU   rd   rV   r   r   r   ry   rj   r   rx   r3  
adjustdestrh   r   defineparentsrb   r  p1r   r   rk   r  
rebasenoderl   r   InMemoryMergeConflictsErrorr{   ConflictResolutionRequiredr	   bailifchangedr   r   r   rz   r  mergemodr   r   mergeeditformgetcommiteditor
setparentsr2  r<  r   isemptyr   r   )r   r   r   
progressfnr<   rU   rd   r2   descr   succsuccdescr  rD  p2baser  mergingrA  r.  r;  s                        r-   r!  rebaseruntime._rebasenode=  s   DGGTYY$i}::c?c!IIa/0478>>>5 	  GGNN3LLS!???>>sCD|GH4O#DJ/L$% GGNN3LLS! 4dllDJJMD #JJsOZZ_'IIa()D01sO(

;;LBD {{tyy||~113r9>?#3TXXfc5JK	&&y)<)"   NN!% =V >>-"00)D 00K(KdK 		$$TX]]_dhmmoF,,S&9 ""&w-"3"3"5

3+eGn<==((**GGI 	 ~~GG5 	 LL$$S)"$

35:;II/0Dtzz#:O3PP 
  U !<< ;;"'"B"B9"MM>> "		!F"#11$7${{ "'-,T2!" ).//1 TYY?"   NN!%/ =<sD   ?U?#Q//A'U<S.-U<.,TAU<8U?;U<<U??
Vc                   U R                   U R                  U R                  p2nUR                  S[        R
                  " U5      5      nUR                  5         U R                  (       Ga}  [        U[        U R                  5      U R                  U R                  U R                  U R                  5      u  pVnUR                  S5      nSn	U R                  (       a  U R                  n
OISn
[!        U R                  5       H,  nXR                  ;  d  M  U
SX   R#                  5       -  -  n
M.     Sn[$        R&                  " XS9n[)        U R                  5      nU R*                  R-                  X   R/                  5       XR0                     R/                  5       5        U R3                  XU
S9nUb3  X   R5                  5       nU R                   H  nXR                  U'   M     S	UR7                  5       ;   a!  [9        XR                  U R                  40 UD6  U R                  R                  U R:                  U R:                  5      nUS
:  a  U R:                  nUUS    R=                  5        Vs/ s H  nUR5                  5       PM     sn;  a3  UR?                  [A        S5      5        [B        RD                  " UU   5        S nU R                  (       a  U RF                  (       d  Wn[I        UUU R                  U R                  U R                  UU RF                  UU RJ                  S9	  [M        U5        [O        U5        UR?                  [A        S5      5        [P        RR                  " URU                  S5      SS9  U R                  (       a2  [W        U R                  5      nUR?                  [A        S5      U-  5        URY                  5         U RZ                  (       ak  U RZ                  UR\                  ;   aP  US   R/                  5       UR\                  U RZ                     :X  a!  [^        R`                  " XRZ                  5        g g g g s  snf )Nr6   edits   rebase.collapses   Collapsed revisions   
* %sT)rW  rA  )r-     qtipr   s0   update back to initial working directory parent
)fmr   s   rebase completed
s   undoignoremissings   %d revisions have been skipped
   .)1r<   rU   rd   	formatterr   rn   	startitemrl   rC  minr   rh   rj   rx   rk   ro   r   r0  r	   rK  r3  r  rL  r2  rf   r<  r   tagsupdatemqre   parentsr#  r   rI  r   rt   clearrebasedrs   r   r   r    
unlinkpathsjoinrK   endrg   
_bookmarksr   activate)r   r<   rU   rd   rY  rD  rR  _baseeditoptrA  r-  rebasedr.  
revtoreuser;  r   r   newwdr9  collapsedas
skippedlens                        r-   _finishrebaserebaseruntime._finishrebase  sK   DGGTYY$\\)X%9%9$%?@
>>>)DJJ

;;MBE hhv&G)H ,,	1	%djj1Gll2!Y1J1J1L%LL	  2 ,,'MFTZZJII  $}}2E2J2J2LM((i ) G "**,"jjF)/JJv& ) diik!T::t||<t< 

t@19OOE$t**<*<*>?*>Q*>??GGAJKLOODK(>>$**!KLLJJLLJJ<<
	
 	D
'()

7+4@<<T\\*JGGA9:ZGH
 ##t6T
!T__T5H5H%IIt%8%89 J 7  = @s   6Qc                h  ^ U R                   m U R                  R                  5        VVs/ s H*  u  pVUS:  d  M  Xe:w  d  M  X`R                  U   :w  d  M(  UPM,     nnnU Vs/ s H  nTU   R	                  5       (       a  M  UPM!     n	nSn
U	(       aJ  TR
                  R                  [        S5      SR                  U4S jU	 5       5      -  [        S5      S9  Sn
[        5       nU(       a$  [        TR                  R                  U5      5      nU[        U5      -
  (       a&  TR
                  R                  [        S	5      5        Sn
U
(       a  U(       a/  TR                  S
U5       Vs/ s H  oR                  5       PM     nn[        U5      nUR                  U R                  R                  5       5        U(       d  UR                  U R                   5        TS   R#                  5       U;   nU(       d*  U(       a#  [$        R&                  " TU R                      5        U(       a!  [(        R*                  " TR
                  TWUS9  U R,                  (       a;  U R,                  TR.                  ;   a!  [0        R2                  " TU R,                  5        [5        T5        [7        T5        U(       d$  TR
                  R                  [        S5      5        gs  snnf s  snf s  snf ! [5        T5        [7        T5        U(       d%  TR
                  R                  [        S5      5        f f = f)z-Restore the repository to its original state.r   Ts-   warning: can't clean up public changesets %s
   , c              3  @   >#    U  H  n[        TU   5      v   M     g 7fr?   bytesr   r   r<   s     r-   r   'rebaseruntime._abort.<locals>.<genexpr>/  s      CAtAw   s    see 'hg help phases' for detailsr   FsD   warning: new changesets detected on destination branch, can't strip

   roots(%ld)r\  r   s   rebase aborted
)r<   r   r   rh   mutablerU   r   r   r   ri   r   descendantsr2  r   r   r   re   r   rI  clean_updater   striprg   rg  r   rh  r   r   )r   r   r   r{   r   r   srk  r   	immutablecleanupr}  r9  strippointsupdateifonnodesshouldupdater<   s                   @r-   r   rebaseruntime._abort  s    yyA	5 !JJ,,..DA6 f )*ll1o)= .  
 %,EGq47??3DGIEGGHjj C CCD>?  
  %K!$.."<"<W"EFS\)=  *.((='*J#*JQ*J   # #&g,&&t||':':'<=
 $''8#Dz~~/?B ,))$t*?@ LL$FK""t':':doo'M""4)<)<= T"Q234{
 F0#8 T"Q234 sN   K- KKKKK- $K#K#
C%K- /K(DK- K- -AL1)rc   rg   rs   rl   ro   r\   rh   r{   rf   rq   rz   ru   rt   rx   ry   rd   re   ra   rb   rw   rj   r   r~   rU   r  )FFNr?   )TFFF)__name__
__module____qualname____firstlineno____doc__r   propertyr<   r   r   r   r   r   r   r  r  r(  r<  r!  rp  r   __static_attributes__r+   r,   r-   rX   rX      ss    </@b  %1,6$KZ,4 LQ D2h
 +2Z:xL\O:bFr,   rX   r6      s   sources5   rebase the specified changesets and their descendantss   REV   bs   bases=   rebase everything from branching point of specified changeset   rs   revs   rebase these revisions   d   destr,   s#   rebase onto the specified changesetr   s   collapse the rebased changesets   ms   messages#   use text as collapse commit messages   TEXT   es   edits    invoke editor on commit messages   ls   logfiles&   read collapse commit message from files   FILE   kr   s   keep original changesetsr   s   keep original branch names   Ds   detachs   (DEPRECATED)   is   interactive   t   tools   specify merge tools   stops   stop interrupted rebase   cs   continues   continue an interrupted rebase   as   aborts   abort an interrupted rebases   auto-orphanssL   automatically rebase orphan revisions in the specified revset (EXPERIMENTAL)s>   [[-s REV]... | [-b REV]... | [-r REV]...] [-d REV] [OPTION]...)helpcategoryc           	        U R                  SS5      n[        R                  " USSS5      nU(       a2  [        R                  " X$SS/5        [        R                  " X$/ SQ5        [        R                  " USS5        [        R                  " US	S
S5        U(       d  UR	                  5       b  SnUR                  S5      (       ap  [        U5      S1-
  n[        R                  " USU5        [        UR                  UR                  S5      5      5      n[        R                  " SU5      /US	'   SUS'   UR                  S5      (       d  UR                  S5      (       a  [        XXB5      $ US:X  Ga  [        X5      nUR                  5          UR                  5          UR                  5         UR                   (       a  ["        R$                  " ['        S5      5      e[(        R*                  " U[(        R,                  5      nUR.                  (       d.  U(       d'  ["        R$                  " ['        S5      ['        S5      S9e[0        R2                  " XR4                     5        UR7                  5          SSS5        SSS5        gU(       a,   SS0n	U R9                  U	S5         [;        XXBUS9sSSS5        $ [;        XXB5      $ ! , (       d  f       O= fSSS5        g! , (       d  f       g= f! , (       d  f       g= f! ["        R<                   aV    U R                  SS5      (       a  e U R?                  ['        S5      5        [A        U5        [C        U5        [;        XXBSS9s $ f = f)a9  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.

Published commits cannot be rebased (see :hg:`help phases`).
To copy commits, see :hg:`help graft`.

If you don't specify a destination changeset (``-d/--dest``), rebase
will use the same logic as :hg:`merge` to pick a destination.  if
the current branch contains exactly one other head, the other head
is merged with by default.  Otherwise, an explicit revision with
which to merge with must be provided.  (destination changeset is not
modified by rebasing, but new changesets are added as its
descendants.)

Here are the ways to select changesets:

  1. Explicitly select them using ``--rev``.

  2. Use ``--source`` to select a root changeset and include all of its
     descendants.

  3. Use ``--base`` to select a changeset; rebase will find ancestors
     and their descendants which are not also ancestors of the destination.

  4. If you do not specify any of ``--rev``, ``--source``, or ``--base``,
     rebase will use ``--base .`` as above.

If ``--source`` or ``--rev`` is used, special names ``SRC`` and ``ALLSRC``
can be used in ``--dest``. Destination would be calculated per source
revision with ``SRC`` substituted by that single source revision and
``ALLSRC`` substituted by all source revisions.

Rebase will destroy original changesets unless you use ``--keep``.
It will also move your bookmarks (even if you do).

Some changesets may be dropped if they do not contribute changes
(e.g. merges from the destination branch).

Unlike ``merge``, rebase will do nothing if you are at the branch tip of
a named branch with two heads. You will need to explicitly specify source
and/or destination.

If you need to use a tool to automate merge/conflict decisions, you
can specify one with ``--tool``, see :hg:`help merge-tools`.
As a caveat: the tool will not be used to mediate when a file was
deleted, there is no hook presently available for this.

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

.. container:: verbose

  Examples:

  - move "local changes" (current commit back to branching point)
    to the current branch tip after a pull::

      hg rebase

  - move a single changeset to the stable branch::

      hg rebase -r 5f493448 -d stable

  - splice a commit and all its descendants onto another part of history::

      hg rebase --source c0c3 --dest 4cf9

  - rebase everything on a branch marked by a bookmark onto the
    default branch::

      hg rebase --base myfeature --dest default

  - collapse a sequence of changes into a single commit::

      hg rebase --collapse -r 1520:1525 -d .

  - move a named branch while preserving its name::

      hg rebase -r "branch(featureX)" -d 1.3 --keepbranches

  - stabilize orphaned changesets so history looks linear::

      hg rebase -r 'orphan()-obsolete()' -d 'first(max((successors(max(roots(ALLSRC) & ::SRC)^)-obsolete())::) + max(::((roots(ALLSRC) & ::SRC)^)-obsolete()))'

Configuration Options:

You can make rebase require a destination if you set the following config
option::

  [commands]
  rebase.requiredest = True

By default, rebase will close the transaction after each commit. For
performance purposes, you can configure rebase to use a single transaction
across the entire rebase. WARNING: This setting introduces a significant
risk of losing the work you've done in a rebase if the rebase aborts
unexpectedly::

  [rebase]
  singletransaction = True

By default, rebase writes to the working copy, but you can configure it to
run in-memory for better performance. When the rebase is not moving the
parent(s) of the working copy (AKA the "currently checked out changesets"),
this may also allow it to run even if the working copy is dirty::

  [rebase]
  experimental.inmemory = True

Return Values:

Returns 0 on success, 1 if nothing to rebase or there are
unresolved conflicts.

r6   s   experimental.inmemoryabortstopcontinuer   dry_run)r   sourcerS  r  r   r  rS  NFauto_orphanss   %ld and orphan()s   _destautoorphanrebase(SRC)r  s!   cannot stop in --collapse sessions<   cannot remove original changesets with unrebased descendantss^   either enable obsmarkers to allow unstable revisions or use --keep to keep original changesetsr   r   r6      singletransactionT)rz   r&   r'   s?   hit merge conflicts; re-running rebase without in-memory merge
)"rr   r	   check_at_most_one_argcheck_incompatible_argumentscurrenttransactionrk   ri   listrH   r   
formatspec_dryrunrebaserX   wlocklockr   rl   r   rL   r   r   r   allowunstableoptrt   rI  r~  re   rp  r  	_dorebaserF  r   r   r   )
rU   r<   rd   rz   r7   disallowed_optsuserrevsrbsrtallowunstabler  s
             r-   rebaser  e  s   x }}Y(@AH**4&*MF,,9i0	
 	,,;	
 !!$	9=!!$x@((*6 xxd)~&66,,./	
 		$((>":;<!,,-@(KLU4Vxx	dhhy11Rv44	6	d'ZZ\499;!&&q)M'NOO$..tX5N5NOMKK=&&2 &
 
 !!$'7'7"89!+ '\\, 
	E ;DAI""9i8 6(K 98 600U ';\\\6 9800 	E}}X'FGGGG  T"RveDD	EsV   K#!CK	9K#L (K43	L 	
K	K##
K14
L>L L A'M/.M/c                R   [        XSSUS9nUR                  S5      nU(       a  U R                  [        S5      5        OU R                  [        S5      5        UR	                  5          UR                  5          Sn SS0nU R                  US5         [        U UUUU5      nU[        5       :X  aG  SnUsS S S 5        U(       a!  UR                  SSSUR                  S	5      S
9  sS S S 5        sS S S 5        $  S S S 5        U(       a_  U R                  [        S5      5        U R                  [        S5      5      (       d  UR                  5         OUR                  SSSUS9  SnOU R                  [        S5      5         U(       a!  UR                  SSSUR                  S	5      S
9  S S S 5        S S S 5        g! , (       d  f       N= f! [        R                   aU    U R                  [        S5      5         U(       a!  UR                  SSSUR                  S	5      S
9  S S S 5        S S S 5        g[        R                   a    Sne f = f! U(       a"  UR                  SSSUR                  S	5      S
9  f f = f! , (       d  f       O= fS S S 5        g ! , (       d  f       g = f)NT)rz   r{   rd   r   s   starting in-memory rebase
s8   starting dry-run rebase; repository will not be changed
r  r6   Fr  )r   r   r   r{   s   rebase completed successfully
s!   apply changes (yn)?$$ &Yes $$ &No)r   r   r   r   sW   dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase
r   s   hit a merge conflict
r*   )rX   rk   r   r   r  r  r  _origrebaser.   r   promptchoicerp  r   rG  r   )	rU   r<   r7   rd   r  r   
needsabortr  ress	            r-   r  r  n  sr   $T$TJEhhy!G
		!234
		JK	
 
tyy{
1	:DAI""9i8! *,,!&J 98P --  "88I.	 . ] #{ - 9$ 		!>?@q)M'NOO'')11 $$"& '	 2  #
		B --  "88I.	 . ] # 98 // 	IIa1236 --  "88I.	 . ] #$ {{ 	J	4 --  "88I.	 .  Y #{s   *J;I>?G!F=6	G?(I>'	J;GB I(I>,J=
GG.I<I=(I>%J6II+I;;I>>
J	J
J&c                0    [        XXCS9n[        XX#U5      $ )N)rd   )rX   r  )rU   r<   r7   rd   rz   r  s         r-   r  r    s    $H8Eru55r,   c                0   US:w  d   eUR                  5          UR                  5          UR                  S5      (       aG   [        R                  " S5      (       a  SnSW-  n[        S5      U-  n[        R                  " U5      eUR                  (       a0  UR                  (       d  [        R                  " [        S5      5      eU(       a  UR                  (       a  [        R                  " [        S	5      5      eUS
:X  a1  UR                  SS5      (       a  U R                  [        S5      5        US:X  a5  [        R                  R                  U5      n[        R                   " U5        UR#                  US
:H  S9n	U	b  U	sS S S 5        sS S S 5        $ OUR                  S5      n
[%        U UUR&                  UR                  SS 5      UR                  S/ 5      UR                  S/ 5      UR                  S/ 5      U
S9nUR)                  U5      n	U	b  U	sS S S 5        sS S S 5        $ [+        XR                  5        S nU R-                  SS5      nU(       a  UR/                  S5      n[0        R2                  " U5         UR5                  U5        UR6                  (       d  UR9                  5         S S S 5        S S S 5        S S S 5        g ! [
         a    Sn GNf = f! , (       d  f       N2= f! , (       d  f       N;= f! , (       d  f       g = f)Nr  interactives   histeditr,   s    --config extensions.histedit=s   hg%s help -e histeditsO   interactive history editing is supported by the 'histedit' extension (see "%s")s+   message can only be specified with collapses*   cannot use collapse with continue or abortr  r?  Fs   tool option will be ignored
r  r   
_destspacer  r  rS  r   r:   r6   r  )r  r  rk   r   findKeyErrorr   r   r   ro   rl   r   mergestatemodr   r   r   checkunresolvedr   _definedestmaprz   r  storecollapsemsgrr   transactionr    acceptinterventionr(  r{   rp  )rU   r<   r7   rd   r  enablehistedithelpr   msretcoder:   rh   r   singletrs                 r-   r  r    s   V	tyy{88M""C??;//%(N ,n<D9 	  ""3''U__""@A  &&CD   TXXfe%<%<:;<#"--2248))"-33Vw=N3PG"G #{D #
 .I$&2&$##	G --g6G"i #{j T#4#45==,@A!!),B
 $$R(  $<<##% )A #
  C!BCv )(A #{sy   LK6KD)K6	LBK6	L/AK63K%9K6LK"K6!K""K6%
K3/K66
L	 L
Lc           	     
  ^ Uc  / n[         R                  " T5        U(       d  [         R                  " T5        U R                  SS5      (       a.  U(       d'  [        R
                  " [        S5      [        S5      S9eSnU(       a;  [        R                  " TU5      n	U	(       d  U R                  [        S5      5        gGOU(       aM  [        R                  " TU5      n
U
(       d  U R                  [        S5      5        gTR                  S	X5      n	GOR[        R                  " TU=(       d    S
/5      nU(       d  U R                  [        S5      5        gU(       a  [        R                  " TU5      nOT[        TXS9   n[        U5      n/ n0 nU HI  nTR                  SXR                  5       5      R                  5       nUR!                  U/ 5      U/-   X'   MK     SU;   a  UR#                  5         UR%                  5        H%  u  nnU['        TR                  SUU5      5      -  nM'     TR                  SU5      n	U	(       Gd  ['        U5      UR                  5       /:X  aA  U(       a  U R                  [        S5      U-  5        gU R                  [        S5      5         gTR                  SXR                  5       5      (       d_  U(       a9  U R                  [        S5      SR)                  U4S jU 5       5      U4-  5        gU R                  [        S5      U-  5         gU R                  [        S5      SR)                  U4S jU 5       5      U4-  5        g[*        U	;   a  [        R
                  " [        S5      5      eTS
   R                  5       U	;   nU R-                  SSUUS9  U(       a3  U(       a,  [         R                  " T5        [         R                  " T5        U(       d  T[        TXS9   n[        U5      n[.        R0                  " SU	5      nSU0nUc   [2        R                  " TUUS9nUb#  UR                  5       nU	 Vs0 s H  nUU_M     nnW(       d  U R                  [        S(5      5        gU$ ! [        R4                   a    0 nU	 H  n[.        R0                  " S U5      US!'   TR7                  U/S"US#9n[9        U5      nUS$:X  a  UR                  5       UU'   MU  US%:X  a"  U R;                  [        S&5      TU   -  5        M}  [        R
                  " [        S'5      TU   -  5      e    GN	f = fs  snf ))z:use revisions argument to define destmap {srcrev: destrev}N   commands   rebase.requiredests   you must specify a destinations   use: hg rebase -d REVr   s-   empty "rev" revision set - nothing to rebase
s0   empty "source" revision set - nothing to rebase
s   (%ld):: + (%ld)r\  s5   empty "base" revision set - can't compute rebase set
r  s   ancestor(%d, %d)s   children(%d) & ancestors(%ld)s   %ld::s6   nothing to rebase - %s is both "base" and destination
sA   nothing to rebase - working directory parent is also destination
s
   %ld - ::%dsG   nothing to rebase - "base" %s is already an ancestor of destination %s
   +c              3  @   >#    U  H  n[        TU   5      v   M     g 7fr?   ru  rw  s     r-   r   !_definedestmap.<locals>.<genexpr>R  s     $BTU47^^Try  sV   nothing to rebase - working directory parent is already an ancestor of destination %s
s    nothing to rebase from %s to %s
c              3  @   >#    U  H  n[        TU   5      v   M     g 7fr?   ru  rw  s     r-   r   r  `  s      >AtAwry  s   cannot rebase the working copyr6   s!   rebasing working copy parent: %r
)rebase_rebasing_wcps   %lds   ALLSRC)
localaliasr   s   SRCT)r/  r  r*   r   s    skipping %s - empty destination
s'   rebase destination for %s is not uniques&   nothing to rebase - empty destination
)r	   checkunfinishedrH  rr   r   r   r   r   revranger   rH   	revsingler=   rv  r   rI   rk   clearr   r  r   r   r  r   r  r   r   anyrevsrK   r#  )rU   r<   rz   destfsrcfbasefrevfr:   r  r  rO   rS  rootsbpbasebbpbsrebasingwcpallsrcaliasrh   r   destsetsizer   s    `                       r-   r  r    s   |
 D!d#	}}["788/0+,
 	

 D''d3	IIaIJK  
!!$-IIaLMNII0#;	""44&9IIOP ''e4DD$DED$KEA.88:>DDFBB+qc1FJ  6> LLNllnFBT$))$Db"MNNE % IIh.	 Dzdhhj\)II2 	L = II<< 1 YY}dHHJ??II$
  99$BT$BBDIJ,  II<
  	 		:;yy > >>EF )q!BCDDt*.."i/KFF-'	   K%d#KiEFd""695FE|	$$T5UCD& ((*'01y!1g:y1
		!>?@N7 $$ 	G * 5 5eQ ?f ,,wTe,L7|19!(GAJQYGGABCd1gMN**DEQO  	* 2s   2R UB<UUc           
        [        5       n[        U5      nU Hn  nXT:X  a  M
  X   R                  5        HN  nUR                  5       U;  d  M  UR                  5       U;  d  M/  UR	                  UR                  5       5        MP     Mp     U(       d  [
        $ [        U5      S:X  a  UR                  5       $ [        R                  " [        S5      [        U5      SR                  S [        U5       5       5      4-  5      e)zReturn the revision that should be used as the second parent
when the revisions in state is collapsed on top of destancestors.
Abort if there is more than one parent.
r*   sK   unable to collapse on top of %d, there is more than one external parent: %srs  c              3  ,   #    U  H
  nS U-  v   M     g7fr   r+   )r   r  s     r-   r   !externalparent.<locals>.<genexpr>  s     )M_%!)_r   )ri   r_  rb  r   r   r   rK   r   r   rL   r   r3  r   r   )r<   r   r  rb  r  r   r  s          r-   r   r     s    
 eGZF=""$Auuwe#}(DAEEG$ %  
7|q{{}


	,	
 }uzz)MVG_)MM
N		O r,   c           	        SnSU;   a  US   nUR                  5         UR                  UUUUUUS9nUR                  5       (       a"  U R                  R	                  SS5      (       d  gU R                  U5      n	UR                  5         U	$ )zTCommit the memory changes with parents p1 and p2.
Return node of committed revision.Nr0   )r\   r3   r/  r1   r.  r+  r,  )_compacttomemctxrM  rU   rr   	commitctxclean)
r<   r  r.  r3   r/  r\   r-  r1   memctx	commitress
             r-   r6  r6    s    
 FEy!
 	MMO]]  F ~~ 2 25:M N Nv&IJJLr,   c           	     R  ^  [         R                  nT R                  R                  SS5      (       d  U 4S jnU" 5          T R	                  XSXBUS9nT R
                  R                  T U   R                  5       T R                  5       5        UsSSS5        $ ! , (       d  f       g= f)zPCommit the wd changes with parents p1 and p2.
Return node of committed revision.r6   r  c                 &   > T R                  S5      $ )Nr6   )r  r<   s   r-   <lambda>commitnode.<locals>.<lambda>  s    T%%i0r,   )textr/  r\   r3   r.  N)	r    nullcontextmanagerrU   rr   commitdirstate	setbranchr1   r  )r<   r.  r3   r/  r\   r-  r   r;  s   `       r-   r7  r7    s     
	 	 B77i)=>>0	++Df  
 	M  "D$;$;$=	
  
s    AB
B&c                  ^  T U   nUR                  5       (       a"  UR                  U5        [        R                  nOT S   R	                  5       U:w  a6  T R
                  R                  SX'4-  5        [        R                  " U5        OT R
                  R                  S5        U 4S jnT S   nT R                  R                  T R                  5       5        T U   n	T R
                  R                  SX4-  5        Ub#  T R
                  R                  SUT U   4-  5        U" 5          T R                  R                  UR                  5       U	R                  5       5      n
[        R                  " T USSUU
/ S	QUS
9nUR!                  UR                  5       T U   R                  5       5        U(       a  ["        R$                  " XiU5        O%["        R$                  " XiU	R'                  5       5        SSS5        WR(                  S:  a@  UR                  5       (       a  [*        R,                  " 5       e[*        R.                  " S5      eg! , (       d  f       N_= f)zFRebase a single revision rev on top of p1 using base as merge ancestorr\  s    update to %d:%s
s    already in destination
c                 :   > T R                   R                  T 5      $ r?   )r  changing_parentsr  s   r-   r  rebasenode.<locals>.<lambda>  s    66t<r,   Ns    merge against %d:%s
s      detach base %d:%s
T)r  r  s   parent of source)branchmergeforceancestormergeancestorlabelsr@  r   r6   )
isinmemorysetbaser    r  r   rU   r   rI  r~  r  r   r  r   
isancestorr2  _updaterL  r   graftcopiesrD  unresolvedcountr   rF  rG  )r<   r   rD  rR  rS  r[   r  p1ctxscoper2   r  statss   `           r-   rE  rE    s    HEU'':>>r!GGMM/2+=>!!%(GGMM67< DzD3356
s)CGGMM+sj89/4d2DDE	11%**,
K  '<	
 	

d2hmmo6t%0
 t#&&(3) 
, q ??3355229==	 !- 
s   +CI
Ic                   X!   nUR                  5        VVs/ s H   u  pgUS:  d  M  X&   U:X  d  M  Xd;  d  M  UPM"     nnn/ n	U R                  R                  U5       Hx  n
UnU
[        :w  a'  U R	                  SX5      R                  5       nUb  X<   nX:X  a,  XS;   a'  X5   nU[        :X  a  [        R                  " SU-  5      eU	R                  U5        Mz     U	$ s  snnf )a  adjust rebase destination given the current rebase state

rev is what is being rebased. Return a list of two revs, which are the
adjusted destinations for rev's p1 and p2, respectively. If a parent is
nullrev, return dest without adjustment for it.

For example, when doing rebasing B+E to F, C to G, rebase will first move B
to B1, and E's destination will be adjusted from F to B1.

    B1 <- written during rebasing B
    |
    F <- original destination of B, E
    |
    | E <- rev, which is being rebased
    | |
    | D <- prev, one parent of rev being checked
    | |
    | x <- skipped, ex. no successor or successor in (::dest)
    | |
    | C <- rebased as C', different destination
    | |
    | B <- rebased as B1     C'
    |/                       |
    A                        G <- destination of C, different

Another example about merge changeset, rebase -r C+G+H -d K, rebase will
first move C to C1, G to G1, and when it's checking H, the adjusted
destinations will be [C1, G1].

        H       C1 G1
       /|       | /
      F G       |/
    K | |  ->   K
    | C D       |
    | |/        |
    | B         | ...
    |/          |/
    A           A

Besides, adjust dest according to existing rebase information. For example,

  B C D    B needs to be rebased on top of C, C needs to be rebased on top
   \|/     of D. We will rebase C first.
    A

      C'   After rebasing C, when considering B's destination, use C'
      |    instead of the original C.
  B   D
   \ /
    A
r   s   max(%ld and (::%d))s-   rev %d should be rebased already at this time)
r   r   
parentrevsr   rH   rI   r   r   ProgrammingErrorappend)r<   r   rh   r   rj   r  r  r   r  r  prevadjusted	candidates                r-   rB  rB    s    j <D KKM!DAq5 	
Z4' 	
,-,< 	
!   F))#.7?		"8&GMMOI$ +{H7",,DtK  	h / M+s   CCCCc                
  ^  [         R                  " T [         R                  5      nX#-
  nU(       aR  U(       dJ  U 4S jU 5       n[        S5      n[        S5      n[        R
                  " USR                  U5      4-  US9egg)a  
Abort if rebase will create divergence or rebase is noop because of markers

`rebaseobsrevs`: set of obsolete revision in source
`rebaseobsskipped`: set of revisions from source skipped because they have
successors in destination or no non-obsolete successor.
c              3  @   >#    U  H  n[        TU   5      v   M     g 7fr?   ru  rw  s     r-   r   "_checkobsrebase.<locals>.<genexpr>s  s     F-EU47^^-Ery  s+   this rebase will cause divergences from: %ssJ   to force the rebase please set experimental.evolution.allowdivergence=True   ,r   N)r   r   r   r   r   rL   r   )	r<   rU   rebaseobsrevsrebaseobsskippeddivergenceokdivergencebasecandidates	divhashesr   hs	   `        r-   r   r   f  s~     %%dH,G,GHL,?F-EF	>?;
 sdii	&:%<<1EE )5r,   c              #     #    U R                   b   eU R                  R                  R                  n[        R
                  " U R                  X   R                  5       /5       H  nU" U5      nUc  M  Uv   M     g7f)z,yield revision numbers for successors of revN)r   r   indexget_revr   allsuccessorsobsstorer2  )rM   r   r$  r  r   s        r-   successorrevsr'  |  se     ??"""nn""**G""4==49>>3C2DEAJ=G Fs   A.A=4	A=c           	     \  ^ ^^^^^ T R                   b   eT R                  nUR                  mUT   nT R                  R                  T5      n[        [        /m[        T TX#U5      m[        U5      n	[        S USS  5       5      (       a
  TS   TS'   GOX[        U5       H  u  mn
U
n[        UUU4S j[        T U
5       5       5      (       a  TT   nOX;   a  X:   S:  a  X:   n[        TST 5       HO  u  pU[        :X  a  M  T" X5      (       a  [        nM&  T" X5      (       d  M5  UTU'   [        nU	T   X   sX'   U	T'   MQ     UTT'   M     TS   [        :w  aL  US   TS   :X  a@  [        T5      S:X  a  [        U5      S:X  d   eTR                  5         U	R                  5         [        T5      [        U5      :X  a-  UT;  a'  [        R                  " [!        S5      TT T   4-  5      e[        UU4S jT 5       5      (       a  [        R                  " [!        S	5      5      e[#        U4S
 j[        U	5       5       5      S:  Ga  SS/n[        U	5       H  u  mnU[        :X  d  UT;   a  M  [        U	5      U1-
  n[        T R%                  SUX5      5      nU(       d  ML  UR'                  5        VVs/ s H  u  nnUS:  d  M  UU;  d  M  UPM     nnnU Vs/ s H#  nUR                  U5      S   [        :w  d  M!  UPM%     nn[        T R%                  SUUU5      5      UT'   M     [        S U 5       5      (       a  [)        S [        U5       5       5      u  nmUS:  aL  [!        S5      R+                  U 4S jU 5       5      n[        R                  " [!        S5      TT T   U4-  5      eTS:w  a/  TT   [        :w  a  TT   TS   sTS'   TT'   U	T   U	S   sU	S'   U	T'   U	S   nT R,                  R/                  S[1        T5      -  5        TS   TS   U4$ s  snnf s  snf )a  Return new parents and optionally a merge base for rev being rebased

The destination specified by "dest" cannot always be used directly because
previously rebase result could affect destination. For example,

      D E    rebase -r C+D+E -d B
      |/     C will be rebased to C'
    B C      D's new destination will be C' instead of B
    |/       E's new destination will be C' instead of B
    A

The new parents of a merge is slightly more complicated. See the comment
block below.
Nc              3  2   #    U  H  o[         :H  v   M     g 7fr?   r   r   s     r-   r    defineparents.<locals>.<genexpr>  s     
+A<s   r*   r   c              3  <   >#    U  H  nT" UTT   5      v   M     g 7fr?   r+   )r   rD   rP   r   r
  s     r-   r   r+    s!     K4Jq:aq**4Js   r   s>   cannot rebase %d:%s without moving at least one of its parentsc              3  T   >#    U  H  o[         :g  =(       a	    T" TU5      v   M     g 7fr?   r*  )r   r  r
  r   s     r-   r   r+    s"     
>1<.JsA..s   %(!   source is ancestor of destinationc              3  N   >#    U  H  o[         :w  d  M  UT;  d  M  S v   M     g7f)r*   Nr*  )r   r  newpss     r-   r   r+    s     
DjL1Qe^11js   %%	%s   (%ld %% (%d+%d))s   %ld - (::%ld) - %ldc              3  (   #    U  H  oS Lv   M
     g 7fr?   r+   )r   rH   s     r-   r   r+    s     5HD4Hs   c              3  J   #    U  H  u  pUc  M
  [        U5      U4v   M     g 7fr?   )rK   )r   r   rH   s      r-   r   r+    s&      2GA TA2s   	##s    or c              3  d   >#    U  H%  nUc  M  SR                  U4S jU 5       5      v   M'     g 7f)Nrs  c              3  8   >#    U  H  nS UTU   4-  v   M     g7f)r  Nr+   rw  s     r-   r   *defineparents.<locals>.<genexpr>.<genexpr>$  s     E1x1d1g,6s   )r   )r   rH   r<   s     r-   r   r+  #  s0      / ( FEJJEEEE (s   0"0s4   rebasing %d:%s will include unwanted changes from %ss    future parents are %d and %d
)r   r   isancestorrevr  r   rB  r  allr   anyr'  rK   reverseri   r   r   r   sumrH   r   r_  r   rU   r   tuple)r<   r   rh   r   rj   
obsskippedr8  r  oldpsbasesr  npjrD   unwantedrS  other_basessiderevsr   r   r  mergesr   unwanteddescrP   r   r
  r0  s   ``                      @@@@r-   rC  rC    s1     ??"""	B!!J3<DNN%%c*EgEtS'':EKE

+qr
+++8a0 e$DAqBKM$4JKKK1X1X "%),<b$$ B&&!E!H B */q58&EHeAh - E!H+ %4 8w58uQx#7u:?s5zQ66MMOMMO u:U#E(9"": S	"	#  
>
>>>q!EFGG" 
Dc%j
DDqH$< 'GAtw$%- e*v-K		-{DGH x"'++-"/$!Q1q5AQj=PA-    )(!BMM!,<Q,?7,JAy   #II.&)' (2 5H555 (2 DAq 1u z / (/  
 &&MNDI|45  Av8w&).q58&E!HeAh%*1XuQx"a%( 8DGGMM4uU|CD8U1Xt##_s   :P#P#P#  P)P)c                2   [         R                  R                  U R                  R                  U5      n[	        US5       n[
        R                  " U5       H#  nUR                  S5      (       d  M    SSS5        g   SSS5        g! , (       d  f       g= f)z/Return true if the given patch is in git formatrbs
   diff --gitNTF)ospathr   mqopenr   
linereader
startswith)r<   	patchnamemqpatchfplines        r-   isagitpatchrR  >  so    ggll477<<3G	gt	$$R(D}-- 
	( 
 	 
	 s   .B3B=B
Bc           
        0 nU R                   nUR                  SS n[        5       nUR                   H  nXR                     R                  5       n	X;   aN  U R                  R                  SXR                  4-  5        UR                  [        XR                  5      4XI'   Mr  UR                  UR                  5        M     U(       a  UR                  XR                  5       5        [        USS9 Hp  n	X;  aR  XI   u  pU R                  R                  [        S5      XU	   XU	      4-  5        UR!                  U SU
USX   -  /S9  MZ  UR                  XI   S	   5        Mr     U Vs/ s H*  nUR"                  R%                  US
5      S	   U;  d  M(  UPM,     nnXR                  SS& SUl        UR)                  5         ggs  snf )z9Update rebased mq patches - finalize and then import themNs.   revision %d is an mq patch (%s), finalize it.
T)r9  s   updating mq patch %s to %d:%s
r+   r   )rN  gitr   r   r*   )rJ  
fullseriesri   appliedr2  r   rU   r   namerR  r   finishr   r   r#  r   qimportguard_rer   seriesdirty	savedirty)r<   r   rj   rd   mqrebaserJ  original_seriesskippedpatchesr  r   rW  isgitr  	newseriess                 r-   ra  ra  I  s   H	BmmA&OUNZZ66l <GGMMB-  VV[vv%>?HM qvv&  
		$( (D1C!&m893ZCj)9:; 

"+,   ""8=#34! 2. %
${{  A&q)? $ 	 

 %a
A 2
s   -'GGc                    U=(       d    SnU R                  SS5      nUR                  SU-  5        UR                  5         g)z,Store the collapse message to allow recoveryr,      last-message.txtr   r   N)r   r   close)r<   ro   r   s      r-   r  r    s7    $K$d+AGGGk!"GGIr,   c                8    U R                   R                  SSS9  g)zRemove collapse message filerc  TrZ  N)r   rd  r  s    r-   r   r     s    HH+4@r,   c                     U R                  S5      nUR                  5       R                  5       nUR                  5         U$ ! [         a,    U(       a  Sn U$ [
        R                  " [        S5      5      ef = f)z*Restore previously stored collapse messagerc  r,   s'   missing .hg/last-message.txt for rebase)r   readliner  rd  FileNotFoundErrorr   r   r   )r<   r   r   ro   s       r-   r   r     sv    	MHH()jjl((*		   MK  ++a JKLLMs   ?A A9 A9c                    U R                  5       nU(       a  UR                  S5        U R                  R                  SSS9  g)zRemove the status filesr`   TrZ  N)r  removefilegeneratorr   rd  )r<   r   s     r-   r   r     s:     
	 	 	"B	
~.HHd;r,   c              #    #    [        U 5      nU(       as  [        U5      n/ nU H  nX   U;  d  M  UR                  U5        M      U(       d  [        R                  " [        S5      5      eU[        U5      -  nUv   U(       a  Mr  gg7f)a  yield source revisions in an order that we only rebase things once

If source and destination overlaps, we should filter out revisions
depending on other revisions which hasn't been rebased yet.

Yield a sorted list of revisions each time.

For example, when rebasing A to B, B to C. This function yields [B], then
[A], indicating B needs to be rebased first.

Raise if there is a cycle so the rebase is impossible.
s#   source and destination form a cycleN)ri   r   r  r   r   r   )rh   srcsetsrclistr  r   s        r-   r   r     sw      \F
.Az'a   ""1%K#LMM#f+ &s   +B	AB	B	c                T  ^ UR                  5       nU S   R                  5       nSU R                  5       ;   a  U R                  R                   Vs1 s H  oPUR
                     R                  5       iM!     nn[        UR                  5       5      U-  (       a  [        R                  " [        S5      5      e[        [        U5      5      nU(       d  [        R                  " [        S5      5      e[        U R                  SUS   5      5      nU(       d  [        R                  " [        S5      5      eS n	[        XS9n[        R!                  U["        5      m[%        U5      S	:H  n
U GH/  nXUR                  5             nUR'                  U5      nX:X  a  [        R                  " [        S
5      5      eX:X  a  U S   nXR)                  5       :X  a"  UR+                  5       UR+                  5       :H  nO!UR+                  5       UR+                  5       :H  nU(       dY  U(       aR  XR-                  5       ;   a?  UR                  5       TUR                  5       '   U R.                  R1                  S5        GM  Sn
U R.                  R1                  SX4-  5        GM2     U
(       a  g[        T5       Hd  nU R2                  R5                  U5       Vs/ s H  nU[6        :w  d  M  UPM     nnU(       d  MC  [9        U4S jU 5       5      (       d  M_  UTU'   Mf     XAT4$ s  snf s  snf )z`Define which revisions are going to be rebased and where

repo: repo
destmap: {srcrev: destrev}
r\  rX  s&   cannot rebase onto an applied mq patchs   no matching revisionsrz  r   c                "    U R                  5       $ r?   )r   )r   s    r-   revofbuildstate.<locals>.revof  s    uuwr,   )keyr*   r.  Ns!   source is a child of destination
Fs    rebase onto %s starting from %s
c              3  L   >#    U  H  nTR                  U5      U:H  v   M     g 7fr?   )rk   )r   r  r   s     r-   r   buildstate.<locals>.<genexpr>  s     >g599Q<1,gs   !$)r   r   r`  rJ  rV  r2  ri   r   r   rL   r   r  r   r   r   dictfromkeysr   rK   r  rD  r1   rb  rU   r   r   r  r   r7  )r<   rh   r[   r  re   r  	mqapplied	sortedsrcr  rp  emptyrebaserootr  
commonbaser  
samebranchr   r  rb  r   s                      @r-   r   r     sw    Id!J
 $))+15AA!&&\%%'	Aw~~ 9,""1%N#OPP Z()Iq!9:;; -167Eq!9:;; 5$EMM)W-Ei.A%KDHHJ'(]]4(
""1%I#JKK:Dwwy ![[]dkkm;
![[]dkkm;

t||~/E %)HHJdhhj!CD:d\IJ) * e}"nn77<M<W1<M7s>g>>>E#J	 
 %%g B^ Ns   &L L%&L%c	           
     \   UR                   R                  n	0 n
0 n[        R                  " U[        R                  5      (       + n/ n[        UR                  5       5       H  u  pUS:  d  M  X:w  d  M  U	" U5      nU=(       d    U	" U5      nUUU'   SnX;   a!  U(       d  X   R                  5       (       d  SnOU(       a  UR                  U5        OU4nUc  M{  UU
U4'   M     U(       a  U4U
[        U5      '   U(       a  UR                  nUR                  nUR                  n0 nU
R                  5        H6  u  nnU H*  nU" U Vs/ s H  nU" U5      PM     snSS9UU" U5      '   M,     M8     U" USSS9nUR                  US	9  U(       a  0 n
[        R                  " XS
XS9  gs  snf )ab  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.

If `keepf` is not True, the rebase has --keep set and no nodes should be
removed (but bookmarks still need to be moved).

If `backup` is False, no backup will be stored when stripping rebased
revisions.
r   Nr+   s   node)rW  s   oldnodes   newnodes)rr  value)nodechangesr6   r{  )r   r2  r   r   r   r   r   r  r;  hexfunc
formatlist
formatdictr   r   cleanupnodes)rU   r<   rh   r   rj   rn  rt   rY  r   tonodereplacementsmovesstripcleanupcollapsednodesr   r   oldnoder;  succshfflfdchangesoldnsnewnoldnnr  s                               r-   rc  rc    s   , ^^  FLE))$0I0IJJLNekkm,Q;6=SkG!3VF^G$E'NE~ty'9'9';';E%%g. 
 +0gZ( - /:nU>*+	ZZ]]]]'--/KE4$&t'<t!1t'<7$K4!  0 jD
K(YM (=s   	F)c                   UR                  S5      (       Gah  UR                  SS5      (       a*  [        S5      n[        S5      n[        R                  " XVS9eUR                  5          UR                  5          UR                  S5      (       a  US	 UR                  S5        [        R                  " US	S
9  [        R                  " U[        S5      S9  [        U5      n[        R                  nS n	U	[        l         U " X/UQ70 UD6n
U[        l        [        U5      nX:  aE  SU;   a  US	 SU;   a  US	 [        UR                  R                  US95      nXS'    [!        X40 UD6  SSS5        SSS5        W
$ UR                  S5      (       a  [        R                  " [        S5      5      eU " X/UQ70 UD6n
U
$ ! U[        l        f = f! [        R"                   a~    [$        R&                  " U5      u  pnXS   R)                  5       :X  a  UR+                  [        S5      5         NUR+                  [        S5      5        [,        R.                  " X5         Nf = f! , (       d  f       GN= f! , (       d  f       W
$ = f)zCCall rebase after pull if the latter has been invoked with --rebaser  r  r  s,   rebase destination required by configurations)   use hg pull followed by hg rebase -d DESTr   r   sC   --update and --rebase are not compatible, ignoring the update flag
T)	skipmergesC   cannot pull with rebase: please commit or shelve your changes firstc                     g r?   r+   )r   kwargss     r-   _dummypullrebase.<locals>._dummyY  s    r,   r   r  )startr  r\  r   s%   nothing to rebase - updating instead
Nr?  s%   --tool can only be used with --rebase)rk   rr   r   r   r   r  r  r   r	   r  rH  rK   postincomingr  r   rH   r  NoMergeDestAbortr   
destupdater   r   r
   r   )origrU   r<   r   rd   r   r   revsprepullorigpostincomingr  retrevspostpullr:   r   _a_bs                   r-   
pullrebaser  =  s@   xx==&;<<CDCABD""322ZZ\499;xx!!N)
 ##DD9!!B d)K&33 $*G 823d3d3'7$t9L) D=U t#X !4!4;!4!GH	%.\"22,t,U '\t J	 88F""1%M#NOO2+d+d+J? (8$  -- 	2"*"5"5d";KCR4jnn..		!$:";<		!$M"NO !1	2W ';\\t Jsi   )I::BI(GAI("G.I:GI(AI%0I(20I%"I($I%%I((
I7	2I::
J	c                  ^ 0 n[        5       nU R                  nUR                  R                  n[        U R	                  S5      5      nU H  nUR                  U5      n	[        [        R                  " U R                  U	/5      5      n
U
R                  U	5        U
 Vs1 s H
  o" U5      iM     nnUR                  S5        U
(       a  UR                  U5      (       a  SX8'   M  TU   nU H   nUR                  X5      (       d  M  XU'     M     X;   d  [        U4S jU 5       5      (       d  M  UR                  U5        M     UU4$ s  snf )aU  Figure out what to do about about obsolete revisions

`obsolete_with_successor_in_destination` is a mapping mapping obsolete => successor for all
obsolete nodes to be rebased given in `rebaseobsrevs`.

`obsolete_with_successor_in_rebase_set` is a set with obsolete revisions,
without a successor in destination, that would cause divergence.
s	   extinct()Nc              3  ,   >#    U  H	  oT;   v   M     g 7fr?   r+   )r   r  rh   s     r-   r   )_compute_obsolete_sets.<locals>.<genexpr>  s     /OhWhs   )ri   r   r#  r$  rH   r2  r   r%  r&  removediscardissubsetr6  r8  r   )r<   r  rh   rx   ry   r8  r$  extinctrevssrcrevsrcnode
successorsr  succrevsdstrevsuccrevs     `            r-   r   r     s.    .0*,/E)	BhhGdii-.K''&/..t}}wiHI
'"(23
1GAJ
3X..{;;=A2:V_F###G44EL6B $ (C/Oh/O,O,O9==fE-  2 	/- % 4s    Ec                    UR                  5          UR                  5          [        X5      nUR                  SS9  S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)NTr  )r  r  rX   r   )rU   r<   r  s      r-   abortrebaser    sA    	tyy{d'%%d%3 #{{s!   AAA
A	A
A-c                   UR                  5          UR                  5          [        X5      n[        R                  R                  U5      n[        R                  " U5        UR                  SS9nUb  UsS S S 5        sS S S 5        $ UR                  S 5        UR                  5         S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)NFr  )r  r  rX   r  r   r   r   r  r   r(  rp  )rU   r<   r  r  r  s        r-   continuerebaser    s    	tyy{d'%%**40!!"%///> #{ 	T" #{{s/   CAB;6	C	!B;*C;
C		C
Cc           	     6   UR                   R                  S5      (       d  g  [        X0 5      nUR                  5         UR                  n[        UR                  5        Vs/ s H  oUS:  d  M
  UPM     sn5      nU R                  [        S5      U R                  [        S5      S5      U-  U R                  [        S5      S5      [        U5      U-
  -  4-  5        g ! [
        R                   a    [        S5      nU R                  U5         g f = fs  snf )	Nr`   s8   rebase: (use "hg rebase --abort" to clear broken state)
r   s#   rebase: %s, %s (rebase --continue)
s
   %d rebaseds   rebase.rebaseds   %d remainings   rebase.remaining)r   r   rX   r   r   r   r   r   r   rK   r   label)rU   r<   r  r   r   r   
numrebaseds          r-   summaryhookr    s    88??>**d+ :A6a:;JHH	
12HHQ}%'89JFHHQ')<=5zJ&(
	
    LM
	
 ;s   (C  "	D/D 0DDc           	     f   [         R                  " [        R                  S[        5      nUS   R                  SSS [        S5      45        US   R                  SSS[        S5      45        [        R                  R                  S[        5        [        R                  " SS	S
S
[        [        S9  g )Ns   pullr*   r,   r6   s'   rebase working directory to branch headr  r  s   specify merge tool for rebaser`   T)fnamestopflagcontinueflag	abortfunccontinuefunc)r   wrapcommandr
   tabler  r  r   r	   summaryhooksr   r  r|   addunfinishedr  r  )rU   entrys     r-   uisetupr    s    ""8>>7JGE	!HOO	iq!KLM 
!HOOT7C+K)LMNY4#r,   r?   )F)NFNT)Wr  
__future__r   rH  mercurial.i18nr   mercurial.noder   r   r   	mercurialr   r	   r
   r   r   r   r   r   r   rI  r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r|   r    r   r   r   cmdtablerS   configtable
configitem
testedwithr.   r4   r=   revsetpredicaterE   rQ   rV   rX   
dryrunoptsformatteroptsconfirmoptsCATEGORY_CHANGE_MANAGEMENTr  r  r  r  r  r   r6  r7  rE  rB  r   r'  rC  rR  ra  r  r   r   r   r   r   rc  r  r   r  r  r  r  r+   r,   r-   <module>r     s   # 	  
      B 
 ,


H
%!!+.
 
# #
$
 ++-  
E !
E )*# +#,J JZ 	 FGfI	
 NOfI	
 
vr1676C45fI	
 
k5!$F"GH45gJ	
 
wq!DEF78gJ	
 
wq!<=>	oua(E&FG	y%?!34	~ua&89	wQ456	gua :;<	{E1%F#GH	x"@ AB:		
_8r s9t u:v w;x GH33@BE1C@BE1P<~6
E&P^B48$2>jK\F,u$p3lA
<4@&R 
9NxBJ*Z4	0r,   