a —+«bŠcã @s0dZddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z ddl mZmZmZmZmZmZmZmZmZmZmZddlmZmZiZe e¡ZiZe e¡Zedd d d d edd d dedddd d eddd ddZ dd„Z!dd„Z"dGdd„Z#dd„Z$dd„Z%dd„Z&dHd d!„Z'd"d#ge d$ƒe d%ƒfd&d'ge d(ƒe d)ƒfd d*d e d+ƒe d,ƒfd d-d e d.ƒe d/ƒfd0d1d e d2ƒe d)ƒfd d3de d4ƒfd d5de d6ƒfd d7de d8ƒfgej(ej)Z*edd9d:d e d;ƒe d<ƒfge*e d=ƒej+d d>d?d@„ƒZ,GdAdB„dBe-ƒZ.dCdD„Z/dEdF„Z0e.gZ1dS)IaB 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). é)Úabsolute_importN)Ú_)ÚnullrevÚshort) ÚarchivalÚcmdutilÚencodingÚerrorÚ filemergeÚ formatterÚ logcmdutilÚpycompatÚ registrarÚscmutilÚutil)ÚprocutilÚ stringutilóextdiffsopts\..*óT)ÚdefaultÚgenericsgui\..*)ró diff-toolss .*\.diffargs$s.*\.gui$sships-with-hg-corec Cs tj |j¡}|dkrd}|dur2d|t|ƒf}tj ||¡}t |¡g}|durv| tdƒt |ƒt|ƒf¡n| tdƒt |ƒ¡|r|j   ddd ¡t j |||d t ||¡|d t|ƒD]N} t | ¡} | d | ¡|durÈtj || ¡} | | | | ¡t | ¡f¡qÈ||fS) zŸ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.rórootNs%s.%ss(making snapshot of %d files from rev %s s3making snapshot of %d files from working directory suis archivemetaFsfiles)ÚmatchÚsubreposs %s )ÚosÚpathÚbasenameÚrootrÚjoinÚmkdirÚnoterÚlenÚuiZ setconfigrÚarchiverZ matchfilesÚsortedrZpconvertÚappendZwjoinÚlstat) r#ÚrepoÚfilesÚnodeÚtmprootÚ listsubreposÚdirnameÚbaseÚ fnsandstatÚfnZwfnÚdest©r2ú3/usr/lib64/python3.9/site-packages/hgext/extdiff.pyÚsnapshotšsH ÿÿÿÿ ú  r4c sN||||||||dœ‰‡‡fdd„} d} ˆs@t | |¡s@|d7}t | | |¡S)N)sparentsparent1óparent2splabel1splabel2schildsclabelrcs6| d¡}| d¡}ˆs$|dkr$|S|t ˆ|¡S)Néér5)ÚgrouprÚ shellquote)rZpreÚkey©Údo3wayÚreplacer2r3Úquoteâs    zformatcmdline..quotesJ(['"]?)([^\s'"$]*)\$(parent2|parent1?|child|plabel1|plabel2|clabel|root)\1s $parent1 $child)ÚreÚsearchÚsub) ÚcmdlineÚ repo_rootr<Úparent1Úplabel1Úparent2Úplabel2ÚchildÚclabelr>Zregexr2r;r3Ú formatcmdlineÉsø  ÿrJc Cs:t |¡}tjt |¡dtjt |¡t tj|¡d}|S)zflike 'procutil.system', but returns the Popen object directly so we don't have to wait on it. T)ÚshellZ close_fdsÚenvÚcwd) rZ shellenvironÚ subprocessÚPopenZ tonativestrZclosefdsZ tonativeenvr Zrapply)ÚcmdÚenvironrMrLÚprocr2r2r3Ú_systembackgroundós  ûrSc Csg}t|ƒ}tt|ƒƒD]°\}}tj ||¡}|| }tj |¡sJtj}d}d}|r~tj | |¡}|| }tj |¡s~tj}tj | |¡}|| }|rLt dƒ||d|f}t dƒ}|  d||f¡}|dkr"|dkr"|  |¡dD] \}}|  d|t  |¡f¡qì|  d||f¡}qÔ|dkr.n|dkr = ``` 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.éNróopts.r›ógui.rTFs .diffargs)rs merge-toolss.gui) rZ expandpathÚ startswithrZfindexer ZfindexternaltoolZconfigr9Z configboolr"r Z shlexsplit) r#rPrZdiffoptsrBr¦r:ÚsectionÚargsr2r2r3Ú_gettooldetailsÝs>           r³cCsr| d¡D]b\}}| d¡s | d¡r(q t|||ƒ\}}}}t|tdd…tdƒ|tjddt|||ƒƒq dS)Nrr®r¯shg %s [OPTION]... [FILE]...Trš)Z configitemsr°r³ÚcommandÚ extdiffoptsrÚCATEGORY_FILE_CONTENTSr )r#rPrrBr¦r2r2r3Úuisetups  û úr·)NN)F)2r¢Z __future__rrr?rr~rNZmercurial.i18nrZmercurial.noderrZ mercurialrrrr r r r r rrrZmercurial.utilsrrZcmdtabler´Z configtableZ configitemZ testedwithr4rJrSrqrur‰r“ZwalkoptsZ subrepooptsrµr¶rŸÚobjectr r³r·Z i18nfunctionsr2r2r2r3Ús®L  4   üýüý /* i! Mûüüèæåÿ ÿýø &"8