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

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


��c@s�dZddlmZmZddlmZmZmZmZm	Z	ddlm
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZiZeje�ZdZejd�Zdd	eed
�fddded
�fddded�fgZd�Zdefd��YZd�Zdefd��YZd�Zd�Z edej!ddeed��d��Z"d�Z#d�Z$d �Z%d!�Z&e$ged"�fed#<d$�Z'd%�Z(ej)d&7_)dS('s<commands to interactively select changes for commit/qrefreshi�(tgettextt_(tcmdutiltcommandst
extensionsthgtpatch(tutilNtinternals'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)twsignore-all-spaces'ignore white space when comparing linestbsignore-space-changes+ignore changes in the amount of white spacetBsignore-blank-liness(ignore changes whose lines are all blankc#sXtj|���fd�}x3trS�j�}|s=Pn|jd�s[|jd�r�d�}|||�}�j�}|jd�r��j�}|||g7}n
�j|�d|fVq!|ddkr�||d
��fVq!|ddkrd||d
��fVq!tj|�}|rEd|j�fVq!d|fVq!WdS(s�like patch.iterhunks, but yield different events

    - ('file',    [header_lines + fromfile + tofile])
    - ('context', [context_lines])
    - ('hunk',    [hunk_lines])
    - ('range',   (-start,len, +start,len, proc))
    csZ|g}xJtrU�j�}|s(Pn||�rD|j|�q�j|�PqW|S(sscan lr while predicate holds(tTruetreadlinetappendtpush(tfirsttptlinestline(tlr(s0/sys/lib/python2.7/site-packages/hgext/record.pyt	scanwhile(s		
s
diff --git a/sdiff -r cSs'|jdd�}|p&|ddkS(Niis---tdiff(s---sdiff(tsplittNone(Rts((s0/sys/lib/python2.7/site-packages/hgext/record.pyt	notheader;ss---tfileit tcontextcSs|ddkS(Nis \((tl((s0/sys/lib/python2.7/site-packages/hgext/record.pyt<lambda>Gss-+thunkcSs|ddkS(Nis-+\((R((s0/sys/lib/python2.7/site-packages/hgext/record.pyRIstrangetotherN(	Rt
linereaderRR
t
startswithRtlines_retmatchtgroups(tfpRRRtheadertfromfilettofiletm((Rs0/sys/lib/python2.7/site-packages/hgext/record.pyt	scanpatchs.		
R)cBs�eZdZejd�Zejd�Zejd�Zejd�Zejd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�ZRS(sIpatch header

    XXX shouldn't we move this to mercurial/patch.py ?
    sdiff --git a/(.*) b/(.*)$sdiff -r .* (.*)$s (?:index|new file|deleted file) s(?:new file|deleted file) s"(?:index|new|deleted|copy|rename) cCs||_g|_dS(N(R)thunks(tselfR)((s0/sys/lib/python2.7/site-packages/hgext/record.pyt__init__\s	cCstjd�|jD��S(Ncss|]}|jd�VqdS(sindex N(R$(t.0th((s0/sys/lib/python2.7/site-packages/hgext/record.pys	<genexpr>as(RtanyR)(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pytbinary`sc
Cs�x�jD]�|jd�r6|jtd��Pn|jj|�r{|j|�|j�rw|jtd��nPn|jd�r�|jtd�t|j�t	g|jD]}t
|j|j�^q��f�Pn|j|�q
WdS(Nsindex s-this modifies a binary file (all or nothing)
sthis is a binary file
s---s%d hunks, %d lines changed
(
R)R$twriteRt	pretty_reR&R4tlenR.tsumtmaxtaddedtremoved(R/R(R2((s0/sys/lib/python2.7/site-packages/hgext/record.pytprettycs
6cCs|jdj|j��dS(Nt(R5tjoinR)(R/R(((s0/sys/lib/python2.7/site-packages/hgext/record.pyR5tscs tj�fd��jD��S(Nc3s!|]}�jj|�VqdS(N(tallhunks_reR&(R1R2(R/(s0/sys/lib/python2.7/site-packages/hgext/record.pys	<genexpr>xs(RR3R)(R/((R/s0/sys/lib/python2.7/site-packages/hgext/record.pytallhunkswscCso|jj|jd�}|rN|j�\}}||krD|gS||gS|jj|jd�j�SdS(Ni(t
diffgit_reR&R)R'tdiff_re(R/R&R*R+((s0/sys/lib/python2.7/site-packages/hgext/record.pytfileszs
cCs|j�dS(Ni�(RC(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pytfilename�scCs ddjtt|j���S(Ns<header %s>R(R>tmaptreprRC(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pyt__repr__�scs tj�fd��jD��S(Nc3s!|]}�jj|�VqdS(N(t
special_reR&(R1R2(R/(s0/sys/lib/python2.7/site-packages/hgext/record.pys	<genexpr>�s(RR3R)(R/((R/s0/sys/lib/python2.7/site-packages/hgext/record.pytspecial�s(t__name__t
__module__t__doc__tretcompileRARBR?R6RHR0R4R<R5R@RCRDRGRI(((s0/sys/lib/python2.7/site-packages/hgext/record.pyR)Qs						
		cCshtg|D]}|ddkr
|^q
�}tg|D]}|ddkr9|^q9�}||fS(shunk -> (n+,n-)it+t-(R7(R R2taddtrem((s0/sys/lib/python2.7/site-packages/hgext/record.pytcountchanges�s//R cBs>eZdZdZd�Zd�ZeZd�Zd�ZRS(sBpatch hunk

    XXX shouldn't we merge this with patch.hunk ?
    ic	s�fd�}|�_|||�\�_�_|||�\�_�_|�_|�_t�j�\�_�_	dS(NcsDt|��j}tr:|dkr:|||�j fS||fS(Ni(R7t
maxcontexttFalse(tnumberRtdelta(R/(s0/sys/lib/python2.7/site-packages/hgext/record.pyttrimcontext�s(
R)tfromlinetbeforettolinetaftertprocR RSR:R;(	R/R)RYR[R]RZR R\RX((R/s0/sys/lib/python2.7/site-packages/hgext/record.pyR0�s			c
Cs�t|j�t|j�}|jrE|jddkrE|d8}n||j}||j}|jd|j||j||jo�d|jf�|jdj	|j|j
|j��dS(Ni�s\ No newline at end of file
is@@ -%d,%d +%d,%d @@%s
RR=(R7RZR\R;R:R5RYR[R]R>R (R/R(RWtfromlenttolen((s0/sys/lib/python2.7/site-packages/hgext/record.pyR5�s


	cCs
|jj�S(N(R)RD(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pyRD�scCsd|j�|jfS(Ns<hunk %r@%d>(RDRY(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pyRG�s(	RJRKRLRTR0R5R<RDRG(((s0/sys/lib/python2.7/site-packages/hgext/record.pyR �s			cCs�dtfd��Y}|�}d}xit|�D][\}}y|j||||�Wn*tk
r�tjd||f��nX|}q2W|j�S(s&patch -> [] of headers -> [] of hunks tparsercBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	iied6ed	6ed
6ed6d	6ied	6ed
6ed6ed6d6ied6ed	6ed6d
6ied6ed
6d6ied6d6Z
RS(
spatch parsing state machinecSsLd|_d|_d|_d|_g|_g|_g|_g|_dS(NiR=(	RYR[R]RR)RRZR theaders(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pyR0�s							cSs@|\}}}}}t|�|_t|�|_||_dS(N(tintRYR[R](R/tlimitst	fromstarttfromendttostartttoendR]((s0/sys/lib/python2.7/site-packages/hgext/record.pytaddrange�scSs�|jr�t|j|j|j|j|j|j|�}|jjj|�|jt|j�|j	7_|jt|j�|j
7_g|_g|_d|_n||_dS(NR=(R R)RYR[R]RZR.RR7R;R:R(R/RR2((s0/sys/lib/python2.7/site-packages/hgext/record.pyt
addcontext�s			cSs.|jr!|j|_g|_n||_dS(N(RRZR (R/R ((s0/sys/lib/python2.7/site-packages/hgext/record.pytaddhunk�s	cSs6|jg�t|�}|jj|�||_dS(N(RiR)RaR(R/thdrR2((s0/sys/lib/python2.7/site-packages/hgext/record.pytnewfile�s
cSsdS(N((R/R((s0/sys/lib/python2.7/site-packages/hgext/record.pytaddother�scSs|jg�|jS(N(RiRa(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pytfinished�s
RRR R!R"(RJRKRLR0RhRiRjRlRmRnttransitions(((s0/sys/lib/python2.7/site-packages/hgext/record.pyR`�s.	
						



Rsunhandled transition: %s -> %s(tobjectR-RotKeyErrorRt
PatchErrorRn(R(R`Rtstatetnewstatetdata((s0/sys/lib/python2.7/site-packages/hgext/record.pyt
parsepatch�sB	
	
cs(�fd�}t�}i}d\}}dtd�|D��}}x�|D]�}	|t|	j�7}d}d}
dj|	j�}||kr�qNn|j|�|dkr�|	j��nt	d�t	d�jd�|	j
�D��}||||d�\}
}}}|
sqNn|	g||	j�<|	j�rZ||	j�c|	j7<qNnxt
|	j�D]n\}}|dkr�|dkr�|j��n|dkr�t	d	�|j�}n6|t|	j�|}t	d
�|||j�f}|||||�\}
}}}|
ra|
rGtj|�}|j|
7_n||j�j|�qj|dk	r�xh|D]I}x@|jD]5}|
r�|j|
7_n||j�j|�q�WqtWqj|
|j|j7}
qjWqNWtg|j�D].}	|	dj�st|	�dkr�^q��S(
s:Interactively filter patch chunks into applied-only chunksc
s
d&}|d&k	r"||||fS|d&k	r>||||fSx�trtd�}td�td�td�td�td�td�td�td	�td
�f	}�jd||f|�}�jd�|d
krJttj�}|jd�d}	x@||	j	�D].}
|
j
d�r�j|
j�d�qqWqAn�|dkr_t}n�|dkrtt}n�|dkrm|d&kr��jtd���jd�qAn|j
j�r�jtd���jd�qAndtd�}tjdddddt�\}
}d&}z/tj|
d�}|j
j|�|j|�|jdjg|j	�D]}d|^ql��|j��j�}tjd||fdi�j�d 6d!tjd"td#�d$�j�t|�}tj�}x-|D]%}|j
d%�s|j|�qqW|j�|jd�t|�}Wd&tj |�~Xt}n�|d'kr�t}}no|d(kr�t}}nV|d)kr�t}}n=|d*kr�t}}n$|d+kr�jtd,���n||||fSWd&S(-s�prompt query, and process base inputs

        - y/n for the rest of file
        - y/n for the rest
        - ? (help)
        - q (quit)

        Return True/False and possibly updated skipfile and skipall.
        s[Ynesfdaq?]s&Yes, record this changes&No, skip this changes&Edit the change manuallys$&Skip remaining changes to this files&Record remaining changes to this &files'&Done, skip remaining changes and filess*Record &all changes to all remaining filess&Quit, recording no changess&?s%s %ss
is::is      iis cannot edit patch for whole files!cannot edit patch for binary files---s�
To remove '-' lines, make them ' ' lines (context).
To remove '+' lines, delete them.
Lines starting with # will be removed from the patch.

If the patch applies cleanly, the edited hunk will immediately be
added to the record list. If it does not apply cleanly, a rejects
file will be generated: you can use that when you try again. If
all lines of the hunk are removed, then the edit is aborted and
the hunk is left unchanged.
tprefixs
hg-editor-tsuffixs.diffttextR	s# s%s "%s"tenvirontHGUSERtonerrt	errprefixsedit failedtoutt#Niiiiis	user quit(!RRRtpromptchoiceR5RtrecordRLtfindt
splitlinesR$tstripRUR)R4ttempfiletmkstemptostfdopenR>tcloset	geteditorRtsystemtusernametAborttfouttopent	cStringIOtStringIOtseekRvtunlink(tskipfiletskipalltquerytchunkt
newpatchestrespstchoicestrtdoctcRtrettphelptpatchfdtpatchfnt	ncpatchfptftiteditortpatchfpR(tui(s0/sys/lib/python2.7/site-packages/hgext/record.pytprompts�
									
		




3





	



icss|]}t|j�VqdS(N(R7R.(R1R2((s0/sys/lib/python2.7/site-packages/hgext/record.pys	<genexpr>ysiR=sexamine changes to %s?s and css|]}d|VqdS(s'%s'N((R1R�((s0/sys/lib/python2.7/site-packages/hgext/record.pys	<genexpr>�ssrecord this change to '%s'?srecord change %d/%d to '%s'?N(NN(tsetRR8R7R.R>R)RQR<RRCRDR@t	enumeratetcopyR[RR;R:t
itervaluesRI(R�RaR�tseentappliedR�R�tposttotalR2t	fixoffsetRktmsgR�tnpR�R�tidxR�tnewpatchtnewhunk((R�s0/sys/lib/python2.7/site-packages/hgext/record.pytfilterpatchs`h	

	&!
"R�s
^commit|ciishg record [OPTION]... [FILE]...cOs#t||tjdt||�dS(sDinteractively select changes to commit

    If a list of files is omitted, all changes reported by :hg:`status`
    will be candidates for recording.

    See :hg:`help dates` for a list of formats valid for -d/--date.

    You will be prompted for whether to record changes to each
    modified file, and for files with multiple changes, for each
    change to use. For each query, the following responses are
    possible::

      y - record this change
      n - skip this change
      e - edit this change manually

      s - skip remaining changes to this file
      f - record remaining changes to this file

      d - done, skip remaining changes and files
      a - record all changes to all remaining files
      q - quit, recording no changes

      ? - display help

    This command is not available when committing a merge.tcommitN(tdorecordRR�RU(R�trepotpatstopts((s0/sys/lib/python2.7/site-packages/hgext/record.pyR��s cs[|ds|||||�Stjd���fd�}t|||dt||�dS(Ntinteractivetmqcs�j|||�dS(N(trefresh(R�R�R�R�(R�(s0/sys/lib/python2.7/site-packages/hgext/record.pyt
committomq�stqrefresh(RR�R�R(torigfnR�R�R�R�R�((R�s0/sys/lib/python2.7/site-packages/hgext/record.pyR��s

cs~ytjd��Wn&tk
r;tjtd���nX|jj����fd�}t|||dt	||�dS(svinteractively record a new patch

    See :hg:`help qnew` & :hg:`help record` for more information and
    usage.
    R�s'mq' extension not loadedcs't|d<�j||�||�dS(Nt	checkname(RUtnew(R�R�R�R�(R�R(s0/sys/lib/python2.7/site-packages/hgext/record.pyR��s
tqnewN(
RR�RqRR�RR�tcheckpatchnameR�RU(R�R�RR�R�R�((R�Rs0/sys/lib/python2.7/site-packages/hgext/record.pytqrecord�s
cOs6|dr t|||||�S||||||�S(NR�(R�(R�R�R�RtargsR�((s0/sys/lib/python2.7/site-packages/hgext/record.pyR��s
c
s�|j�s(tjtd�|��n|j���fd�}d�}|j}	tj|d|�ztj	|||||�SWd|	|_XdS(Ns)running non-interactively, use %s insteadcst|dj��dk}|r:tjtd���n|jd|�d }tj|dt	dt
dt
d|jd	�d
|jd�d|jd
���}tj|d|d|�}t
j�}	|	jdj|��|	jd�yt|t|	��}Wn/tjk
r5}
tjtd�|
��nX~	t�}x?|D]7}y|jt|j���WqItk
rqIXqIW|d|d|d}
g|
D]}||kr�|^q�}|s�jtd��dSt|d�}�r�}n%g|D]}||kr|^q}i�|r�|jd�}ytj|�Wq�tk
r}}
|
jtjkr~�q~q�Xnz��|D]�}tjd|j dd�dd|�\}}tj!|�|j"d||f�tj#|j$|�|�t%j&|j$|�|�|�|<q�Wt
j�}	x0|D](}|j'��kr6|j|	�q6q6W|	j(�}|	jd��r�t)j*||j+j,��fd��n|r y@|j"d�|j"|	j-��tj.|||	ddd�Wq tjk
r}
tjt/|
���q Xn~	tj0�}tj1|j2�z�||||�Wdtj1|�XdSWdy�xp�j3�D]b\}}|j"d||f�tj#||j$|��t%j&||j$|��tj4|�qW|r�j5|�nWntk
rnXXdS( s%This is generic record driver.

        Its job is to interactively filter local changes, and
        accordingly prepare working directory into a state in which the
        job can be delegated to a non-interactive commit command such as
        'commit' or 'qrefresh'.

        After the actual job is done by non-interactive command, the
        working directory is restored to its original state.

        In the end we'll record interesting changes, and everything else
        will be left in place, so the user can continue working.
        is9cannot partially commit a merge (use "hg commit" instead)R&iR�tgittnodatestignorewstignore_all_spacetignorewsamounttignore_space_changetignoreblanklinestignore_blank_linestchangesR=iserror parsing patch: %sisno changes to record
srecord-backupsRwt/Rt.tdirsbackup %r as %r
cs
|�kS(N((tkey(tbackups(s0/sys/lib/python2.7/site-packages/hgext/record.pyRTssapplying patch
teolmodeNsrestoring %r to %r
(6R7RtparentsRR�RtstatusRtdiffoptstdictRtgetRR�R�R5R>R�R�RvRrR�tupdateRCtAttributeErrorR�tmkdirtOSErrorterrnotEEXISTR�R�treplaceR�tdebugtcopyfiletwjointshutiltcopystatRDttellRtreverttdirstatetp1tgetvaluet
internalpatchtstrtgetcwdtchdirtroott	iteritemsR�trmdir(R�R�tmessageR&R�tmergeR�R�tchunksR(terrt
contendersR2tchangedR�tnewfilestmodifiedttobackupt	backupdirtfdttmpnameR�tdopatchtcwdtrealname(t	backupallt
commitfunc(R�s0/sys/lib/python2.7/site-packages/hgext/record.pyt
recordfunc�s�
	

%	%





 	
csS|jdd�}x:tj�fd��D] \}}||d||�q+WdS(NtlabelR=cs�S(N(((R�(s0/sys/lib/python2.7/site-packages/hgext/record.pyR�s(tpopRt	difflabel(torigR�tkwRR�R((R�s0/sys/lib/python2.7/site-packages/hgext/record.pyt	wrapwrite�s%R5(
R�RR�RR�R5RtwrapfunctionRR�(
R�R�Rt
cmdsuggestRR�R�RRtoldwrite((RRs0/sys/lib/python2.7/site-packages/hgext/record.pyR��s

�	s&hg qrecord [OPTION]... PATCH [FILE]...R�cCs�ytjd�}Wntk
r'dSXt|jddttd�ftd<td|jttd��td|jt	td	��dS(
NR�s^qnewis&hg qrecord [OPTION]... PATCH [FILE]...R�R�s interactively record a new patchR�s'interactively select changes to refresh(
RR�RqR�tcmdtableR�Rt_wrapcmdR�R�(R�R�((s0/sys/lib/python2.7/site-packages/hgext/record.pytuisetup�s
cCs6tj|||�}|djddd|f�dS(NiR�R�(RtwrapcommandRR(tcmdttabletwrapfnR�tentry((s0/sys/lib/python2.7/site-packages/hgext/record.pyR�ss record qrecord(*RLtmercurial.i18nRRt	mercurialRRRRRRR�R�R�R�RMR�R�Rtcommandt
testedwithRNR%RURR�R-RpR)RSR RvR�RR�R�R�R�R�RRt	inferrepo(((s0/sys/lib/python2.7/site-packages/hgext/record.pyt<module>s@(T				3<	(	P	�				�		

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].