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

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


�t�c@shdZddlmZddlmZmZddlmZmZmZm	Z	m
Z
ddlZddlZddl
Z
ddlZddlZdZd�Zd�Zd	�Zied
dded
�ed�fddged�ed�fddged�ed�fddded�ed�fge	jed�fd6Zd�Ze	jd7_dS(s�command to allow external programs to compare revisions

The extdiff Mercurial extension allows you to use external programs
to compare revisions, or revision with working directory. The external
diff programs are called with a configurable set of options and two
non-option arguments: paths to directories containing snapshots of
files to compare.

The extdiff extension also allows you to configure new diff commands, so
you do not need to type :hg:`extdiff -p kdiff3` always. ::

  [extdiff]
  # add new command that runs GNU diff(1) in 'context diff' mode
  cdiff = gdiff -Nprc5
  ## or the old way:
  #cmd.cdiff = gdiff
  #opts.cdiff = -Nprc5

  # add new command called vdiff, runs kdiff3
  vdiff = kdiff3

  # add new command called meld, runs meld (no need to name twice)
  meld =

  # add new command called vimdiff, runs gvimdiff with DirDiff plugin
  # (see http://www.vim.org/scripts/script.php?script_id=102) Non
  # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
  # your .vimrc
  vimdiff = gvim -f "+next" \
            "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"

Tool arguments can include variables that are expanded at runtime::

  $parent1, $plabel1 - filename, descriptive label of first parent
  $child,   $clabel  - filename, descriptive label of child revision
  $parent2, $plabel2 - filename, descriptive label of second parent
  $root              - repository root
  $parent is an alias for $parent1.

The extdiff extension will look in your [diff-tools] and [merge-tools]
sections for diff tool arguments, when none are specified in [extdiff].

::

  [extdiff]
  kdiff3 =

  [diff-tools]
  kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child

You can use -I/-X and list of file or directory names like normal
:hg:`diff` command. The extdiff extension makes snapshots of only
needed files, so running the external diff program will actually be
pretty fast (at least faster than having to compare the entire tree).
i�(t_(tshorttnullid(tscmutilRtutiltcommandstencodingNtinternalcCstjj|j�}|dkr*d}n|d	k	rOd|t|�f}ntjj||�}tj|�|d	k	r�|jt	d�t
|�t|�f�n|jt	d�t
|��tj|�}g}||}	x|D]}
t
j|
�}||	krq�|jd|�tjj||�}|	|}
|j||
j��}d|
j�kr�|j||�n8|j||�d|
j�kr�t
j|tt�n|d	kr�j||j|
�tj|�jf�q��||fS(
s�snapshot files as of some revision
    if not using snapshot, -I/-X does not work and recursive diff
    in tools like kdiff3 and meld displays too many files.ttroots%s.%ss(making snapshot of %d files from rev %s
s3making snapshot of %d files from working directory
s  %s
tltxN(tostpathtbasenameR	tNoneRtjointmkdirtnoteRtlenRtopenerRtpconvertt
wwritedatatdatatflagstsymlinktwritetsetflagstFalsetTruetappendtwjointlstattst_mtime(tuitrepotfilestnodettmproottdirnametbasetwopenert
fns_and_mtimetctxtfntwfntdesttfctxR((s1/sys/lib/python2.7/site-packages/hgext/extdiff.pytsnapshotGs@	



c+s?|jd�}|jd�}dj|�}d|k�|rc|rctd�}	tj|	��nr|r�tj||d�j�}
|j	j
|
�\}}n6tj||�\}}
|s�|jj
�}nt}�r�tkr��q�tj||
||�}
tt|j||
|
�d �\}}}�rktt|j||
|
�d �\}}}nt�t�t�}}}||B|B|B}||B|B}|s�dStjdd	�}zS||B||B|B}t|||||�d}d
||j�}�r\||B||B|B}t|||||�d}d
||j�}nd}d}g}d}d}|
r�t||||
|�d} d
||
j�}nBt|�dkr�|||d|�\} }nd} |j}|}!|}"|}#t|�dkr�tj|j��}$tjj|||$�}|$|}!tjj|�sntj}n�r�tjj|||$�}|$|}"tjj|�s�tj}q�ntjj|| |$�} |$|}#nt d
|d|d|d|!d|"d|#d| d|j����fd�}%d}&�rWt!j"|&|�rW|d7}nt!j#|&|%|�}tj$|�d|}'|j%d|'|f�tj&|'d|d|j'�xY|D]Q\}(})}*tj(|(�j)|*kr�|j%d|)|(f�tj*|(|)�q�q�WdSWd|j+td��t,j-|�XdS(s
Do the actual diff:

    - copy to a temp structure if diffing 2 internal revisions
    - copy to a temp structure if diffing working revision with
      another one and more than 1 file is changed
    - just invoke the diff for a single file in the working dir
    trevtchanget s$parent2s2cannot specify --rev and --change at the same timeiitprefixsextdiff.s@%dRitparenttparent1tparent2tplabel1tplabel2tclabeltchildR	cs8|j�d}�r'|dkr'dStj�|�S(NiR7R(tgroupRt
shellquote(tmatchtkey(tdo3waytreplace(s1/sys/lib/python2.7/site-packages/hgext/extdiff.pytquote�ss6\$(parent2|parent1?|child|plabel1|plabel2|clabel|root)s $parent1 $childsrunning %r in %s
tcwdtouts6file changed while diffing. Overwriting: %s (src: %s)
Nscleaning up temp directory
(.tgetRRRtAbortRt	revsingleRR%t	changelogtparentstrevpairtdirstatetp2RRR>tmaptsettstatusttempfiletmkdtempR0R1RR	t	localpathtpopRR
tisfiletdevnulltdicttretsearchtsubR=tdebugtsystemtfoutR R!tcopyfileRtshutiltrmtree(+R"R#tdiffcmdtdiffoptstpatstoptstrevsR2targstmsgtnode2tnode1atnode1btmatchertmod_atadd_atrem_atmod_btadd_btrem_btmodaddtcommonR&tdir1a_filestdir1atrev1atdir1b_filestdir1btrev1bR*tdir2roottrev2tdir2tlabel1atlabel1btlabel2tcommon_fileRBtregextcmdlinetcopy_fnt
working_fntmtime((R@RAs1/sys/lib/python2.7/site-packages/hgext/extdiff.pytdodiffos�	+.!	



	cOsU|jd�}|jd�}|s<d}|p6dg}nt||||||�S(suse external program to diff repository (or selected files)

    Show differences between revisions for the specified files, using
    an external program. The default program used is diff, with
    default options "-Npru".

    To select a different program, use the -p/--program option. The
    program will be passed the names of two directories to compare. To
    pass additional options to the program, use -o/--option. These
    will be passed before the names of the directories to compare.

    When two revision arguments are given, then changes are shown
    between those revisions. If only one revision is specified then
    that revision is compared to the working directory, and, when no
    revisions are specified, the working directory files are compared
    to its parent.tprogramtoptiontdiffs-Npru(RER�(R"R#RbRcR�R�((s1/sys/lib/python2.7/site-packages/hgext/extdiff.pytextdiff�stpR�Rscomparison program to runtCMDtoR�s!pass option to comparison programtOPTtrR1trevisiontREVtcR2schange made by revisionshg extdiff [OPT]... [FILE]...R�cCsWxP|jd�D]?\}}|jd�ru|d}|sD|}n|jdd|d�}|rl|gpog}nI|jd�r�qn4|r�tj|�}|jd�}n
|g}}|gkr|jd|d�p�jd	|d�}|rtj|�}qnd
�}||||�tdddtd�|ft|<qWdS(
NR�scmd.isopts.Ris
diff-toolss	.diffargssmerge-toolscsM��fd�}td�tdtj���}|jtj�|_|S(s'use closure to save diff command to usecs!t||��|d||�S(NR�(R�(R"R#RbRc(RaR
(s1/sys/lib/python2.7/site-packages/hgext/extdiff.pytmydiff1ss�use %(path)s to diff repository (or selected files)

    Show differences between revisions for the specified files, using
    the %(path)s program.

    When two revision arguments are given, then changes are shown
    between those revisions. If only one revision is specified then
    that revision is compared to the working directory, and, when no
    revisions are specified, the working directory files are compared
    to its parent.R
(RRVRtuireprtdecodeRt__doc__(tcmdR
RaR�tdoc((RaR
s1/sys/lib/python2.7/site-packages/hgext/extdiff.pytsave/s
ishg %s [OPTION]... [FILE]...(tconfigitemst
startswithtconfigtshlextsplitRStcmdtableR(R"R�R
RaReR�((s1/sys/lib/python2.7/site-packages/hgext/extdiff.pytuisetups,
	
	s extdiff(R�tmercurial.i18nRtmercurial.nodeRRt	mercurialRRRRRR�R^RPRWt
testedwithR0R�R�twalkoptsR�R�t	inferrepo(((s1/sys/lib/python2.7/site-packages/hgext/extdiff.pyt<module>>s,(<	(	�					5

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.