ó œt•Pc @shdZddlmZddlmZmZddlmZmZmZm Z m Z ddl Z ddl Z ddl Z ddlZddlZdZd„Zd„Zd „Zied d d 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 |ƒƒt j |ƒ}g}||} x|D]} t j| ƒ} | | krqìn|jd| ƒtjj|| ƒ} | | } |j| | jƒƒ}d| jƒkr€|j|| ƒn8|j| |ƒd| jƒkr¸t j| ttƒn|d krì|j| |j| ƒtj| ƒjfƒqìqìW||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ót‰qóntj|| ||ƒ} 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æt|||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&t dir1a_filestdir1atrev1at dir1b_filestdir1btrev1bR*tdir2roottrev2tdir2tlabel1atlabel1btlabel2t common_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 „}||||ƒtdd d td ƒ|ft|>s,(< ( ‚      5