
    	^c%_                     |   d dl Z d dlZd dlmZ d dlmZmZ d dlmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ i Z ej        e          Zd Zd Z d Z!d	 Z"d
 Z# ej$        ede#           d Z%d Z& edddg  ed          fddg  ed          fddd ed          fddg  ed          fddd ed          fddg  ed          fddd ed          fddd ed           fdd!d" ed#          fdd$d ed%          fg
e
j'        z    ed&          d"ej(        '          d)d(            Z)dS )*    N)_)hexshort)bundle2cmdutilcommands	discoveryencodingerrorexchange
extensionshg
narrowspecpathutilpycompat	registrarrepairrepoviewrequirementssparseutilwireprototypes)urlutilc                     t          j        t          j        dt                    } | d                             dddt          d          f           | d                             dddt          d          f           | d                             dd	dt          d
          f           dt          j                    vrX| d                             ddg t          d          f           | d                             ddg t          d          f           t          j        t          j        dt                    } | d                             dddt          d          f           t          j        t          j        dt                     dS )z@Wraps user-facing mercurial commands with narrow-aware versions.s   clone          narrowNs%   create a narrow clone of select files   depths0   limit the history fetched by distance from heads
   narrowspecs   read narrowspecs from files   sparse   includes&   specifically fetch this file/directory   excludes2   do not fetch this file/directory, even if includeds   pulls   archive)
r   wrapcommandr   tableclonenarrowcmdappendr   enabledpullnarrowcmdarchivenarrowcmd)entrys    =/usr/lib/python3/dist-packages/hgext/narrow/narrowcommands.pysetupr+   -   s    "8>8^LLE	!HOO	iq!IJJK   
!HOOABB		
   
!HOOS-a0M.N.NOPPP
*,,,,a*b!$M"N"NO	
 	
 	
 	aGHH		
 	
 	
 "8>7MJJE	!HOOABB		
   8>:7GHHHHHr   c                    t          j                  t          j                    }d         }|r[t          j                            t          j                    |          }|	                    t          d          |z             	 t          j        |          }nO# t          $ rB}	t          j        t          d          |t          j        |	j                  fz            d}	~	ww xY wt#          j        ||d          \  }
}}|r!t          j        t          d                    t)          j        |
           t)          j        |           dd<   d                             |
           d	                             |           d         r fd
}t/          j        t2          d|          }|5   | ||g|R i t          j                  cddd           S # 1 swxY w Y   dS )zAWraps clone command, so 'hg clone' first wraps localrepo.clone().r   s   reading narrowspec from '%s'
%   cannot read narrowspecs from '%s': %sNr   s9   cannot specify other files using '%include' in narrowspecTr    r!   c                 d     | ||                                d          rd         |d<   d S d S )Nr   getorigpullopkwargsoptss      r*   pullbundle2extraprepare_widenz5clonenarrowcmd.<locals>.pullbundle2extraprepare_widen|   sG    D   xx!! 2#'>x   2 2r      _pullbundle2extraprepare)r   byteskwargsr   nullcontextmanagerospathjoinr
   getcwdstatusr   readfileIOErrorr   Abort
strtolocalstrerrorr   parseconfigConfigErrorr   validatepatternsextendr   wrappedfunctionr   	strkwargs)r2   uirepoargsr5   wrappedextrapreparenarrowspecfilefilepathfdatainstincludesexcludesprofilesr6   s       `         r*   r$   r$   X   s{   %%D133-(N *7<< 1 1>BB
		!566ABBB	M(++EE 	 	 	+:;;X0??@A  	 (.'9"eY'O'O$(H 	##    	#H---#H--- YZ)))Z)))I 

	2 	2 	2 	2 	2 )813P
 
 
 A AtB@t@@@x'9$'?'?@@A A A A A A A A A A A A A A A A A As*   B   
C,*=C''C,9G%%G),G)c                     t          j                    }t          j        |j        v r fd}t	          j        t          d|          }|5   | ||g|R i cddd           S # 1 swxY w Y   dS )z2Wraps pull command to allow modifying narrow spec.c                 d     | ||                                d          rd         |d<   d S d S )Ndepthr   r/   r1   s      r*   r6   z4pullnarrowcmd.<locals>.pullbundle2extraprepare_widen   sG    D   xx   1#'=x   1 1r   r7   N)r   r9   r   NARROW_REQUIREMENTr   rH   r   )r2   rJ   rK   rL   r5   rM   r6   s       `  r*   r'   r'      s    133&$*;;;	1 	1 	1 	1 	1
 )813P
 
 
 - -tB,t,,,t,,- - - - - - - - - - - - - - - - - -s   
A$$A(+A(c                 4   t           j        |j         v ry|j        \  }}t          |                    dg                     }t          |                    dg                     }t          j        ||||          \  }}}	|r||d<   |r||d<    | ||g|R i |S )z5Wraps archive command to narrow the default includes.includeexclude)r   rX   
narrowpatssetr0   r   restrictpatterns)
r2   rJ   rK   rL   r5   repo_includesrepo_excludesrR   rS   unused_invalids
             r*   r(   r(      s    &$*;;;'+$}txx	2..//txx	2..//-7-Hh}.
 .
*(N  	'&DO 	'&DO4D(4(((4(((r   c                    |j         t          j        j        vr | ||          S t          j        |j                                        vr!t          j        t          d                     | ||           d|d<   j
        \  }}||d<   ||d<   |r||d<   |r||d<   t          j        |j                                        v r7fd                    d	|j                  D             |d
<   |d
         s|d
= d S d S d S )N%   server does not support narrow clonesTr   s   oldincludepatss   oldexcludepats   includepats   excludepatsc                     g | ]@}|                                 j        k    t          |                                           AS  )nodenullidr   .0ctxrK   s     r*   
<listcomp>z+pullbundle2extraprepare.<locals>.<listcomp>   sF     
 
 
xxzzT[(( 

OO(((r      ::%ln   known)rK   r   rX   r   	NARROWCAPremotecapabilitiesr   rA   r   r\   ELLIPSESCAP1r]   common)r2   r3   r4   rZ   r[   rK   s        @r*   pullbundle2extraprepareru      sQ   ;D&d.???tFF###v}'A'A'C'CCCk!DEEFFFDF9GW 'F 'F )!(~ )!(~ "fm&@&@&B&BBB
 
 
 
xx&-88
 
 
x
 h 	! x    CB	! 	!r   r7   c
           	         ! t          j        j        ||           t          j        j        ||                                          !t	          j        !||          }
|                     t          d                     |                     t          d          t          d          t          |
j
                  t          |
j                  z             }g }|5  t          j        |
j
        |
j                  D ]_}|                                 t           fd!|                                         D                       r|                    |           `	 d d d            n# 1 swxY w Y   !                    d|          }t'          j        d          }t+          fd||z
  D                       }|r|                     t          d	                     d
}| j        st          |          |k    r+|D ]'}|                     dt/          |          z             (ng|d |         D ]'}|                     dt/          |          z             (|                     t          d          t          |          |z
  z             |s0t1          j        t          d          t          d                    |                                 5  |r!fd|D             }d                                         |v rQt9                              dd                                         |                    }t;          j        |           ddi}|	r#|                     t          d                     n"|                     t          d                     |                     |d          5  tA          j!        | !|d|	           d d d            n# 1 swxY w Y   g }j"        #                                D ]\  }}}|$                    d          r+|dd         } |          s|                    |           F|$                    d          rq|dd         }tK          tM          j'        |h                    |gz   }d}|D ]%}(                    |          }|sd} n	|dk    r n&|s|                    |           ͉)                                 *                    d           5  +                    ||           |D ]m}|                     t          d!          |z             tY          j-        j.        /                    |                     j"        0                    |           n|                     t          d"                     j1        2                                5  t          j3        d#           t          j4                   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   5                                 d d d            d S # 1 swxY w Y   d S )$N	commonincs,   looking for local changes to affected paths
s
   changesets)topicunittotalc              3   F   K   | ]} |          o |           V  d S Nrg   )rk   fnewmatcholdmatchs     r*   	<genexpr>z_narrow.<locals>.<genexpr>   s:      LLq88A;;2xx{{?LLLLLLr   s   descendants(%ln)s   visiblec              3   L   K   | ]}j                             |          V  d S r}   	changelogrh   )rk   rrK   s     r*   r   z_narrow.<locals>.<genexpr>   sD        #$A     r   sT   The following changeset(s) or their ancestors have local changes not on the remote:

      %s
s*   ...and %d more, use --verbose to list all
s   local changes founds*   use --force-delete-local-changes to ignore)hintc                 D    g | ]}j                             |          S rg   r   )rk   r   unfis     r*   rm   z_narrow.<locals>.<listcomp>  s)    CCC!t~**1--CCCr      .s   (::%n) - %ln + null)   devels   strip-obsmarkersFs%   moving unwanted changesets to backup
s   deleting unwanted changesets
r   )ry   backups   data/   s   meta/iTs   alls	   narrowings   deleting %s
s*   deleting unwanted files from working copy
)assumeclean)6r   matchroot
unfilteredr	   findcommonoutgoingr>   r   makeprogresslenmissingexcluded	itertoolschain	incrementanyfilesr%   revsr   
filterrevslistverboser   r   
StateErroruninterruptiblerh   maxr   cleanconfigoverrider   stripstore	datafiles
startswithsortedr   dirsvisitdir
destroyingtransactionsetnarrowpatsr   
unlinkpathsvfsr<   markremoveddirstateparentchangeupdateworkingcopycopytoworkingcopy	destroyed)"rJ   rK   rq   rx   oldincludesoldexcludesnewincludesnewexcludesforcer   outgoingprogress
localnodesnrevstostrip
hiddenrevsvisibletostripmaxnodestostripurev	overridestodeletetr~   sizefiledirr   rZ   dvisitr   r   r   s"    `                             @@@r*   _narrowr      s    	;DDH	;DDH
 ??D+D&INNNHIIa@AABBB}("##c(*;&<&<<   H
 J	 % %!183DEE 	% 	%A   LLLLLDGMMOOLLLLL %!!!$$$	%% % % % % % % % % % % % % % %
 ))/<<K$T:66J    )4z)A    N  
		6 	
 	
 	
 : 		^,,88# . .		'E!HH,----. $IXI. . .		'E!HH,----II@AA~&&13    	"())DEE   
 
				 : : 	PCCCC{CCCGDz  G++II.T
))&   t$$$8%@I @		!EFFGGGG		!=>>???""9i88 P PRwiOOOOP P P P P P P P P P P P P P P *..00 	' 	'JAq$||H%% '2wx~~ 'OOA&&&h'' '#hhmSE2233se;  A$--a00E  "' ' 'OOA&&&l++ 	3 	3 {K888 * *		!,--1222	q 1 1222
&&q))))IIaFGGHHH++-- 3 3,TtDDDD,T2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	u: : : : : : : : : : : : : : : : : :s   %B E22E69E6C X=?O%X=%O)	)X=,O)	-DX=CX+W:.X:W>>XW>XX=X	X=X	X==YYc                    |                                 t          fdt          j        D                       }|ot          j        v ot          j        v}	fd}
t          j        t          d|
          }fd}|_	        ddi}|d         }| 
                                5  |r{j        }|                                |                                }}|                                5  |                    j        j                   d d d            n# 1 swxY w Y   |	r3|5  t          j        ||           d d d            n# 1 swxY w Y   n+g }|r"fd	                    d
|          D             }|                                5 }|                    d||d|||d                                          }d d d            n# 1 swxY w Y   t          j        d|                                          }|5  j                            |d          5  t5          j        |j        d          }t5          j        ||           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |rB|                                5  |                    ||           d d d            n# 1 swxY w Y                       d          5  j                                        5  	                                 t=          j                   t=          j                    d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nc              3       K   | ]}|v V  	d S r}   rg   )rk   cap	remotecaps     r*   r   z_widen.<locals>.<genexpr>[  s9         y     r   c                 4     | ||           |d<   |d<   d S )Nrd   re   rg   )r2   r3   r4   r   r   s      r*   r6   z-_widen.<locals>.pullbundle2extraprepare_wideng  s/    VV!,~!,~r   r7   c                  4                                     d S r}   )r   )r   r   rK   s   r*   setnewnarrowpatsz _widen.<locals>.setnewnarrowpatss  s    ;44444r   )r   s   all-warningsFr   )headsc                 r    g | ]3}|                                 j        k    |                                 4S rg   )rh   ri   rj   s     r*   rm   z_widen.<locals>.<listcomp>  s@       xxzzT[00 HHJJ000r   rn   s   narrow_widens   03)s   oldincludess   oldexcludess   newincludess   newexcludess	   cgversions   commonheadsro   s   ellipsess   widen)source)ops   widening)!rr   r   r   SUPPORTED_ELLIPSESCAPrs   ELLIPSESCAPr   rH   r   r   r   r   p1p2r   
setparentsri   pullr]   commandexecutorcallcommandresulttransactionmanagerurlrJ   r   r   bundleoperationr   processbundler   r   r   )rJ   rK   rq   rx   r   r   r   r   ellipsesremoteisoldellipsesr6   rM   r   r   rt   dsr   r   knownebundle	trmanagerr   r   s    `    ``               @r*   _widenr   J  s0     ##%%I    $2$H    N 	 	8'94	8&i7 - - - - - - %4-/L 5 5 5 5 5 5 5 -D,e4Iq\F					 1/ 1/ 	8BUUWWbeeggB"" 8 8dk4;7778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 "	;$ : :dF&9999: : : : : : : : : : : : : : : E    #xx&99  
 '')) Q#(3(3(3(3&+(."'%3	 	  &((                !3h

 I  ; ;DG229hGG ; ;,)/   %dFr::::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;  	&"" & &b"%%%& & & & & & & & & & & & & & & k** 	/ 	/DM,F,F,H,H 	/ 	/!!###(...(...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/]1/ 1/ 1/ 1/ 1/ 1/ 1/ 1/ 1/ 1/ 1/ 1/ 1/ 1/ 1/ 1/ 1/ 1/s3  +AM41!DM4D"	"M4%D"	&M4-EM4E	M4E	?M42G
M4G	M4G	-M4I>'4I'I>'I++I>.I+/I>2M4>J	M4J	M4K6M4K	M4	K	
M4"M<=M9MM		MM	MM4M 	 M4#M 	$M44M8;M8   trackedr   
   addincludes   new paths to include   removeincludes   old paths to no longer includes   auto-remove-includesFs.   automatically choose unused includes to remove
   addexcludes   new paths to excludes   import-ruless   import narrowspecs from a file   removeexcludes   old paths to no longer exclude   clears*   whether to replace the existing narrowspecs   force-delete-local-changess/   forces deletion of local changes when narrowing   backupTs$   back up local changes when narrowings   update-working-copys.   update working copy when the store has changeds   [OPTIONS]... [REMOTE])	inferrepohelpcategoryc                   & t          j        |          }t          j        |j        vr!t	          j        t          d                    |d         r!t	          j        t          d                    |                    d          }|r		 t          j	        
                    t          j                    |          }t          j        |          }nO# t          $ rB}t	          j        t          d          |t          j        |j                  fz            d}~ww xY wt'          j        | |d          \  }	}
}|r!t	          j        t          d                    |d	                             |	           |d
                             |
           t-          j        |d	                   }t-          j        |d                   }t-          j        |d
                   }t-          j        |d                   }|d         }|d         }|p|p	|p|p|p|p| }|j        \  }}||z  }||z  }||z  }||z  }|p|}|p|}|r|                     d           |                     d|          }t7          |          D ]H}|                                 |                    dddd           |                    dd|d           It7          |          D ]H}|                                 |                    dddd           |                    dd|d           I|                                 dS |r|                                5  |                                 5  |!                    d          5  |j"        #                                5  t-          j$        |           t-          j%        |           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   dS |s(|s&|s$| &                    t          d                     dS |                                5  |                                 5  tO          j(        |           tS          j*        d|| |          }|\  }}| &                    t          d          tS          j+        |          z             tY          j-        |||          }	 |rAt\          j/        |0                                vr!t	          j1        t          d                    te          j3        ||          }|rute          j4        |||          }| &                    t          d                     tk                      }tm          j7        |j8        |j9                  D ]/} |:                    ||          ;                                           0g }!t7          |          D ]N}"t-          j<        |j=        |"g|          &t}          &fd |D                       s|!?                    |"           O|!r[|!D ]}#| &                    d|#z             | @                    t          d!                    dk    r|:                    |!           d"}n"| &                    t          d#                     |r2||z
  }$||z  }%t          | ||||||$|%|d$         |d%         
  
         |$}|%}|r ||z  }$||z
  }%t          | ||||||$|%           |C                                 n# |C                                 w xY w	 ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   dS )&a  show or change the current narrowspec

    With no argument, shows the current narrowspec entries, one per line. Each
    line will be prefixed with 'I' or 'X' for included or excluded patterns,
    respectively.

    The narrowspec is comprised of expressions to match remote files and/or
    directories that should be pulled into your client.
    The narrowspec has *include* and *exclude* expressions, with excludes always
    trumping includes: that is, if a file matches an exclude expression, it will
    be excluded even if it also matches an include expression.
    Excluding files that were never included has no effect.

    Each included or excluded entry is in the format described by
    'hg help patterns'.

    The options allow you to add or remove included and excluded expressions.

    If --clear is specified, then all previous includes and excludes are DROPPED
    and replaced by the new ones specified to --addinclude and --addexclude.
    If --clear is specified without any further options, the narrowspec will be
    empty and will not match any files.

    If --auto-remove-includes is specified, then those includes that don't match
    any files modified by currently visible local commits (those not shared by
    the remote) will be added to the set of explicitly specified includes to
    remove.

    --import-rules accepts a path to a file containing rules, allowing you to
    add --addinclude, --addexclude rules in bulk. Like the other include and
    exclude switches, the changes are applied immediately.
    sJ   the tracked command is only supported on repositories cloned with --narrowr   s'   the --clear option is not yet supporteds   import_rulesr-   Nr   sJ   including other spec files using '%include' is not supported in narrowspecr   r   r   r   s   auto_remove_includess   update_working_copyr   s   statuss   %s    Is   narrow.included)labels   patr      Xs   narrow.excludedr   s	   narrow-wcs   nothing to widen or narrow
s   comparing with %s
rc   rw   s&   looking for unused includes to remove
c              3   .   K   | ]} |          V  d S r}   rg   )rk   r~   r   s     r*   r   ztrackedcmd.<locals>.<genexpr>}  s+      <<AuuQxx<<<<<<r   s0   remove these unused includes (yn)?$$ &Yes $$ &NoTs   found no unused includes
s   force_delete_local_changesr   )Dr   r8   r   rX   r   
InputErrorr   r0   r:   r;   r<   r
   r=   r   r?   r@   StorageErrorrB   rC   r   rD   rG   r   parsepatternsr\   pager	formatterr   	startitemwriteendwlocklockr   r   r   r   r   r>   r   bailifchangedr   get_unique_pull_pathhidepasswordr   peerr   rp   rr   rA   r	   findcommonincomingr   r]   r   r   r   r   updater   r   r   r   r%   promptchoicer   r   close)'rJ   rK   
remotepathpatsr5   newrulesrO   rP   rQ   includepatsexcludepatsrT   addedincludesremovedincludesaddedexcludesremovedexcludesautoremoveincludesupdate_working_copy	only_showr   r   widening	narrowingfmir   r   branchesrq   rx   r   
localfilesr   suggestedremovalsrZ   sr   r   r   s'                                         @r*   
trackedcmdr%    s	   Z %%D&d.???5 
 
 	
 H~ Nq!KLLMMM xx((H 0	w||HO$5$5x@@HM(++EE 	 	 	$:;;X0??@A  	
 .4-?y.
 .
*[(  	"6    	]"";///]"";///,T--@AAM .t4D/EFFO,T--@AAM .t4D/EFFO5656 			 	 		
 	 I  $K [ M{"O[ M{"O/H0=I  
\\)T**$$ 	C 	CALLNNNHHY4FHGGGHHVWa/AHBBBB$$ 	C 	CALLNNNHHY4FHGGGHHVWa/AHBBBB
q ZZ\\ 	/ 	/499;; 	/ 	/(8(8)
 )
 	/ 	/=%%''	/ 	/ (...(...		/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/
 q 	 %7 
		!344555q	 X Xtyy{{ X Xd###
 (T2zJJX
		!*++g.B3.G.GGHHHtS))M	
 O",F4G4G4I4IIIk!$L"M"MNNN!4T6BBI! @$7&I   		!FGGHHH UU
")98;LMM 7 7A%%d1gmmoo6666$&!%k22 : :G&,TY	;OOE<<<<<<<<< :)00999$ @. / /		'A+....!2     (../@AAA$(	IIa =>>??? *)O;)M967O   *) )M9)O;	 	 	 LLNNNNFLLNNNNNqX X X X X X X X X X X X X X X X X X X X X X X X X X X X X Xt 1s   AC 
D=DD
P	O25O)O	8OOOOOO2OO2"O#O2&P	2O6	6P	9O6	:P		PP] )A>]	(H&\#]	#\99]	=] 	]	] ]	]  ]$']$r}   )*r   r:   mercurial.i18nr   mercurial.noder   r   	mercurialr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   mercurial.utilsr   r#   commandr+   r$   r'   r(   ru   wrapfunctionr   r   
remoteoptsCATEGORY_MAINTENANCEr%  rg   r   r*   <module>r.     s|       				                                                      *      	
)
E
"
"(I (I (IV/A /A /Ad- - -$) ) ) ! ! !> 
 )+B  
w w wtb/ b/ b/L 		mR#:!;!;<	AA&G$H$HI#A?@@		
 
mR#:!;!;<	osAA&G$H$HI	AA&G$H$HIA;<<		
 )A@AA		
 A566		
 "A?@@		
=$J K%L A-U+ + +XY Y YY+ +XY Y Yr   