^c[c dZddlZddlZddlZddlZddlZddlmZddlm Z m Z ddl m Z m Z mZmZmZmZmZmZmZmZmZddlmZmZiZejeZiZejeZeddd d edd d edddd eddd dZdZdZ daB 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. If there is more than one file being compared and the "child" revision is the working directory, any modifications made in the external diff program will be copied back to the working directory from the temporary directory. 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 meld, runs meld (no need to name twice). If # the meld executable is not available, the meld tool in [merge-tools] # will be used, if available 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 If a program has a graphical interface, it might be interesting to tell Mercurial about it. It will prevent the program from being mistakenly used in a terminal-only environment (such as an SSH terminal session), and will make :hg:`extdiff --per-file` open multiple file diffs at once instead of one by one (if you still want to open file diffs one by one, you can use the --confirm option). Declaring that a tool has a graphical interface can be done with the ``gui`` flag next to where ``diffargs`` are specified: :: [diff-tools] kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child kdiff3.gui = true 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). N)_)nullrevshort) archivalcmdutilencodingerror filemerge formatter logcmdutilpycompat registrarscmutilutil)procutil stringutilextdiffsopts\..*T)defaultgenericsgui\..*)r diff-toolss .*\.diffargs$s.*\.gui$sships-with-hg-corec tj|j}|dkrd}|d|t |fz}tj||}tj|g}|B|tdt|t |fzn2|tdt|z|r|j ddd tj |||d tj||| t!|D]} t#j| } |d | z|]tj|| } || || tj| f||fS) zsnapshot 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.rrootNs%s.%ss(making snapshot of %d files from rev %s s3making snapshot of %d files from working directory suis archivemetaFsfiles)matchsubreposs %s )ospathbasenamerootrjoinmkdirnoterlenui setconfigrarchiver matchfilessortedrpconvertappendwjoinlstat) r$repofilesnodetmproot listsubreposdirnamebase fnsandstatfnwfndests //usr/lib/python3/dist-packages/hgext/extdiff.pysnapshotr9sgty))G#~~ guT{{33 7<< ) )DHTNNNJ   : ; ;5zz5;;' (     E F F5zz     J %777    $T511!     -- J JB-##C GGIO $ $ $|w||D#..!!4B$"HIII J rc  ||||||||d  fd} d} stj| |s|dz }tj| | |S)N)sparentsparent1parent2splabel1splabel2schildsclabelrc|d}|d}s|dkr|S|tj|zS)Nr;)groupr shellquote)rprekeydo3wayreplaces r8quotezformatcmdline..quotesRkk!nnkk!nn #++JX(6666rsJ(['"]?)([^\s'"$]*)\$(parent2|parent1?|child|plabel1|plabel2|clabel|root)\1s $parent1 $child)researchsub) cmdline repo_rootrCparent1plabel1parent2plabel2childclabelrEregexrDs ` @r8 formatcmdlinerRs  G777777 E  '")E733'&& 6% ( ((rc tj|}tjtj|dtjtj|tjtj|}|S)zflike 'procutil.system', but returns the Popen object directly so we don't have to wait on it. T)shell close_fdsenvcwd) r shellenviron subprocessPopen tonativestrclosefds tonativeenvr rapply)cmdenvironrWrVprocs r8_systembackgroundrbsi   ( (C  S!!#   % % OH0# 6 6    D Krc g}t|}tt|D]X\}}tj||}|| z}tj|s tj}d}d}|rPtj| |}|| z}tj|s tj}tj| |}|| z}|rtd||dz|fz}td}| d||fz}|dkrs|dkrm| |dD]1\}}| d|tj|fz2| d||fz}|dkm|dkrn|dkr|d krnt||||||||| }|s|sF|d tj||fz|||d |dtj||fzt'||}||Z|rJ|d 5|D]}| ddddS#1swxYwYdSdS)Nrsdiff %s (%d of %d)sZ[Yns?]$$ &Yes, show diff$$ &No, skip this diff$$ &Skip remaining diffs$$ &? (display help)s%s %sr>s%s - %s rr=rCrKrLrMrNrOrPrunning %r in %s rrW blockedtags running %r in %s (backgrounded) )rW)r# enumerater(rrr isfiler osdevnullr promptchoiceextractchoiceswriterlowerrRdebugbytestrsystemrbr*timeblockedsectionwait)rIrJr$guitoolrCconfirm commonfilesr0dir1adir1bdir2rev1arev1brev2 waitprocs totalfilesidx commonfilepath1alabel1apath1blabel1bpath2label2 difffiles responsesrct curcmdlineras r8_runperfilediffrs&I[!!J$VK%8%899L#L#ZeZ00u$w~~f%% ('F  ,W\\%44F 5(G7>>&)) ,!+ T:..d"  /00a4I (IIy+A ABBAAvv1ff " 1 1) < ?  k5::<<(   $JH D yy{{D&$))++wII!L " Vq $BfdGXNNjj9GG F 88K 0  v;;!  .66KGLL%==E!E)G7>>%(( + * / We[AA%-w~~e,,/$.E7<<$ <>>>   I HHZ((',,w..28B"',,w...dh--    "$.//R'"" 4= !R %6 6 6~++&BJ,>?? HH/2 = ``` entry: cmd: command/tool name path: path to the tool cmdline: the command which should be run isgui: whether the tool uses GUI or not Reads all external tools related configs, whether it be extdiff section, diff-tools or merge-tools section, or its specified in an old format or the latest format. scmd.Nropts.rgui.rdFs .diffargs)rs merge-toolss.gui) r expandpath startswithrfindexer findexternaltoolconfigr@ configboolr#r shlexsplit) r$r_rdiffoptsrIrrBsectionargss r8_gettooldetailsrs$ ?4 D ~~g9!""g B#C((D| 1"c::Ac99ZC88%d++  ' th &G j'C-88  G8.w77881>( # # s~~g'>'>  $3BT$B$B!T7E   N , - - 3 7    4% ( (  * * * * * *r)NN)F)/rrrFrrrYmercurial.i18nrmercurial.noderr mercurialrrrr r r r r rrrmercurial.utilsrrcmdtabler configtable configitem testedwithr9rRrbrrrrwalkopts subrepooptsrrrrrr i18nfunctionsrrr8r$snJJZ                             ) H % % !Y !+ . .             # ,,,^')')')T    fffR   BR R R jGGGGZ    A2 3 3 AfII   vr11566& B gsAA6777D eS!!233QQwZZ@ y#qq!;< ? ?6KA&''/   #1#1  #1L        D5%5%5%p * * * r