
    	^cx                     B   d Z ddlZddlmZ ddlmZ ddlmZmZm	Z	 ddl
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZm Z   G d d	ej!                  Z"i Z# ej$        e#          Z$d
Z%i Z& ej'        e&          Z' e'ddd            e'ddd            G d d          Z( G d d          Z) G d d          Z*d Z+d Z, e$dddd ed           ed          fddg  ed           ed          fd d!d ed"          fd#d$g  ed%           ed          fd&d'g  ed(           ed          fdd)d ed*           ed          fd+d,d- ed.          fddd ed/          fdd0d- ed1          fd2d3d ed4          fddd ed5           ed6          fg ed7          e$j-        8          d9             Z.d: Z/d; Z0 ej1                    Z1 e1d<          d=             Z2 ej3                    Z3 e3d>d?h@          dA             Z4dB Z5e2e4gZ6dS )CaV  command to transplant changesets from another branch

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

Transplanted patches are recorded in .hg/transplant/transplants, as a
map from a changeset hash to its hash in the source repository.
    N)_)open)binhexshort)
bundlerepocmdutilerrorexchangehg
logcmdutilmatchmergepatchpycompat	registrarrevsetsmartsetstateutilvfs)procutil
stringutilurlutilc                       e Zd ZdS )TransplantErrorN)__name__
__module____qualname__     2/usr/lib/python3/dist-packages/hgext/transplant.pyr   r   3   s        Dr!   r   s   ships-with-hg-core
   transplant   filter)default   logc                       e Zd Zd ZdS )transplantentryc                 "    || _         || _        d S N)lnodernode)selfr+   r,   s      r"   __init__ztransplantentry.__init__O   s    



r!   N)r   r   r   r.   r    r!   r"   r(   r(   N   s#            r!   r(   c                   4    e Zd ZddZd Zd Zd Zd Zd ZdS )	transplantsNc                     || _         || _        || _        |st          j        | j                   | _        i | _        d| _        |                                  d S NF)pathtransplantfileopenervfsmodr   r0   dirtyread)r-   r3   r4   r5   s       r"   r.   ztransplants.__init__U   sS    	, 	0 *TY//DK
		r!   c                    t           j                            | j        | j                  }| j        rt           j                            |          r| j                            | j                                                  D ]o}t          t          |
                    d                    \  }}| j                            |g           }|                    t          ||                     ld S d S d S )N   :)osr3   joinr4   existsr5   r8   
splitlinesmapr   splitr0   
setdefaultappendr(   )r-   abspathliner+   r,   lists         r"   r8   ztransplants.read`   s    ',,ty$*=>> 	;27>>'#:#: 	;(()<==HHJJ ; ;"3

4(8(899u'225"==OE599::::		; 	; 	; 	;; ;r!   c                    | j         r| j        rt          j                            | j                  st          j        | j                   |                     | j        d          }| j                                        D ]I}|D ]D}t          t          |j        |j        f          \  }}|                    |dz   |z   dz              EJ|                                 d| _         d S )N   wr:      
F)r7   r4   r;   r3   isdirmkdirr5   r0   valuesr?   r   r+   r,   writeclose)r-   fprE   tlrs         r"   rL   ztransplants.writeh   s    : 	$- 	7==++ $###T0$77B(//11 3 3 3 3AsQWag$677DAqHHQX\E122223 HHJJJ


r!   c                 :    | j                             |          pg S r*   )r0   get)r-   r,   s     r"   rS   ztransplants.gett   s    ##E**0b0r!   c                     | j                             |g           }|                    t          ||                     d| _        d S NT)r0   rA   rB   r(   r7   )r-   r+   r,   rE   s       r"   setztransplants.setw   sA    **5"55OE511222


r!   c                     | j                             |j                  }|r||                    |          = d| _        d S d S rU   )r0   rS   r,   indexr7   )r-   
transplantrE   s      r"   removeztransplants.remove|   sL    ##J$455 	TZZ
++,DJJJ	 	r!   )NNN)	r   r   r   r.   r8   rL   rS   rV   rZ   r    r!   r"   r0   r0   T   ss        	 	 	 	; ; ;
 
 
1 1 1  
    r!   r0   c                   v    e Zd Zd Zd ZddZd Z	 ddZd Zd	 Z	d
 Z
d Zd Zd Zd ZddZd Zd Zd ZdS )transplanterc                     || _         | _        j                            d          | _        t          j        | j                  | _        t          | j        d| j                  | _        fd}|| _        d S )Nr#   s   transplants)r5   c                      t          j        d          d          } t          j        dd| it          j                  S )Nr#   editformr    )r	   mergeeditformgetcommiteditorr   	strkwargs)r_   optsrepos    r"   ra   z.transplanter.__init__.<locals>.getcommiteditor   sN    ,T$ZGGH*  !%-%7%=%=  r!   )	uird   r   r<   r3   r6   r5   r0   ra   )r-   re   rd   rc   ra   s     `` r"   r.   ztransplanter.__init__   s    	HMM-00	j++&I~dk
 
 
	 	 	 	 	 	  /r!   c                    t          ||          r|j                            |          }t          ||          r>|j                            |          }|j                            |g|d          }||v rdS | j                            |          D ]v}t          ||j                  s| j                            |            dS |j                            |j                  }||j                            |g|d          v r dS wdS )zmreturns True if a node is already an ancestor of parent
        or is parent or has already been transplantedT)	inclusiveF)hasnode	changelogrev	ancestorsr0   rS   r+   rZ   )	r-   rd   nodeparent	parentrevrj   	reachablerO   lnoderevs	            r"   appliedztransplanter.applied   s6    4   	3**622I4 	.$$T**C00SD 1  I it!%%d++ 		 		A4))  ''***uu~))!'22H4>33X 4     tt ur!   Nc                 <   |i }t          |          }|j                                        }g }t          j        | j        |          }	d|	_        dx}
}	 |                                }
|                    d          }|D ]}||         }d|t          |          fz  }| 
                    |||          r+| j                            t          d          |z             a|j                            |          }|                    d          s|                    d          s|d         |k    r|                    |           |}|rj||k    r)t#          j        ||                                |	           t)          j        ||d
                             |j                                        }g }d}||v r<d}t-          ||          s*t#          j        ||                                |g	           d}|d         |j        k    r|                    d          s<| j                            t          d          |t          |          fz             d}nh|                    |d                   }||vr@t5          j        t          d          t          |          t          |          fz            n|d         }|rd}nst9          j        d          \  }}t=          j        |d          }t          j         ||||	          }|D ]}|!                    |           |"                                 ||= |s|r:	 	 | #                    |||j        $                    |          |||                    d          |                    d                    }n## tJ          $ r |"                                  w xY w|r<|r:| j        &                    t          d          |t          |          fz             nH|rF| j        &                    t          d          t          |          t          |          fz             |rt=          j'        |           # |rt=          j'        |           w w xY w|"                                 |rIt#          j        ||                                |	           t)          j        ||d
                             | (                    ||           | j)        !                                 |r|*                                 |
r|
*                                 dS dS # | (                    ||           | j)        !                                 |r|*                                 |
r|
*                                 w w xY w)z:apply the revisions in revmap one by one in revision orderNTr#   s   %d:%ss%   skipping already applied revision %s
r$   r&   r   )headsF      parents   skipping merge changeset %d:%s
   %s is not a parent of %s   hg-transplant-prefixwb)rc   )r   logfilters   %s merged at %s
s   %s transplanted to %s
)+sorteddirstatep1r   difffeatureoptsre   gitlocktransactionr   rq   warnr   ri   parentsrS   rB   r   pullpeerr   updaterh   nullidnotelookupr
   Abortr   mkstempr;   fdopendiffrL   rM   applyoner8   r   statusunlink
saveseriesr0   release)r-   rd   sourcerevmapmergesrc   revsr   pullsdiffoptsr   trrj   rl   revstrr   domerge	skipmergerm   	patchfilefdrN   genchunkns                            r"   applyztransplanter.apply   s   <Df~~]($77ri	99;;D!!-00B [1 [1c{!S%++$66<<dB// GLLCDDvM    *22488++ #txx/?/? # qzR''T***!  #!T>>$M$UKKKKT%)_555!]--// "6>> #G"4.. I dFKKMM$HHHH!	1:,,88I.. ABB"E$KK01   %)		!'tI!?!?!00"'+ !"= > >#(==%++">!?# #  1 %QZF  $II$,$4<M$N$N$NMB	2t,,B*VVTIIIC!$ ( (HHJJJ3K 1 11" $ $ $ & 0 5 5d ; ; )&-$(HHV$4$4'+xx	':': !. ! !AA  / " " " HHJJJ!	"
    GNN !"6 7 76588:L L      GNN !"< = =#(;;a"9!:  
 % 1Ii000 % 1Ii0000171: HHJJJ .dFKKMM????T%)_---OOFF+++""$$$ 

  	 OOFF+++""$$$ 

 s;   K.T= AN Q!  O  B	Q!	T= !Q::A$T= =AVc                 t   | j                             t          d          |z             |d         |d         |d         }}}t          j        d          \  }}	t          j        |d          }
|
                    d           |
                    d	|z             |
                    d
|z             |
                    |dz              |
                                 	 | j         	                    d|t          j        |	          t          j        |          fz  |d         t          |          dt          j        t          d          d           |                     t!          |	d                    dd         \  }}}t          j        |	           n# t          j        |	           w xY w|||fS )z0arbitrarily rewrite changeset before applying its   filtering %s
ru         rx   ry   r{   s   # HG changeset patch

   # User %s
s   # Date %d %d
rH   s   %s %s %s)s   HGUSERs
   HGREVISIONs   filter faileds   transplant_filter)environonerr	errprefix
blockedtags   rb)re   r   r   r   r   r;   r   rL   rM   systemr   
shellquoter   r
   r   parselogr   r   )r-   r}   rl   ri   r   userdatemsgr   
headerfilerN   s              r"   r}   ztransplanter.filter#  s    	q*++i7888$Q<1y|Cd!)1BCCCJYr4  
*+++
$&'''
"T)***
u



	"GNN'
33'	22  )|#&t99  k,--/     #mmDU,C,CDDQqSIOD$Ij!!!!BIj!!!!dC  s   "B%F F2Fc           	         |dd         \  }}	\  }
}}}d|
|fz  }d|i}|r|                      ||||          \  }	}}|r|dt          |          z  z  }| j                            t	          d          t          |          z             | j                            d|	||fz             |s#|s!t          j        t	          d                    |r(	 t                      }t          j
        | j        |||d	           t          |          }n# t          $ r}t          j                            | j        d
          }t          j                            |          rt          j        |           |j                                        }|}|                     |	|||||           | j                            t-          j        |          dz              t1          t	          d                    d}~ww xY wd}|rC|j                                        }|                    ||           t5          j                    }nt5          j        |          }|                    ||	||||                                           }|s9| j                            t	          d          t          |          z             dS |s| j         	                    ||           |S )z>apply the patch in patchfile to the repository as a transplantN   s   %d %d   transplant_sources   
(transplanted from %s)s   applying %s
s	   %s %s
%s
s"   can only omit patchfile if merging)fileseolmode   series)r   rH   s=   fix up the working directory and run hg transplant --continue)extrar   editors   skipping emptied changeset %s
)!r}   r   re   r   r   r   r   r
   r   rV   r   rE   	Exceptionr;   r3   r<   r=   r   r   r   r|   rL   r   forcebytestrr   
setparentsr   alwaysexactcommitra   r   r0   )r-   rd   rl   clr   r   r|   r}   manifestr   timetimezoner   messager   r   inst
seriespathr   p2mr   s                         r"   r   ztransplanter.applyoneF  s    >@V:4)$5'4**%t, 	M$(KKb)$L$L!T4 	?2SYY>>Gq)**U4[[8999^tT7&;;<<< 	H 	H+a EFFGGG 	DGT9E4PPPPU   W\\$)Y??
7>>*-- *Ij)))]%%''tWb"EBBBj5d;;eCDDD%4    E 	#!!##BOOB%%%AAE""AKK''))  
 
  	GLL=>>tLMMM4 	*  D)))s   ;D 
G8CG33G8c                     t           j                            t           j                            | j        d                    S N   journal)r;   r3   r=   r<   r-   s    r"   	canresumeztransplanter.canresume  s(    w~~bgll49jAABBBr!   c                 N   t           j                            t           j                            | j        d                    r|                     |||          \  }}|rG| j                            t          d          t          |          t          |          fz             n8| j                            t          d          t          |          fz             t           j                            | j        d          }t           j                            |          s| j	        
                                 dS |                                 \  }}i }	|D ]}||	|j                            |          <    t          j        |           |                     |||	||           dS )z7recover last transaction and apply remaining changesetsr   s   %s transplanted as %s
s   %s skipped due to empty diff
r   N)r;   r3   r=   r<   recoverre   r   r   r   r0   rL   
readseriesri   rj   r   r   )
r-   rd   r   rc   r   rl   r   nodesr   r   s
             r"   resumeztransplanter.resume  s{   7>>"',,ty*==>> 		ll466GAt 011U4[[%((4KK    788E$KK>I   W\\$)Y77
w~~j)) 	""$$$F))v 	0 	0A./F6#''**++
	*

466666r!   c                 4   |                                  \  }}}}}d}	|r|r
|r|d         s!t          j        t          d                    |d         }
t	          |          dk    rw|                    d          r`|                    |d                   }
|
|vr@t          j        t          d          t          |
          t          |          fz            nd}	d|i}	 |j        	                                }||
k    r1t          j        t          d	          t          |
          z            |	r|                    ||d                    |                                }|j        |j        |j        |j        f\  }}}}|	s|s|s|s|rm|                    |||||                                 
          }|s!t          j        t          d                    |	s| j                            ||           nd}|                                  ||fS # w xY w)z/commit working directory using journal metadataFr   s   transplant log file is corruptru   rv   rw   Tr   s-   working directory not at transplant parent %s)r   r   s   commit failedN)readlogr
   r   r   lenrS   r   r   r   r   r   r   r   modifiedaddedremoveddeletedr   ra   r0   rV   unlog)r-   rd   r   rc   rl   r   r   r   r   r   rm   r   r   str   r   r   r   r   s                      r"   r   ztransplanter.recover  sa   -1\\^^*dD'7 	D4 	Dw 	Dgaj 	D+a ABBCCCw<<!xx	"" tI77((+566 ==%++67   ) %t,$	!!##BV||kFGG&kk"    0GAJ///B

	1-HeWg   E W  KK//11      ;+a(8&9&9::: 2$((D111JJLLLd7 DDDDs   #D1H Hc                 T   |                                  r|d         }t          j        |           |                    t	          d                     |                    t	          d          |                                dd         z             |                                  dS dS )z'logic to stop an interrupted transplant   .s#   stopped the interrupted transplant
s   working directory is now at %s
N   r   )r   r   clean_updater   r   r   r   )r-   re   rd   startctxs       r"   stopztransplanter.stop  s    >> 	DzHx(((IIa?@@AAAII5669LL   JJLLL1	 	r!   c                     g }g }|}| j                             d                                          D ]<}|                    d          r|}|                    t          |                     =||fS )Nr   s   # Merges)r5   r8   r>   
startswithrB   r   )r-   r   r   currD   s        r"   r   ztransplanter.readseries  s}    K$$Y//::<< 	" 	"D{++ JJs4yy!!!!vr!   c                    |sd S t           j                            | j                  st          j        | j                   |                     dd          }t          |          D ]-}|                    t          ||                   dz              .|r?|                    d           |D ]'}|                    t          |          dz              (|                                 d S )Nr   rG   rH   s	   # Merges
)	r;   r3   rI   rJ   r5   r~   rL   r   rM   )r-   r   r   seriesrj   r   s         r"   r   ztransplanter.saveseries  s     	Fw}}TY'' 	 HTYY--&>> 	3 	3CLLVC[))E12222 	-LL''' - -SVVe^,,,,r!   c                    g }g }| j         j        }d}d }d }|                                                                D ]}|r|                    |           |                    d          r|dd          }:|                    d          r|dd          }Z|                    d          rt          |dd                    }|                    d          r+|                    t          |dd                               |                    d	          sd
}|                    |           d ||fv r!t          j        t          d                    |||d
                    |          |fS )NFs   # User    s   # Date s
   # Node ID 
   	   # Parent 	   s   # Ts,   filter corrupted changeset (no user or date)rH   )rd   r   r8   r>   rB   r   r   r
   r   r   r<   )	r-   rN   r   r   rl   inmsgr   r   rD   s	            r"   r   ztransplanter.parselog  s   yGGII((** 	% 	%D %t$$$$,, 
%ABBx,, %ABBx// %49~~.. %s48}}----__U++ %t$$$D$<+ABB   dD%**W"5"5w??r!   c                 v   t           j                            | j                  st          j        | j                   |                     dd          }|                    d|z             |                    d|z             |                    dt          |          z             |                    dt          |          z   dz              |r(|                    dt          |          z   dz              |                    |                                dz              |                                 dS )	z,journal changelog metadata for later recoverr   rG   r   s
   # Date %s
s   # Node ID %s
r   rH   N)	r;   r3   rI   rJ   r5   rL   r   rstriprM   )r-   r   r   r   r   r   r   rN   s           r"   r|   ztransplanter.log  s    w}}TY'' 	 HTY[[T**
$&'''
$&'''
"SWW,---
B'%/000 	5HH\CGG+e3444
!!E)***





r!   c                 R    |                      |                     d                    S r   )r   r5   r   s    r"   r   ztransplanter.readlog,  s     }}T[[44555r!   c                     t           j                            | j        d          }t           j                            |          rt          j        |           dS dS )zremove changelog journalr   N)r;   r3   r<   r=   r   )r-   absdsts     r"   r   ztransplanter.unlog/  sO    di447>>&!! 	If	 	r!   c                       fd}|S )Nc                 0                        |           rdS j                            |           d         j        k    rdS j                            |           d         }|                    d          }|r                     |          rdS dS )NFru   r   r   T)rq   ri   r   r   r8   rS   )rl   r   cnoderd   rootr-   r   s      r"   matchfnz.transplanter.transplantfilter.<locals>.matchfn6  s    ||D$-- u''--a0DK??u$))$//2EII233E dE488 u4r!   r    )r-   rd   r   r   r   s   ```` r"   transplantfilterztransplanter.transplantfilter5  s5    		 		 		 		 		 		 		 		 r!   r*   )FFN)F)r   r   r   r.   rq   r   r}   r   r   r   r   r   r   r   r   r|   r   r   r   r    r!   r"   r\   r\      s(       / / /"  0t t t tl!! !! !!H IM= = = =~C C C7 7 709 9 9v
 
 

 
 
  @ @ @6   6 6 6      r!   r\   c                 h    	 | j                             |          d uS # t          j        $ r Y dS w xY wr2   )ri   rj   r
   StorageError)rd   rl   s     r"   rh   rh   D  sG    ~!!$''t33   uus    11c                    t          j        | ||          }g }g }t          d          }|D ]-}|                    ||                    d}	|	s|                     |          }
d|
|
dz            }	|	dk    r>|                     |          d         D ]\  }}|                     d||fz              d}	nV|	dk    rP|j                            |          d         }t          j
        |||          D ]}|                     |           d}	|	|	d	k    r|                    |           |	d
k    r|                    |           |	dk    r n|	dk    rd}d} n/|                                 ||fS )z#interactively transplant changesetss   apply changeset? [ynmpcq?]:$$ &yes, transplant this changeset$$ &no, skip this changeset$$ &merge at this changeset$$ show &patch$$ &commit selected changesets$$ &quit and cancel transplant$$ &? (show this help)Ns   ynmpcq?ru      ?s   %s: %s
   pr      y   m   c   qr    )r   changesetdisplayerr   showpromptchoiceextractchoicesrL   ri   r   r   r   rB   rM   )re   rd   r   rc   	displayerr0   r   promptrl   actionchoicecrO   rm   r   s                  r"   
browserevsr  K  s   -b$==IKF	"	 	F   tDz""" 	__V,,F! 34F~~--f55a8 3 3DAqHH[Aq6122224//55a8"Zfd;; $ $EHHUOOOO  	 T>>t$$$$t^^MM$t^^Et^^KFE  OO  r!      s   sourcer!   s   transplant changesets from REPOs   REPO   b   branchs!   use this source changeset as heads   REV   a   alls0   pull all changesets up to the --branch revisionsr      prunes   skip over REVr     merges   merge at REVrv   s)   parent to choose when transplanting merge   es   editFs    invoke editor on commit messagess%   append transplant info to log message   stops   stop interrupted transplantr     continues7   continue last transplant session after fixing conflictss!   filter changesets through commands   CMDsC   hg transplant [-s REPO] [-b BRANCH [-a]] [-p REV] [-m REV] [REV]...)helpcategoryc                     |                                 5  t          | |g|R i |cddd           S # 1 swxY w Y   dS )a  transplant changesets from another branch

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

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

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

      (transplanted from CHANGESETHASH)

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

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

    Example:

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

        hg transplant --branch REV --all

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

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

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

    If a changeset application fails, you can fix the merge by hand
    and then resume where you left off by calling :hg:`transplant
    --continue/-c`.
    N)wlock_dotransplant)re   rd   r   rc   s       r"   rY   rY   w  s    T 
 6 6R5555556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6s   377c                 8
   t           j        fd}t           j        fd}d }t          j        |          } |||           |                    d          s|                     dd          |d<   |                    d          s|                     dd          |d<   t          | ||          }|j                                        }t          |          dk    r,||j
        k    r!t          j        t          d                    |                    d	          r6|                                s!t          j        t          d
                    n|                    d          rK|                                s!t          j        t          d                    |                    | |          S t#          j        |           t#          j        |           |                    d          }	|	rt)          j        d|| |	          d         }
t-          j        |||
          }t          j        |j        |                    dd                    }t5          |          }|D ]@}	 |                    |                    |                     ,# t          j        $ r Y =w xY wt;          j        | ||t?          |          d          \  }}n2|t          j        j        |                    dd                    }d }	 |                    d	          r(|                     ||           	 |r |             d S d S |!                    ||          |                    d          r;fdtE          j#        |                    d                    D             fd}n}t          j        j        |                    dd                    }i }|rCtE          j#        |          D ],}|         $                                |tK          |          <   -n|                    d          s|s|k    r |||          }n ||||          }|                    d          r|}n*tM          | ||          \  }}|'                    |           |D ]}||j(        )                    |          <    |D ]}||j(        )                    |          <    |*                    ||||           |r |             d S d S # |r |             w w xY w)Nc              3   2   K   |D ]} ||          r|V  d S r*   r    )rd   csetsr   rl   s       r"   incwalkz_dotransplant.<locals>.incwalk  s9       	 	DuT{{ 


	 	r!   c              3   :  K   |s|                                  }g }| |         }|D ]B}|                    |                    | |                                                              C| j                            ||          d         D ]} ||          r|V  dS )zYield all nodes that are ancestors of a head but not ancestors
        of dest.
        If no heads are specified, the heads of repo will be used.r   N)rs   rB   ancestorrl   ri   nodesbetween)rd   destrs   r   rk   ctxheadrl   s           r"   transplantwalkz%_dotransplant.<locals>.transplantwalk  s        	!JJLLE	4j 	> 	>DS\\$t*55::<<====N//	5AA!D 	 	DuT{{ 


	 	r!   c                 f   |                      d          rt          j        | dg d           d S |                      d          rt          j        | dg d           d S |                      d          sM|sK|                      d          s6|                      d          s!t          j        t          d                    |                      d          rY|                      d          s!t          j        t          d	                    |r#t          j        t          d
                    d S d S )Nr  )r  r  r  r  r  r  r  s9   no source URL, branch revision, or revision list providedr  s    --all requires a branch revisions*   --all is incompatible with a revision list)rS   r	   check_incompatible_argumentsr
   r   r   )rc   r   s     r"   	checkoptsz _dotransplant.<locals>.checkopts  sn   88K   	0k#@#@#@   F88G 	0g<<<   FHHY		 xx!!	 xx	""		 +%    88F 	88I&& Jk!$G"H"HIII kCDD  		 	 r!   r&   r#   r$   r   s   no revision checked outr  s   no transplant to continuer  s   no interrupted transplant foundr  r  r    T)	onlyheadsforcer  c                 D    h | ]}|                                          S r    )rl   ).0rQ   r   s     r"   	<setcomp>z _dotransplant.<locals>.<setcomp>L  s7        q	    r!   c                 "     |           o| vS r*   r    )xprunetfs    r"   <lambda>z_dotransplant.<locals>.<lambda>P  s    1 8!5. r!   r  r  )r   )+r   r   r   byteskwargsrS   configr\   r   r   r   r   r
   r   r   r   
StateErrorr   r	   checkunfinishedbailifchangedr   get_unique_pull_pathr   r   maplistr   rV   add	RepoErrorr   getremotechangesr~   r   r   r   revrangerl   intr  extendri   rj   r   )re   rd   r   rc   r   r'  r*  tpr   
sourcerepour   rs   targetrQ   r  	cleanupfnr   r   r   alltransplants	newmergesr2  r   r3  s                         @@@r"   r  r    s   #';    
 15      > %%DIdD88F 8yy77V88I >))M9==Y	b$	%	%B					B
4yy1}}t{**k!677888xx 	$||~~ 	D"1%A#B#BCCC	D	'		 $||~~ 	J"1%G#H#HIIIwwr4   %%%d###)$$J (b*MMaPwtT1%% dhhy".E.EFFU 	 	A

4;;q>>****?   #-#>dfVnnD$
 $
 $
 yy  B0G0GHH	'88K   	IIdFD)))F  	IKKKKK	 	C   vr2288H 	   #,VTXXh5G5GHH  E 98888GGG!&-(B1G1GHH 	4(66 2 2!'!1!1s1vv2XXf 	4V 	4~~!(g!F!F!F!/BW" " " xx )%",R"N"Nii((( 4 423v'++A..// 	0 	0A./F6#''**++
vvvt444 	IKKKKK	 	9 	IKKKK	s%   )(JJ$#J$,T
 F8T
 
Tc                     |                                 5  t          | |i           }|                    ||i           cddd           S # 1 swxY w Y   dS )zAlogic to resume an interrupted transplant using
    'hg continue'N)r  r\   r   )re   rd   rB  s      r"   continuecmdrJ  o  s     
 ) )"dB''yytR(() ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )s   (A

AAs   transplanted([set])c                 z     |rt          j         ||          }n|}t          j         fd|D                       S )z?Transplanted changesets in set, or all transplanted changesets.c                 n    g | ]1}|                                                              d           /|2S )r   )r   rS   )r.  rQ   rd   s     r"   
<listcomp>z&revsettransplanted.<locals>.<listcomp>  s9    CCCqa,,-ABBCCCCr!   )r   getsetr   baseset)rd   subsetr1  ss   `   r"   revsettransplantedrR  z  sS     	 M$**CCCCACCC  r!   s   transplanted   ctx)requiresc                     |                      |d          }|                                                    d          }|rt          |          pdS )zEString. The node identifier of the transplanted
    changeset if any.rS  r   r!   )resourcer   rS   r   )contextmappingr%  r   s       r"   kwtransplantedrY    sH     

7F
+
+C		,--A<Q3r!   c           
      x    t          j        dddt          t          d          t          d                     d S )Nr#   s   transplant/journalTsM   To continue:    hg transplant --continue
To stop:        hg transplant --stops8   use 'hg transplant --continue' or 'hg transplant --stop')fname	clearablecontinuefunc
statushintcmdhint)statemodaddunfinishedrJ  r   )re   s    r"   extsetuprb    sR    # 4
 
 MNN
 
 
 
 
 
r!   )7__doc__r;   mercurial.i18nr   mercurial.pycompatr   mercurial.noder   r   r   	mercurialr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r`  r   r   r6   mercurial.utilsr   r   r   r   r   cmdtablecommand
testedwithconfigtable
configitemr(   r0   r\   rh   r  CATEGORY_CHANGE_MANAGEMENTrY   r  rJ  revsetpredicaterR  templatekeywordrY  rb  i18nfunctionsr    r!   r"   <module>rr     s    
			       # # # # # #         
                                   $         	 	 	 	 	ek 	 	 	 
)
H
%
%
 #
!Y!+..
 

   
 

          , , , , , , , ,^~ ~ ~ ~ ~ ~ ~ ~B  )! )! )!X 	 A011AgJJ	
 A233AfII	
 AABB		
 
xQQ/00!!F))<	xQQ//6;A:;;AfII	
 
wqq!DEEF	fdAAFGGH	guaa >??@AHII		
 A233AfII	
O.^ A	  3k6 6 6n46 46o6 6n46nG G GT) ) ) ,)+-- '((  )( ,)+-- F8444  54   $^4r!   