
    6h^                       S r SSKJr  SSKrSSKJr  SSK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  SSKJr  Sr0 r\R:                  " \5      r0 r\R>                  " \5      r\" S	S
SS9  \" S	SSS9  \" S	SSS9  SSSS.r \RB                  r! " S S5      r" " S S5      r#S r$S4S jr%S4S jr& " S S\RN                  5      r(S5S jr) " S S5      r* " S  S!5      r+S" r,S# r-S5S$ jr.\" S	S%S&S\" S'5      4S(S)S\" S*5      4S+S,S\" S-5      4S.S/S\" S05      4/\R^                  -   \R`                  -   \Rb                  -   \" S15      \Rd                  SS29S3 5       r3g)6a?  apply working directory changes to changesets (EXPERIMENTAL)

The absorb extension provides a command to use annotate information to
amend modified chunks into the corresponding non-public changesets.

::

    [absorb]
    # only check 50 recent non-public changesets at most
    max-stack-size = 50
    # whether to add noise to new commits to avoid obsolescence cycle
    add-noise = 1
    # make `amend --correlated` a shortcut to the main command
    amend-flag = correlated

    [color]
    absorb.description = yellow
    absorb.node = blue bold
    absorb.path = bold
    )annotationsN)_)hexshort)cmdutilcommandscontextcrecorderrorlinelogmdiffobsoletepatchphasespycompat	registrarrewriteutilscmutilutil)
stringutils   ships-with-hg-core   absorb	   add-noiseTdefaults
   amend-flag   max-stack-size2   s   yellows	   blue bolds   bold)   absorb.description   absorb.node   absorb.pathc                  *    \ rS rSrSrSrSrSrS rSr	g)nulluiW   zblank ui object doing nothingFTc                    S nU$ )Nc                     g N )argskwdss     ./usr/lib/python3/dist-packages/hgext/absorb.pynullfunc$nullui.__getitem__.<locals>.nullfunc_   s        r&   )namer*   s     r)   __getitem__nullui.__getitem__^   s    	 r,   r&   N)
__name__
__module____qualname____firstlineno____doc__	debugflagverbosequietr.   __static_attributes__r&   r,   r)   r!   r!   W   s    'IGEr,   r!   c                  *    \ rS rSrSrS rS rS rSrg)emptyfilecontexte   z.minimal filecontext representing an empty filec                    Xl         g r%   _repo)selfrepos     r)   __init__emptyfilecontext.__init__h   s    
r,   c                    g)Nr,   r&   r?   s    r)   dataemptyfilecontext.datak   s    r,   c                .    U R                   R                  $ r%   )r>   nullidrD   s    r)   nodeemptyfilecontext.noden   s    zz   r,   r=   N)	r0   r1   r2   r3   r4   rA   rE   rI   r8   r&   r,   r)   r:   r:   e   s    8!r,   r:   c                    [        5       n/ nU  H,  nX1;  d  M
  UR                  U5        UR                  U5        M.     U$ )z@list -> list. remove duplicated items without changing the order)setaddappend)lstseenresultxs       r)   uniqrS   r   s;    5DF=HHQKMM!  Mr,   c                T   U n/ nUR                  5       [        R                  :w  aq  U(       a  [        U5      U:  a  OZUR	                  5       n[        U5      S:w  a  O:UR                  U5        US   nUR                  5       [        R                  :w  a  Mq  UR                  5         U$ )a  (ctx, int?) -> [ctx]. get a linear stack of non-public changesets.

changesets are sorted in topo order, oldest first.
return at most limit items, if limit is a positive number.

merges are considered as non-draft as well. i.e. every commit
returned has and only has 1 parent.
   r   )phaser   publiclenparentsrN   reverse)headctxlimitctxrQ   rY   s        r)   getdraftstackr^   }   s     CF
))+
&S[E)++-w<1caj ))+
& NNMr,   c                   Uc
  [        5       nU (       d   eXS   ;  a  / 0 4$ / n0 nU S   R                  5       n[        U 5       H`  nX;  a  Un  OXXa   nUR                  U5        Xr;   a  Sn  O:XtU'   UR	                  5       nU(       d  MG  UnX;   d  MP  UR                  5       n  O   UbA  X;   a  UR                  XQ   5        O(UR                  [        UR                  5       5      5        UR                  5         [        U5      U4$ )a  ([ctx], str, set) -> [fctx], {ctx: fctx}

stack is a list of contexts, from old to new. usually they are what
"getdraftstack" returns.

follows renames, but not copies.

seenfctxs is a set of filecontexts that will be considered "immutable".
they are usually what this function returned in earlier calls, useful
to avoid issues that a file was "moved" to multiple places and was then
modified differently, like: "a" was copied to "b", "a" was also copied to
"c" and then "a" was deleted, then both "b" and "c" were "moved" from "a"
and we enforce only one of them to be able to affect "a"'s content.

return an empty list and an empty dict, if the specified path does not
exist in stack[-1] (the top of the stack).

otherwise, return a list of de-duplicated filecontexts, and the map to
convert ctx in the stack to fctx, for possible mutable fctxs. the first item
of the list would be outside the stack and should be considered immutable.
the remaining items are within the stack.

for example, given the following changelog and corresponding filelog
revisions:

  changelog: 3----4----5----6----7
  filelog:   x    0----1----1----2 (x: no such file yet)

- if stack = [5, 6, 7], returns ([0, 1, 2], {5: 1, 6: 1, 7: 2})
- if stack = [3, 4, 5], returns ([e, 0, 1], {4: 0, 5: 1}), where "e" is a
  dummy empty filecontext.
- if stack = [2], returns ([], {})
- if stack = [7], returns ([1, 2], {7: 2})
- if stack = [6, 7], returns ([1, 2], {6: 1, 7: 2}), although {6: 1} can be
  removed, since 1 is immutable.
Nr   )	rL   p1reversedrN   
copysourcer:   r@   rZ   rS   )	stackpath	seenfctxsfctxsfctxmappctxr]   fctxcopys	            r)   getfilestackrl      s    J E	L592vEG8;;=D?DyTD 4D{vvx " <LL$LL)$))+67	MMO ;r,   c                  $    \ rS rSrSrS rS rSrg)overlaystore   zkread-only, hybrid store based on a dict and ctx.
memworkingcopy: {path: content}, overrides file contents.
c                    Xl         X l        g r%   basectxmemworkingcopy)r?   rr   rs   s      r)   rA   overlaystore.__init__   s    ,r,   c                   XR                   ;  a  gU R                   U   nXR                  ;   a  U R                  U   nOUR                  5       nUR                  5       UR	                  5       4nUR                  5       nX4U4$ )z-comply with mercurial.patch.filestore.getfileNNN)rr   rs   rE   islinkisexecrc   )r?   re   rj   contentmoderk   s         r)   getfileoverlaystore.getfile   sq    ||##||D!&&&))$/GiikGt{{}- d""r,   rq   N)r0   r1   r2   r3   r4   rA   r{   r8   r&   r,   r)   rn   rn      s    -#r,   rn   c                   Uc7  UR                  5       R                  R                  UR                  5       5      nUc  UR	                  5       nUc  UR                  5       nUR                  5       nUR                  5       n[        UR                  5       5      R                  U 5      n[        X5      n[        R                  " UR                  5       UUUUUUSUS9	$ )za({path: content}, ctx, (p1node, p2node)?, {}?) -> memctx
memworkingcopy overrides file contents.
N)	r@   rY   textfiles	filectxfnuserdatebranchextra)r@   	changelogrY   rI   r   descriptionr   r   rL   r   unionrn   r	   memctx)	rs   r]   rY   r   descr   r   r   stores	            r)   overlaycontextr      s    
 ((*&&..sxxz:}		| 88:D88:D		"">2E-E>>XXZ
 
r,   c                  |    \ rS rSrSrSS jrSS jrS rS rS r	\
S	 5       rS
 rS rS rS rSS jrS rS rSrg)filefixupstatei  a  state needed to apply fixups to a single file

internally, it keeps file contents of several revisions and a linelog.

the linelog uses odd revision numbers for original contents (fctxs passed
to __init__), and even revision numbers for fixups, like:

    linelog rev 1: self.fctxs[0] (from an immutable "public" changeset)
    linelog rev 2: fixups made to self.fctxs[0]
    linelog rev 3: self.fctxs[1] (a child of fctxs[0])
    linelog rev 4: fixups made to self.fctxs[1]
    ...

a typical use is like:

    1. call diffwith, to calculate self.fixups
    2. (optionally), present self.fixups to the user, or change it
    3. call apply, to apply changes
    4. read results from "finalcontents", or call getfinalcontent
Nc                   Xl         X l        U=(       d
    [        5       U l        X@l        U Vs/ s H  oUR                  5       PM     snU l        [        R                  " [        R                  U R                  5      U l        U R                  5       U l        U R                  R                  (       a   U R                  5       U R                  :X  d   eSS/U l        / U l        / U l        / U l        [)        5       U l        gs  snf )z([fctx], ui or None) -> None

fctxs should be linear, and sorted by topo order - oldest first.
fctxs[0] will be considered as "immutable" and will not be changed.
r   N)rg   re   r!   uioptsrE   contentsr   maplistr   splitnewlinescontentlines_buildlinelogr   r5   _checkoutlinelog
chunkstatstargetlinesfixupsfinalcontentsrL   ctxaffected)r?   rg   re   r   r   fs         r)   rA   filefixupstate.__init__/  s     
	.	 ,115a51$,,U-@-@$--P))+77((*dmm;;; a&5 2s   Dc                   U R                   S   nU R                  S   nUR                  5       n[        R                  " U5      nX`l        U R                  R                  U R                  R                  5        U R                  R                  n[        U5      [        U5      :X  d   eU(       a$  US   S   US   S   S-   4nUR                  U5        U R                  X5XF5       Hx  n	U R                  X5      n
U R                  S==   [        U
5      -  ss'   U R                  S==   S-  ss'   U =R                   U
-  sl        Uc  Me  U R#                  X$XiU
5        Mz     g)a{  calculate fixups needed by examining the differences between
self.fctxs[-1] and targetfctx, chunk by chunk.

targetfctx is the target state we move towards. we may or may not be
able to get there because not all modified chunks can be amended into
a non-public fctx unambiguously.

call this only once, before apply().

update self.fixups, self.chunkstats, and self.targetlines.
r`   r   rU   N)r   r   rE   r   r   r   r   annotatemaxrevannotateresultrX   rN   _alldiffchunks_analysediffchunkr   boolr   _showchanges)r?   
targetfctxfmaalinesbblines	annotateddummyendlinechunk	newfixupss              r)   diffwithfilefixupstate.diffwithH  s1    MM"""2&OO$$Q'!dll112LL//	9~V,,,%bM!,imA.>.BCL\* ((v>E..u@IOOA$y/1OOA!#KK9$K~!!"fYG ?r,   c           
     :   [        U R                  5       H  u  pp4nU R                  XE nU R                  R                  (       ai  [        US-
  S5      S-  nU R                  R                  [        S5      [        U R                  U   R                  5       5      X#[        U5      4-  5        U R                  R                  XX4U5        M     U R                  R                  SS5      (       a  U R!                  5       U l        gU R%                  5       U l        g)z~apply self.fixups. update self.linelog, self.finalcontents.

call this only once, before getfinalcontent(), after diffwith().
rU   r      s   %s: chunk %d:%d -> %d lines

edit_linesFN)rb   r   r   r   r5   maxwriter   r   rg   rI   rX   r   replacelinesr   get_checkoutlinelogwitheditsr   r   )r?   reva1a2b1b2r   idxs           r)   applyfilefixupstate.applyk  s     $,DKK#8CRR%%b,Fww  37A1,67TZZ_1134bc&kJK LL%%crr: $9 99==u--!%!?!?!AD!%!6!6!8Dr,   c                V    U R                   R                  U5      nU R                  U   $ )z@(fctx) -> str. get modified file content for a given filecontext)rg   indexr   )r?   rj   r   s      r)   getfinalcontentfilefixupstate.getfinalcontent  s'    jjt$!!#&&r,   c                r   Uu  p4pVX#U nU(       d9  U(       a2  U[        SUS-
  5      1nU V	s/ s H  oU	   S   S:w  d  M  X)   PM     nn	[        U V
Vs1 s H  u  pU
iM	     snn
5      n/ n[        U5      S:X  a?  U R                  X4S-
  S5      (       a%  US   nUS:  a  US-   nUR	                  XXEU45        OcXC-
  Xe-
  :X  d  XV:X  aT  [        X45       HE  n	X)   u  nnUS:  d  M  XV:X  a  S=nnOXY-   U-
  nUS-   nUS-   nUR	                  XU	S-   UU45        MG     U R                  U5      $ s  sn	f s  snn
f )aE  analyse a different chunk and return new fixups found

return [] if no lines from the chunk can be safely applied.

the chunk (or lines) cannot be safely applied, if, for example:
  - the modified (deleted) lines belong to a public changeset
    (self.fctxs[0])
  - the chunk is a pure insertion and the adjacent lines (at most 2
    lines) belong to different non-public changesets, or do not belong
    to any non-public changesets.
  - the chunk is modifying lines from different changesets.
    in this case, if the number of lines deleted equals to the number
    of lines added, assume it's a simple 1:1 map (could be wrong).
    otherwise, give up.
  - the chunk is modifying lines from a single non-public changeset,
    but other revisions touch the area as well. i.e. the lines are
    not continuous as seen from the linelog.
r   rU   T)r   listrX   _iscontinuousrN   range_optimizefixups)r?   r   r   r   r   r   r   involvednearbylinenumsirlinvolvedrevsr   r   fixuprevlinenumnb1nb2s                      r)   r    filefixupstate._analysediffchunk  sf   & #I !#aa.1N&4&4!Q18L	n   84841Q845	|!d&8&8!VT&J&Jq/CQw7  (!;<W282](|W7x$%c frk!Ag"QwH$$h1q5#s%CD # ##I../ 5s   D. D.D3
c              #  d   #    [         R                  " XX#S9nU H  u  pVUS:w  a  M  Uv   M     g7f)z5like mdiff.allblocks, but only care about differences)lines1lines2   !N)r   	allblocks)r   r   r   r   blocksr   btypes          r)   r   filefixupstate._alldiffchunks  s2      fD"LE}K #s   .0c           	     T   [         R                   " 5       nS/ p2[        [        U R                  5      5       Hm  nU R                  U   U R                  U   peUS-  S-   nU R                  X%X65      n[        [        U5      5       H  u  ppUR                  XyXU5        M     XVp2Mo     U$ )zncalculate the initial linelog based on self.content{,line}s.
this is similar to running a partial "annotate".
r,   r   rU   )	r   r   rX   r   r   r   rb   r   r   )r?   llogr   r   r   r   r   llrevchunksr   r   r   r   s                r)   r   filefixupstate._buildlinelog  s      6s4==)*Aa($*;*;A*>vEAIE((v>F"*4<"8!!%RR8 #9v + r,   c                .   / n[        [        U R                  5      5       Hp  nUS-   S-  nU R                  R	                  U5        SR                  [        U R                  U R                  R                  5      5      nUR                  U5        Mr     U$ )z1() -> [str]. check out file contents from linelogrU   r   r,   )
r   rX   r   r   r   joinmap_getliner   rN   )r?   r   r   r   ry   s        r)   r   filefixupstate._checkoutlinelog  st    s4==)*Aq5A+CLL!!#&hhs4==$,,2M2MNOGOOG$	 +
 r,   c                   U R                   R                  5       n[        S5      U R                  S   R	                  5       -  n[        U R                  5       VVs/ s H  u  p4[        U[        5      (       a  M  X44PM!     nnn[        U5       Hj  u  nu  pdU[        S5      SU-  S[        U5      U-
  S-   -  [        UR                  5       5      UR                  5       R                  SS5      S   4-  -  nMl     U[        S	5      S[        U5      -  -  -  n[        S
 5      nU HV  u  p4U R                   R                  US-   S-  5        U R                   R                   H  nXx   R!                  U5        M     MX     U HJ  nUSSR#                  U VV	s/ s H  u  p9X7U   ;   a  SOSPM     sn	n5      U R%                  U5      4-  -  nML     U R&                  R)                  USSS9n
U
(       d  [*        R,                  " [        S5      5      eS/[        U R                  5      -  nSnU[        U5      -   S-   n[.        R0                  " U
5       H  nUR3                  S5      (       a  M  XS-
  US-    S:w  a"  [*        R,                  " [        S5      U-  5      eXS-   S n[        [4        R6                  " XUS-
   5      5       H  u  p?US:X  d  M  XU   S   ==   U-  ss'   M!     M     X:w  a	  SS/U l        U$ s  snnf s  sn	nf )z&() -> [str]. prompt all lines for editsZ   HG: editing %s
HG: "y" means the line to the right exists in the changeset to the top
HG:
r`   s   HG: %s/%s %s %s
   |   -rU      
r   s   HG: %s
c                     [        5       $ r%   )rL   r&   r,   r)   <lambda>:filefixupstate._checkoutlinelogwithedits.<locals>.<lambda>  s    cer,   r   s       %s : %sr,      y    r   )actions   empty editor text   s   HG:s    : s   malformed line: %sN)r   getalllinesr   rg   re   	enumerate
isinstancer:   rX   r   rI   r   splitdefaultdictr   r   rM   r   r   r   editr   
InputErrorr   r   
startswithr   bytestrr   )r?   alllines
editortextr   r   visiblefctxsjlinesetr   _f
editedtextr   
leftpadposcolonposlinecontentchs                   r)   r   (filefixupstate._checkoutlinelogwithedits  s   <<++- = jjn!!#	$ 	 "$**-
-a!12 QF- 	 

 #<0IAv!01qL)A-12affh%%eQ/2	5  J 1 	ans</@(@AA
 m, DALL!!1q5A+.\\00
q! 1 !
 A. &2%1EA "#ajd:%1 a ,  J  WW\\*c)\D
""1%9#:;;53tzz?*
L 11A5$$Z0A||F##A1-7&&q)>'?!'CDDqLN+K"  1!=> :!_Q/0K?0	 1 # !fDOm
0s   L;LL	c                f    Uu  p#US-  (       a  U R                   US-     U   $ U R                  U   $ )z@((rev, linenum)) -> str. convert rev+line number to line contentrU   r   )r   r   )r?   lineinfor   r   s       r)   r   filefixupstate._getline  s;    7$$SAX.w77##G,,r,   c                    X:  a  gU R                   nUR                  U5      nUR                  U5      [        U5      -   nUR                  XV5      n[	        U5      X!-
  [        U5      -   :H  $ )z(a1, a2 : int) -> bool

check if these lines are continuous. i.e. no other insertions or
deletions (from other revisions) among these lines.

closedinterval decides whether a2 should be included or not. i.e. is
it [a1, a2), or [a1, a2] ?
T)r   	getoffsetintr   rX   )r?   r   r   closedintervalr   offset1offset2linesinbetweens           r)   r   filefixupstate._iscontinuous&  sg     8||..$..$s>'::))';>"bgN0C&CCCr,   c                L  ^^ / m/ SQ/mUU4S jn[        U5       H}  u  p4Uu  pVpxn	TS   S   n
TS   S   nTS   S   nXk:X  a@  X:X  a;  XZ:X  a6  U R                  [        US-
  S5      U5      (       a  UTS   S'   U	TS   S'   Mh  U" 5         [        U5      TS'   M     U" 5         T$ )zh[(rev, a1, a2, b1, b2)] -> [(rev, a1, a2, b1, b2)].
merge adjacent fixups to make them less fragmented.
)r`   r`   r`   r`   r`   c                 Z   > T S   S   S:w  a  TR                  [        T S   5      5        g g )Nr   r`   )rN   tuple)pcurrentchunkrQ   s   r)   	pushchunk1filefixupstate._optimizefixups.<locals>.pushchunk>  s0    Q"b(eM!$456 )r,   r   r   r   rU   )r   r   r   r   )r?   r   r  r   r   r   r   r   r   r   lastrevlasta2lastb2r  rQ   s                @@r)   r   filefixupstate._optimizefixups7  s     -.	7 "&)HA"'CRR#A&q)G"1%a(F"1%a(FLN&&s261~r:: ')a #&(a ##';a ! *" 	r,   c           
     L  ^ ^ S nUu  pxpS/X-
  -  S/X-
  -  pU H]  u  pnnn[        X5       H  n[        US5      S-
  S-  UUU-
  '   M     [        UU5       H  n[        US5      S-
  S-  UUU	-
  '   M     M_     TR                  5         TR                  SSSXxU-
  XU	-
  4-  SS	9  TR	                  T R
                  SS
9  UU 4S jn[        Xx5       H  nU" UUU-
     SU" UU   5      SS5        M      [        X5       H  nU" UUU	-
     SU" UU   5      SS5        M      g )Nc                <    U R                  S5      (       a  U S S n U $ )Nr   r`   )endswith)lines    r)   trim)filefixupstate._showchanges.<locals>.trimW  s!    }}U##CRyKr,   r   rU   r   s   hunks           %s
s   @@ -%d,%d +%d,%d @@s	   diff.hunklabelre   linetypec                j  > TR                  5         SnU (       aW  TR                  U    nTR                  US9  UR                  5       nTR                  R                  UR                  5       5        TR                  SSUSS9  TR                  SU-   SUUUS9  TR                  TR                  US	9  g )
Nr,   )rj      node   %-7.7s r   r#  s	   diffchar s   %s%s
r%  )
	startitemrg   r	   r   r   rM   	changectxr   rE   re   )	r   diffcharr   r&  	linelabelrI   r]   r   r?   s	          r)   	writeline.filefixupstate._showchanges.<locals>.writelineo  s    LLNDjjo


$wwy  $$S]]_5HHWj$nHEHHx'   GGXG6r,   r   s   deleteds   diff.deleted   +s   inserteds   diff.inserted)r   r   r*  r   rE   re   )r?   r   r   r   r   r   r!  r   r   r   r   aidxsbidxsr   fa1fa2fb1fb2r   r.  s   ``                  r)   r   filefixupstate._showchangesV  sV   	 sbgrwu'-#Cc33_!$S!qQ 6a"f %3_!$S!qQ 6a"f % (. 	
"br'2Bw%??	 	 	
 	TYY1	7$ rAa"fVAY  rAa"fVAY  r,   )r   r   r   r   rg   r   r   r   r   re   r   r   r%   )F)r0   r1   r2   r3   r4   rA   r   r   r   r   staticmethodr   r   r   r   r   r   r   r   r8   r&   r,   r)   r   r     s]    *!2!HF9*'
1/f  BH-D">:r,   r   c                      \ rS rSrSrSS jrSS jrS r\S 5       r	S r
S	 rS
 rS rS rS rS r\SS j5       rSS jr\R*                  S 5       rS r\R*                  S 5       rSrg)
fixupstatei  aB  state needed to run absorb

internally, it keeps paths and filefixupstates.

a typical use is like filefixupstates:

    1. call diffwith, to calculate fixups
    2. (optionally), present fixups to the user, or edit fixups
    3. call apply, to apply changes to memory
    4. call commit, to commit changes to hg database
Nc                   U(       d   eU=(       d
    [        5       U l        X0l        Xl        US   R	                  5       R                  5       U l        / U l        SU l        0 U l        0 U l	        0 U l
        SU l        [        5       U l        g)z([ctx], ui or None) -> None

stack: should be linear, and sorted by topo order - oldest first.
all commits in stack are considered mutable.
r`   N)r!   r   r   rd   r@   
unfilteredpathsstatusrh   fixupmap
replacemap	finalnoderL   r   )r?   rd   r   r   s       r)   rA   fixupstate.__init__  ss     u.	
"INN$//1	 
5r,   c                D   U R                   S   R                  X5      U l        / U l        U R                  R	                  S5      nU R                  R
                  (       d  U(       a  U(       a  UR                  5       nOU R                  R
                  n[        5       n[        U5       GHq  nU R                  R                  SU-  5        X   n[        U R                   Xv5      u  p[        S U/U	-    5       5      (       a  M[  UR                  5       U	S   R                  5       :X  a	  U(       d  M  UR                  U	SS 5        XR                  U'   [!        X4SU R                  0U R                  D6nUbB  UR#                  5         UR%                  S5        UR'                  S	S
USS9  UR                  S	S9  UR)                  X5        XR*                  U'   U R                  R-                  U5        U R.                  R                  UR.                  5        GMt     g)z9diff and prepare fixups. update self.fixupmap, self.pathsr`   r   s   calculating fixups for %s
c              3     #    U  HW  n[        U[        5      (       a  M  UR                  5       =(       d$    [        R                  " UR                  5       5      v   MY     g 7fr%   )r   r:   rw   r   binaryrE   ).0r   s     r)   	<genexpr>&fixupstate.diffwith.<locals>.<genexpr>  sC      -A!!%56 :
9j//99-s   A!AA!rU   Nr   s   showing changes for s   path   %s
r   r#  r&  )rd   r>  r=  r   r   modifiedr   rL   sortedr   debugrl   anyrE   updaterh   r   r*  plainr   r   r?  rN   r   )r?   	targetctxmatchr   editoptinterestingpathsrf   re   r   rg   ctx2fctxfstates               r)   r   fixupstate.diffwith  s    jjn++I=
 ))---{{##E${{}#{{33E	 +,DGGMM84?@"J*4::tGOE $-  
  E"INN$44WU12Y'!)LL#EIDGGItyyIF~01'4~F)OOJ+"(MM$JJd###F$6$671 -r,   c                    U R                   R                  5        HW  u  pU R                  R                  (       a'  U R                  R	                  [        S5      U-  5        UR                  5         MY     g)z*apply fixups to individual filefixupstatess   applying fixups to %s
N)r?  itemsr   r5   r   r   r   r?   re   states      r)   r   fixupstate.apply  sL    ==..0KDww  a :;dBCKKM 1r,   c                    U R                   R                  5        VVs0 s H  u  pXR                  _M     snn$ s  snnf )z>-> {path: chunkstats}. collect chunkstats from filefixupstates)r?  rY  r   rZ  s      r)   r   fixupstate.chunkstats  s6     ;?--:M:M:OP:O;4&&&:OPPPs   :c                r   U R                   R                  S5       nU R                  5         U R                  U5        U R                   S   R	                  5       U R
                  ;   a  U R                  5         U R                  5         SSS5        U R                  $ ! , (       d  f       U R                  $ = f)z6commit changes. update self.finalnode, self.replacemapr      .N)	r@   transaction_commitstack_movebookmarksrI   r@  _moveworkingdirectoryparent_cleanupoldcommitsrA  )r?   trs     r)   commitfixupstate.commit  s    YY""9-#yy##%8002##% . ~~ .- ~~s   A-B
B6c                  ^ U R                   nU R                  nUR                  (       aK  UR                  5        H6  u  p4US   (       d  M  UR	                  [        S5      X4S   US   4-  5        M8     gUR                  (       d=  UR                  5       mU4S jS 5       u  pVUR	                  [        S5      XV4-  5        gg)z+print things like '1 of 2 chunk(s) applied'r   s   %s: %d of %d chunk(s) applied
rU   c              3  P   >^#    U  H  m[        U4S  jT 5       5      v   M     g7f)c              3  ,   >#    U  H	  oT   v   M     g 7fr%   r&   )rF  sr   s     r)   rG  7fixupstate.printchunkstats.<locals>.<genexpr>.<genexpr>  s     !61A$s   N)sum)rF  r   statss    @r)   rG  -fixupstate.printchunkstats.<locals>.<genexpr>  s     G1c!6!666s   "&)r   rU   s   %d of %d chunk(s) applied
N)r   r   r6   rY  r   r   r7   values)r?   r   r   re   statappliedtotalro  s          @r)   printchunkstatsfixupstate.printchunkstats  s    WW__
::(..0
77HH<=a$q'23 1 %%'EGGNGHHQ56'9IIJ	 r,   c                   SnSnU R                    GH  nU R                  U5      nU(       d  U(       d  UnM'  UR                  5       =(       a    U R                  XCU5      nU R                  (       a0  U(       a)  SU R
                  UR                  5       '   [        S5      nOU R                  XCUS9nU R                  U   nUnUR                  5       U R
                  UR                  5       '   U(       a>  U(       a  [        S5      nO[        S5      nU[        U5      U R                  U5      4-  nO[        S5      U R                  U5      -  nU R                  R                  (       d  GM]  U(       d  GMg  U R                  R                  [        S5      U R                  U5      U4-  5        GM     U=(       a    UR                  5       U l        g)zvmake new commits. update self.finalnode, self.replacemap.
it is splitted from "commit" to avoid too much indentation.
Ns   became empty and was dropped)ra   s&   %d file(s) changed, became empty as %ss   %d file(s) changed, became %ss	   became %ss   %s: %s
)rd   _getnewfilecontentsr   _willbecomenoopskip_empty_successorr@  rI   r   _commitsingler@   rX   _ctx2strr   r6   r   rA  )r?   lastcommittednextp1r]   rs   willbecomenoopmsgnodestrs           r)   rb  fixupstate._commitstack  sx   
  ::C!55c:N!- YY[ T-A-AV.N ((^.2
+78 ,,^V,L $		' 2&.;.@.@.B
+!% IJ @AN+m4! C
 L/DMM-,HHCww33anc0BC/HHI? @ '?=+=+=+?r,   c                    U R                   R                  (       a#  SUR                  5       UR                  5       4-  $ SUR                  5       [	        UR                  5       5      4-  $ )Ns   %d:%s)r   r5   r   r   r   rI   )r?   r]   s     r)   r|  fixupstate._ctx2str2  sL    77swwy#'')444swwy%
*;<<<r,   c                    0 nU R                    Hd  nU R                  U   nX;  a  M  XA   nUR                  5       nU R                  U   R	                  U5      nXg:w  d  MR  XrUR                  5       '   Mf     U$ )z~(ctx) -> {path: str}

fetch file contents from filefixupstates.
return the working copy overrides - files different from ctx.
)r=  rh   rE   r?  r   re   )r?   r]   rQ   re   rU  rj   ry   
newcontents           r)   rx  fixupstate._getnewfilecontents8  st     JJD||D)H"=DiikGt,<<TBJ$&0tyy{#  r,   c                   U R                   nUR                  R                  5        VVs/ s H&  u  p4X@R                  ;   d  M  X0R                  U   4PM(     nnn/ nU H  u  p4U(       ac  UR	                  X445        U R
                  R                  (       a4  U R
                  R                  [        S5      U[        U5      4-  5        Mm  Mo  UR	                  US 45        U R
                  R                  (       d  M  U R
                  R                  [        S5      U-  5        M     UR                  R                  X!U5        g s  snnf )Ns   moving bookmark %s to %s
s   deleting bookmark %s
)r@   
_bookmarksrY  r@  rN   r   r6   r   r   r   applychanges)r?   rf  r@   r-   hsh
needupdatechangess          r)   rc  fixupstate._movebookmarksJ  s   yy "__224
4	oo% )T??3'(4 	 

 #ID{+77??GGMM78D#c(;KK #
 d|,77???GGMM!$=">"EF $ 	$$Tw7#
s   EEc                  ^^ U R                   (       dg  U R                  R                  SU R                  R	                  5       5      nU R                  UR                  5          nUR                  5       U l         OU R                  U R                      nU R                  R                  mS nUn[        TS5      (       a.  TR                  R                  mUU4S jnUTR                  l
         TR                  U R                  5         TR                  UR                  5       UR                  5       U R                  5        S S S 5        U" 5         g ! , (       d  f       N= f! U" 5         f = f)Ns   max(::. - %ln)c                     g)Nr   r&   r&   r,   r)   r   8fixupstate._moveworkingdirectoryparent.<locals>.<lambda>k  s    qr,   _fsmonitorstatec                 (   > T TR                   l        g r%   )r  
invalidate)bakdirstates   r)   restore7fixupstate._moveworkingdirectoryparent.<locals>.restorep  s    69((3r,   )rA  r@   revsr@  keysfirstrI   r  hasattrr  r  changing_parentsrebuildmanifestr=  )r?   r  r]   noopr  r  r  s        @@r)   rd  &fixupstate._moveworkingdirectoryparent_  s   ~~99>>"3T__5I5I5KLD))DJJL)C XXZDN))DNN+C99%% 8.//**55C: 37H$$/	**4995  S\\^TZZH 6 I 65 Is$   /E% 
:EE% 
E"E% %	E.c                (   U(       d%  UR                  5       n[        U5      S:w  a  gUS   nUR                  5       UR                  5       :w  a  gUR                  5       R	                  S5      (       a  g[        UR                  5       5      R                  [        U 5      5      (       d  gU R                  5        HS  u  pEXB;  d  XA;  a    gX   nX$   nUR                  5       UR                  5       :w  a    gUR                  5       U:w  d  MS    g   g)z({path: content}, ctx, ctx) -> bool. test if a commit will be noop

if it will become an empty commit (does not change anything, after the
memworkingcopy overrides), return True. otherwise return False.
rU   Fr   s   closeT)rY   rX   r   r   r   rL   r   issubsetrY  flagsrE   )rs   r]   ri   rY   re   ry   rj   pfctxs           r)   ry  fixupstate._willbecomenoopz  s     kkmG7|q 1:D::<4;;=(99;??8$$399;((^)<==+113MD4?9DJE{{}

,zz|w& 4 r,   c           
        U=(       a    X0R                   R                  4nUR                  5       nU R                  (       a4  U R                  R                  SS5      (       a  UR                  5       US'   [        R                  " UR                  5       UR                  5       U R                  R                  5        VVs0 s H  u  pgXg/_M
     snn5      n[        XXEUS9n	U	R                  5       $ s  snnf )z(ctx, {path: content}, node) -> node. make a single commit

the commit is a clone from ctx, with a (optionally) different p1, and
different file contents replaced by memworkingcopy.
r   r   s   absorb_source)r   r   )r@   rH   r   _useobsoleter   
configboolr   r   update_hash_refsr   r@  rY  r   rg  )
r?   rs   r]   ra   rY   r   oldnodenewnoder   mctxs
             r)   r{  fixupstate._commitsingle  s     /"ii../		!3!3I|!L!L&)ggiE"#++HHJOO )-(=(=(?(?$G "(?
 D
 {{}s   C3c                `    [         R                  " U R                  [         R                  5      $ )z
() -> bool)r   	isenabledr@   createmarkersoptrD   s    r)   r  fixupstate._useobsolete  s!     !!$))X-F-FGGr,   c                    U R                   R                  5        VVs0 s H  u  pXb  U/O/ _M     nnnU(       a"  [        R                  " U R                  USSS9  g g s  snnf )Nr   T)	operationfixphase)r@  rY  r   cleanupnodesr@   )r?   kvreplacementss       r)   re  fixupstate._cleanupoldcommits  sh     --/
/ }",/ 	 
   		<9t 	
s   Ac                D    [         R                  " U R                  S5      $ )Nr   )r   rz  r   rD   s    r)   rz  fixupstate.skip_empty_successor  s    //CCr,   )r   rh   rA  r?  r   r=  r@  r@   rd   r>  r   r%   NN)r0   r1   r2   r3   r4   rA   r   r   propertyr   rg  ru  rb  r|  rx  rc  rd  r8  ry  r{  r   propertycacher  re  rz  r8   r&   r,   r)   r:  r:    s    
!*(8T Q QK$)@V=$8*6  :0 
H H 
D Dr,   r:  c                   [        U 5      [        R                  [        R                  4;  a  gU R
                  R                  5       nU R                  [        U R                  5      -   S-
  n/ =U l	        U l
        [        R                  " 5       nU R                  U5        [        R                  " UR!                  5       5      nX R"                  -   nUSS  Vs/ s H  ofR%                  S5      (       a  M  USS PM!     nnXXW44$ s  snf )zA(crecord.uihunk or patch.recordhunk) -> (path, (a1, a2, [bline]))r  rU   Nr   )typer
   uihunkr   
recordhunkheaderfilenamefromlinerX   beforeafterr   stringior   r   r   getvalueremovedr   )hunkre   r   buf
patchlinesr   r   r   s           r)   _parsechunkr    s    Dz'..%*:*:;;;;!D	T[[)	)A	-B!!DK$*
--/CJJsO$$S\\^4J	ll	B'^F^<<3Eeae^FFb!!! Gs   D8	Dc                   0 n[        S 5      n[        [        U5       H(  u  pEU(       a  U(       d  M  X4   R                  U5        M*     UR	                  5        Hj  u  pFX@;  d  U(       d  M  UR                  SS9  [        R                  " X   R                  5       5      nU H	  u  pn
XX& M     SR                  U5      X$'   Ml     [        X 5      $ )z(ctx, [crecord.uihunk]) -> memctx

return a memctx with some [1] patches (chunks) applied to ctx.
[1]: modifications are handled. renames, mode changes, etc. are ignored.
c                     / $ r%   r&   r&   r,   r)   r   $overlaydiffcontext.<locals>.<lambda>  s    2r,   T)rZ   r,   )r   r   r  rN   rY  sortr   r   rE   r   r   )r]   r   rs   patchmapre   infopatcheslinesr   r   r   s              r)   overlaydiffcontextr    s     N:&H+v.
4d# / ")?'T"##CINN$45%NBF!"L &"xx * ...r,   c                   Uc  U R                  SS5      nUS   n[        UR                  5       5      S:  a  [        R                  " [        S5      5      e[        Xv5      nU(       a,  [        U5      U:  a  U R                  [        S5      U-  5        U(       d  [        R                  " [        S5      5      eUc  US   nUc  S	n[        U4S
U 0UD6n[        R                  " X4[        R                  " U5      5      n	UR                  S5      (       av  [        R                  " XS   R!                  5       UR!                  5       U	5      n
[        R"                  " U
5      n[$        R&                  " XU	5      S   n[)        US   U5      nUR                  S5      (       a  SUS'   SnUR                  S5      (       d  UR                  S5      (       d&  U R+                  S[        R                  " U5      5      nUR-                  X9U5        Ub  UR/                  5         UR1                  SS[        UR2                  5      5        UR5                  SS9  [7        U5       H  nXR2                  ;  a  M  UR/                  5         UR9                  US9  UR5                  SS9  UR1                  SSUR;                  5       SS9  [<        R>                  " URA                  5       5      nUR1                  SSUSS9  M     URC                  5         UR                  S5      (       d  UR                  S5      (       dE  UR2                  (       a4  U RE                  S SS!9(       a  [        RF                  " [        S"5      5      eURI                  5         URK                  5       (       a  URM                  5         U$ U RN                  (       d  U R1                  [        S#5      5        U$ )$zpick fixup chunks from targetctx, apply them to stack.

if targetctx is None, the working copy context will be used.
if stack is None, the current draft stack will be used.
return fixupstate.
Nr   r   r`  rU   s   cannot absorb into a merges7   absorb: only the recent %d changesets will be analysed
s   no mutable changeset to changer&   r   interactiver`   r   r   Tapply_changesprint_changess   counts   
%d changesets affected
s   summaryrJ  )r]   s	   changesetr(  r)  r   r#  s   descfirstlinerI  r   dry_runs#   apply changes (y/N)? $$ &Yes $$ &Nor   s   absorb cancelled
s   nothing applied
)(	configintrX   rY   r   r   r   r^   warnr:  r   rR  r   byteskwargsr   r   diffrI   
parsepatchr   recordfilterr  	formatterr   r*  r   r   rE   rb   r	   r   r   	firstliner   endpromptchoiceCanceledErrorr   rg  ru  r7   )r   r@   rd   rQ  patsr   r\   r[   r[  matcherr  
origchunksr   r   r]   descfirstlines                   r)   absorbr    s2    }Y(9:t*w !A%""1%B#CDDg-SZ5(GG% 	 q!BCDDJ	|u,,t,EmmIX-A-A$-GHGxxzz$b	 0)..2BGL%%d+
%%bg>qA&uRy&9	xx !%_	Bxx  (A(A\\)X%9%9$%?@	NN9r*	~

3S9J9J5K	
 	$E?C+++LLNJJ3JGG\G*HHWj#'')>HJ&001BCMHH +	   # 	88I))!!6    %%a(=&>??<<>>!!# L HHQ+,-Lr,      as   apply-changess0   apply changes without prompting for confirmation   ps   print-changess;   always print which changesets are modified by which changes   is   interactives*   interactively select which chunks to apply   es
   edit-linessG   edit what lines belong to which changesets before commit (EXPERIMENTAL)s   hg absorb [OPTION] [FILE]...)helpcategory	helpbasicc                   UR                  5          UR                  5          US   (       d  [        R                  " U5        [	        X4SU0UD6n[        S UR                  R                  5        5       5      S:X  a   SSS5        SSS5        g SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)a  incorporate corrections into the stack of draft changesets

absorb analyzes each change in your working directory and attempts to
amend the changed lines into the changesets in your stack that first
introduced those lines.

If absorb cannot find an unambiguous changeset to amend for a change,
that change will be left in the working directory, untouched. They can be
observed by :hg:`status` or :hg:`diff` afterwards. In other words,
absorb does not write to the working directory.

Changesets outside the revset `::. and not public() and not merge()` will
not be changed.

Changesets that become empty after applying the changes will be deleted.

By default, absorb will show what it plans to do and prompt for
confirmation.  If you are confident that the changes will be absorbed
to the correct place, run :hg:`absorb -a` to apply the changes
immediately.

Returns 0 on success, 1 if all chunks were ignored and nothing amended.
r  r  c              3  *   #    U  H	  oS    v   M     g7f)r   Nr&   )rF  rl  s     r)   rG  absorbcmd.<locals>.<genexpr>  s     76t6s   r   NrU   )wlocklockr   checkunfinishedr  rn  r   rq  )r   r@   r  r   r[  s        r)   	absorbcmdr  G  s    | 
tyy{I##D)r3d3d37U--446771< #
 = #{{s)   B4AB# B4B4#
B1	-B44
Cr%   rv   )4r4   
__future__r   collectionsmercurial.i18nr   mercurial.noder   r   	mercurialr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   mercurial.utilsr   
testedwithcmdtablecommandconfigtable
configitem
colortabler   r!   r:   rS   r^   rl   	filestorern   r   r   r:  r  r  r  
dryrunoptstemplateoptswalkoptsCATEGORY_COMMITTINGr  r&   r,   r)   <module>r     s  4 #      " ' #



H
%!!+.
 
9lD 1 
9mT 2 
9' 4 % 
 %% 
! 
!.O d#5?? #.8w wtnD nDb	""/@Od 	 AB		
 LM		
 ;<		
 "		
': ;< => ?@ %&,,I%LM%Lr,   