
    6hf                       S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSKJ	r	J
r
Jr  SSKJr  SSKJrJr  SSKJrJrJrJrJrJrJrJrJrJrJr  SSKJrJr  \R@                  (       a  SS	KJ!r!J"r#  0 r$\RJ                  " \$5      r%0 r&\RN                  " \&5      r'\'" S
SSSS9  \'" S
SSS9  \'" SSSSS9  \'" SSSS9  Sr(            S?S jr)S r*S@S jr+S r,S r-S r.SAS jr/SS/ \" S5      \" S 5      4S!S"/ \" S#5      \" S$5      4SS%S\" S&5      \" S'5      4SS(S\" S)5      \" S*5      4S+S,S\" S-5      \" S$5      4SS.S\" S/5      4SS0S\" S15      4SS2S\" S35      4/\R`                  -   \Rb                  -   r2\%" S
S4S5S\" S65      \" S75      4/\2-   \" S85      \%Rf                  SS99S: 5       r4 " S; S<5      r5S= r6S> r7\5/r8g)BaB  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).
    )annotationsN)ListOptionalTuple)_)nullrevshort)archivalcmdutilencodingerror	filemerge	formatter
logcmdutilpycompat	registrarscmutilutil)procutil
stringutil)	localrepoui   extdiffs   opts\..*    T)defaultgenerics   gui\..*)r   
   diff-toolss   .*\.diffargs$s   .*\.gui$s   ships-with-hg-corec           
        [         R                  R                  UR                  5      nUS:X  a  SnUb  SU[	        U5      4-  n[         R                  R                  XF5      n[         R                  " U5        / nUb2  U R                  [        S5      [        U5      [	        U5      4-  5        O&U R                  [        S5      [        U5      -  5        U(       a  UR                  R                  SSS5        [        R                  " UUUS	[        R                  " X5      US
9  [!        U5       H  n	["        R$                  " U	5      n
U R                  SU
-  5        Ub  M2  [         R                  R                  Xz5      nUR'                  XR)                  U	5      [         R*                  " U5      45        M     Xh4$ )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.r      roots   %s.%ss(   making snapshot of %d files from rev %s
s3   making snapshot of %d files from working directory
s   uis   archivemetaFs   files)matchsubreposs     %s
)ospathbasenamerootr	   joinmkdirnoter   lenr   	setconfigr
   archiver   
matchfilessortedr   pconvertappendwjoinlstat)r   repofilesnodetmprootlistsubreposdirnamebase
fnsandstatfnwfndests               //usr/lib/python3/dist-packages/hgext/extdiff.pysnapshotr>      so    ggtyy)G#~guT{3377<<)DHHTNJ
:;5z5;'(	

 	EF5z	

 %7$$T1!	
 -B--#CGGIO$|ww||D.!!4B$"HI   r   c	           	        ^^ UUUUUUUUS.mUU4S jn	Sn
T(       d   [         R                  " X5      (       d  U S-  n [         R                  " XU 5      $ )N)s   parents   parent1   parent2s   plabel1s   plabel2s   childs   clabelr   c                   > U R                  S5      nU R                  S5      nT(       d  US:X  a  U$ U[        R                  " TU   5      -   $ )N      r@   )groupr   
shellquote)r    prekeydo3wayreplaces      r=   quoteformatcmdline.<locals>.quote   sF    kk!nkk!n#+JX((666r   sJ   (['"]?)([^\s'"$]*)\$(parent2|parent1?|child|plabel1|plabel2|clabel|root)\1s    $parent1 $child)researchsub)cmdline	repo_rootrH   parent1plabel1parent2plabel2childclabelrJ   regexrI   s     `        @r=   formatcmdlinerX      sc     	G7	E 
 "))E33&&66%((r   c           
        [         R                  " U5      n[        R                  " [         R                  " U 5      S[         R
                  [         R                  " U5      [        R                  " [         R                  U5      S9nU$ )z^like 'procutil.system', but returns the Popen object directly
so we don't have to wait on it.
T)shell	close_fdsenvcwd)	r   shellenviron
subprocessPopentonativestrclosefdstonativeenvr   rapply)cmdenvironr]   r\   procs        r=   _systembackgroundrh     sg     


(CS!##  %OOH00#6D Kr   c                   / n[        U5      n[        [        U5      5       GHQ  u  nn[        R                  R                  UU5      nUU-   n[        R                  R                  U5      (       d  [        R                  nSnSnU(       aY  [        R                  R                  U	U5      nUU-   n[        R                  R                  U5      (       d  [        R                  n[        R                  R                  U
U5      nUU-   nU(       a  [        S5      UUS-   U4-  n[        S5      nUR                  SUU4-  5      nUS:X  al  US:X  af  UR                  U5      S    H0  u  nnUR                  SU[        R                  " U5      4-  5        M2     UR                  SUU4-  5      nUS:X  a  Mf  US:X  a  OUS:X  a  GM  US	:X  a    O[        U UUUUUUUUS
9	nU(       d  U(       d>  UR!                  S[        R"                  " U5      U4-  5        UR%                  UUSS9  GM  UR!                  S[        R"                  " U5      U4-  5        ['        UUS9nUR)                  U5        GMT     U(       a4  UR+                  S5         U H  nUR-                  5         M     S S S 5        g g ! , (       d  f       g = f)Nr   s   diff %s (%d of %d)   sZ   [Yns?]$$ &Yes, show diff$$ &No, skip this diff$$ &Skip remaining diffs$$ &? (display help)s   %s %srC   s   %s - %s
r   rB   rH   rQ   rR   rS   rT   rU   rV      running %r in %s
r   r]   
blockedtags    running %r in %s (backgrounded)
)r]   )r)   	enumerater-   r"   r#   r&   isfiler   	osdevnullr   promptchoiceextractchoiceswriter   lowerrX   debugbytestrsystemrh   r/   timeblockedsectionwait)rO   rP   r   guitoolrH   confirmcommonfilesr5   dir1adir1bdir2rev1arev1brev2	waitprocs
totalfilesidx
commonfilepath1alabel1apath1blabel1bpath2label2	difffiles	responsesrct
curcmdlinerg   s                                  r=   _runperfilediffr     s   & I[!J$VK%89ZeZ0u$ww~~f%%''FWW\\%4F 5(G77>>&))!++T:.d"/0a4 I
 (I Iy+A ABAAv1f " 1 1) <Q ?1HNN14E0F!FG !@Iy3I(IJA 1f Avaa"


 ' HH%)9)9*)Ew(OO IIjg*IE
 HH4##J/9: %ZW=DT"Y :\ "":.!		 " /. ..s   J44
Kc                   Sn[         R                  " U S0 5       n[        R                  " UX   R	                  5       X   R	                  5       /UUR
                  R                  XG5      US9  S S S 5        [        R                  " X   U5      n	[        R                  " X   U5      n
UR
                  R                  XI5      nUR
                  R                  XJ5      n[        UUR                  SUU	S S UU
S9	nU R                  S[        R                  " U5      U4-  5        U R                  XdSS9  g! , (       d  f       N= f)	Ns   hg-%h.patchr   )
fntemplater    Frk   rl   rm   rj   )r   nullformatterr   exportrevvfsreljoinmakefilenamerX   r%   rv   r   rw   rx   )r   r2   node1node2r5   matcherrO   templatefmlabel1r   file1file2s                r=   	diffpatchr   ~  s   H		 	 Z	4[__ 12xx'':	
 
5 !!$+x8F!!$+x8FHHW-EHHW-E		G HH"h&6&6w&?%IIJIIgzI:7 
5	4s   AD55
Ec                	   U
R                  S5      nUR                  XEUS9n[        UR                  5      [        UR                  5      [        UR
                  5      pnU(       aP  UR                  XEUS9n[        UR                  5      [        UR                  5      [        UR
                  5      nnnO[        5       [        5       [        5       nnnX-  U-  U-  nUU-  U-  nU(       d  gX-  UU-  U-
  -  n[        XUUR                  5       Xk5      S   nUR                  5       c  SOSUR                  5       -  nU(       a@  UU-  X-  U-
  -  n[        XUUR                  5       Xk5      S   nSUR                  5       -  nOS nSn/ nSnSnUR                  5       b3  [        XUUR                  5       Xk5      S   nSUR                  5       -  nO/[        U5      S:  a  [        XUS Xk5      u  nnOSnUR                  nUn Un!Un"U
R                  S5      (       Gdk  [        U5      S:X  Ga  [        R                  " UR                  5       5      n#[        R                  R!                  UUU#5      nU#U-   n [        R                  R#                  U5      (       d  [$        R&                  nU(       aZ  [        R                  R!                  UUU#5      nU#U-   n![        R                  R#                  U5      (       d  [$        R&                  n[        R                  R!                  UUU#5      nU#U-   n"[)        UUR                  UUU UU!UU"S9	nU R+                  S	[$        R,                  " U5      U4-  5        U R/                  XvS
S9  O[1        UUR                  U U	UU
R                  S5      UU[        R                  R!                  UU5      U(       a   [        R                  R!                  UU5      OS [        R                  R!                  UU5      UUUS9  U H  u  n$n%n[        R2                  " U$5      n&U&[4        R6                     U[4        R6                     :w  d<  U&R8                  UR8                  :w  d"  U&R:                  S-  UR:                  S-  :w  d  M  U R+                  SU%U$4-  5        [        R<                  " U$U%5        M     g)N   subrepos)r6   r   r   s   @%drj      per_filerk   rl   r   rm      confirm)r{   rH   r|   r}   r5   r~   r   r   r   r   r   @   s6   file changed while diffing. Overwriting: %s (src: %s)
)getstatussetmodifiedaddedremovedr>   r4   r   r)   r%   r   	localpathpopr"   r#   r&   rp   r   rq   rX   rv   rw   rx   r   r1   statST_MTIMEst_sizest_modecopyfile)'r   r2   ctx1actx1bctx2r   r5   rO   rH   r{   optsr!   stmod_aadd_arem_astbmod_badd_brem_bmodaddcommondir1a_filesr~   r   dir1b_filesr   r   r9   dir2rootr   r   r   r   r   common_filecopy_fn
working_fncpstats'                                          r=   diffrevsr     s0    xx$H 
d(	;Bbkk*CM3rzz?%Ell4xl@		N ue "eSUCEeu]U"U*Fe^e#F -EEMU#:;KR{EJJL'LQOE99;&CFUYY[,@Eem'>?k5::<

 $J HDyy{&$))+wI!L
"	Vq
 $BfdGNj 99GGF88K   v;!..6KGGLL%=E!E)G77>>%(( **We[A%-ww~~e,,$..E77<<$<D 4'F  II

 	&(*:*:7*CW)MMN
		':	> 	IIHHZ('',,w.28"'',,w.dh-	
" $.R'" 4==!R%66~~+&BJJ,>?HH/2<g1FG MM':.% $.( r   Fc                L   [         R                  " USS5        UR                  S5      nUR                  S5      nUR                  S5      nUR                  S5      n	SU;   n
U	(       a7  [        R                  " XS5      nUR                  5       UR                  5       pOU(       d  U(       aT  [        R                  " X/U/-   S5      n[        R                  " XS5      nU[           n[        R                  " XS5      nO<[        R                  " X5      u  pU(       d  US   R                  5       nO	U[           nU
(       a  UR                  5       [        :X  a  Sn
[        R                  " XU5      nUR                  S	5      (       a  UR                  S
5      (       a  [        R                  " [        S5      5      eUR                  S5      (       a  [        R                  " [        S5      5      eUR!                  5       c  [        R                  " [        S5      5      e["        R$                  " SS9n UR                  S	5      (       a[  ['        XUR!                  5       UR!                  5       XU5      U R)                  [        S5      5        [*        R,                  " U5        $ [/        U UUUUUUUU
UU5      U R)                  [        S5      5        [*        R,                  " U5        $ ! U R)                  [        S5      5        [*        R,                  " U5        f = f)zDo 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
   rev   change   from   tos   $parent2Ns   nowarnF   patchr   s&   --patch cannot be used with --subreposr   s&   --patch cannot be used with --per-files   --patch requires two revisionss   extdiff.)prefixs   cleaning up temp directory
)r   check_at_most_one_argr   r   	revsinglep1p2r   unhidehashlikerevsr   revpairr   r    r   Abortr   r4   r   mkdtempr   r(   shutilrmtreer   )r   r2   rO   patsr   r{   revsfrom_revto_revchangerH   r   r   r   r   r5   s                   r=   dodiffr   3  sn    !!$	:88FDxx HXXe_FXXi FG#F##D$7wwy$'')u	V))*x'
 $$TT:W##D$7 ((4JMMOEME 99;'!FmmD-Gxx88K  ++a IJKK88K  ++a IJKK99;++a ABCCk2G88H%**,		Ww& 	123g! 
 	123g 	123gs   ;A K1 ,K1 12L#   o   options!   pass option to comparison programs   OPT   rr   s   revision (DEPRECATED)s   REVr   s   revision to diff froms   REV1r   s   revision to diff tos   REV2   cr   s   change made by revisions   per-files/   compare each file instead of revision snapshotsr   s3   prompt user before each external program invocationr   s!   compare patches for two revisions   p   programs   comparison program to runs   CMDs   hg extdiff [OPT]... [FILE]...helpcategory	inferrepoc                   [         R                  " U5      nUR                  S5      nUR                  S5      nU(       d  SnU=(       d    S/nSR                  [	        [
        R                  U/U-   5      5      n[        XXbU5      $ )a  use 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,
unless the --per-file option is specified (see below). To pass
additional options to the program, use -o/--option. These will be
passed before the names of the directories or files to compare.

The --from, --to, and --change options work the same way they do for
:hg:`diff`.

The --per-file option runs the external program repeatedly on each
file to diff, instead of once on two directories. By default,
this happens one by one, where the next file diff is open in the
external program only once the previous external program (for the
previous file diff) has exited. If the external program has a
graphical interface, it can open all the file diffs at once instead
of one by one. See :hg:`help -e extdiff` for information about how
to tell Mercurial that a given program has a graphical interface.

The --confirm option will prompt the user before each invocation of
the external program. It is ignored if --per-file isn't specified.
r   r   s   diffs   -Npru    )r   byteskwargsr   r&   mapr   rE   r   )r   r2   r   r   programoptionrO   s          r=   extdiffr     sv    L %Dhhz"GXXi F%H:iiH//'V1CDEG"G400r   c                  $    \ rS rSrSrS rS rSrg)savedcmdi  a  use external program to diff repository (or selected files)

Show differences between revisions for the specified files, using
the following program::

    %(path)s

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.
c                    [         R                  " U5      R                  SS5      nU =R                  S[        R
                  " [         R                  " U5      5      0-  sl        Xl        X0l        X@l	        g )Ns   \\   \r#   )
r   	escapestrrI   __doc__r   sysstruirepr_name_cmdline_isgui)selfre   r#   rO   isguidocpaths         r=   __init__savedcmd.__init__  sW     &&t,44WeD1B1B71K!LMM
r   c           	        U R                   (       a^  [        R                  " 5       (       dD  [        S5      U R                  -  n[        S5      U R                  -  n[
        R                  " XVS9e[        R                  " U5      nSR                  [        [        R                  US   5      5      nU(       a  SU-   n[        XU R                  U-   X4U R                   S9$ )Ns   tool '%s' requires a GUIs2   to override, use: --config diff-tools.%s.gui=False)hintr   r   )r{   )r   r   guir   r   r   r   r   r   r&   r   rE   r   r   )r   r   r2   r   r   msgr  optionss           r=   __call__savedcmd.__call__  s    ;;x||~~/04::=CGH**  ++c--##D)))C 3 3T)_EFWnGdmmg-t4;;
 	
r   )r   r   r   N)__name__
__module____qualname____firstlineno__r   r  r
  __static_attributes__ r   r=   r   r     s    
r   r   c                r   [         R                  " U5      nUR                  S5      (       a  USS nU(       d8  [        R                  " U5      nUc  [
        R                  " X5      =(       d    UnU R                  SSU-   5      n[        R                  " U5      nU(       a  USU-   -  nU R                  SSU-   5      nOU(       a%  Un[        [        R                  " U5      5      S:  nOP[        R                  " U5      nUc  [
        R                  " X5      =(       d    Un[        R                  " U5      nS	nU R                  SSU-   5      nU(       d0  US
-   nS H%  nU R                  Xv5      nU(       d  M  USU-   -  n  O   Uc$  US-   nS H  nU R                  Xv5      nUc  M    O   Uc  S	nXXE4$ )am  
returns following things for a
```
[extdiff]
<cmd> = <path>
```
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.
s   cmd.   Nr      opts.r      gui.rj   Fs	   .diffargs)r   s   merge-toolss   .gui)r   
expandpath
startswithr   findexer   findexternaltoolconfigrE   
configboolr)   r   
shlexsplit)	r   re   r#   diffoptsrO   r  rG   sectionargss	            r=   _gettooldetailsr     s   $ ??4 D
~~g!"g##C(D| 11":Ac99ZC8%%d+th&Gj'C-8G8..w781<H ##C(D| 11":Ac))$/GHj'C-8L 6G99W*Dt4$;&	 7
 }Gm6GMM'/E  7 }g$$r   c           	     .   U R                  S5       H  u  pUR                  S5      (       d  UR                  S5      (       a  M3  [        XU5      u  pp4[        U[        S S  [        S5      U-  [        R                  SS9" [        XX45      5        M     g )Nr   r  r  s   hg %s [OPTION]... [FILE]...Tr   )configitemsr  r   commandextdiffoptsr   CATEGORY_FILE_CONTENTSr   )r   re   r#   rO   r  s        r=   uisetupr&  5  s    ^^J/	>>(##s~~g'>'>$3BT$B!7N,-3 77	
 3g
-	/	 0r   )r   zuimod.uir2   zlocalrepo.localrepositoryr4   zOptional[bytes]r5   bytesr6   boolreturnz7Tuple[bytes, List[Tuple[bytes, bytes, os.stat_result]]])NN)F)9r   
__future__r   r"   rL   r   r   r_   typingr   r   r   mercurial.i18nr   mercurial.noder   r	   	mercurialr
   r   r   r   r   r   r   r   r   r   r   mercurial.utilsr   r   TYPE_CHECKINGr   r   uimodcmdtabler#  configtable
configitem
testedwithr>   rX   rh   r   r   r   r   walkoptssubrepooptsr$  r%  r   r   r   r&  i18nfunctionsr  r   r=   <module>r9     s  JX # 	 	         
 

 


H
%!!+.
 
	  	  #
33
#3 	3
 3 3 =3l')TfRBQhGZ 23fI	
 
vr156&	B	gsA677D	eS!23QwZ@	y#q!;<aiH@A		
 DE		
 
ha DEF14 56 7 @ 		z3"> ?6K  &'//	#1	#1L'
 '
T;%|/ 
r   