
    g.                    F   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZddlm	Z	 ddl
mZmZmZmZmZ ddlmZ ddl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' ddl(m)Z)m*Z*m+Z+ ej,        rdd	lm-Z. ndd
lm/Z.  ej0        d          Z1 ej2        d          Z3e.j4        Z4 ej5        dd           G d d                      Z6d Z7dkdZ8d Z9d Z:d Z;d Z<d Z= G d d          Z>dldZ?dmdZ@d ZAd ZBd ZCd  ZDd! ZEd" ZFdnd#ZGd$ ZHd% ZId& ZJdod(ZKd) ZLd* ZMdkd+ZNdpd.ZOd/ ZPd0 ZQdqd1ZRd2 ZSd3 ZTd4 ZU	 drd7ZV	 drd8Zd9 ZWdkd:ZXd; ZYd< ZZd= Z[ G d> d?          Z\	 	 	 	 	 dsd@Z]dkdAZ^dtdCZ_dD Z`dE ZadF ZbdkdGZcdkdHZddqdIZedkdJZfdK ZgdL ZhdkdMZidN Zj G dO dP          Zk G dQ dR          Zl G dS dT          ZmdU Zn G dV dW          ZodX ZpdY Zq G dZ d[          Zrg d\Zsd]d^gZtd_ Zu e&jv                    ZwdZxdudaZydb ZzdvddZ{de Z|df Z}dg Z~dh Zdi Zdj ZdS )w    N   _)binhexnullrevshortwdirrev)getattr)attr)copiesencodingerrormatchobsoleteobsutilpathutilphasespolicypycompatrequirements
revsetlangsimilarsmartseturlutilvfs)hashutilprocutil
stringutil)
scmwindows)scmposixparsersrevlogTF)slotsreprc                      e Zd ZdZ ej         ej        e                    Z ej         ej        e                    Z	 ej         ej        e                    Z
 ej         ej        e                    Z ej         ej        e                    Z ej         ej        e                    Z ej         ej        e                    Zd Zd ZdS )statuszStruct with a list of files per status.

    The 'deleted', 'unknown' and 'ignored' properties are only
    relevant to the working copy.
    )defaultc              #      K   | j         V  | j        V  | j        V  | j        V  | j        V  | j        V  | j        V  d S N)modifiedaddedremoveddeletedunknownignoredcleanselfs    3/usr/lib/python3/dist-packages/mercurial/scmutil.py__iter__zstatus.__iter__Q   sn      mjllllj    c                 :    dt          d | D                       z  S )NzX<status modified=%s, added=%s, removed=%s, deleted=%s, unknown=%s, ignored=%s, clean=%s>c              3   b   K   | ]*}t          j        t          j        |                    V  +d S r+   )r   sysstrr    pprint).0vs     r5   	<genexpr>z"status.__repr__.<locals>.<genexpr>^   s7      FFA(/*"3A"6"677FFFFFFr7   )tupler3   s    r5   __repr__zstatus.__repr__Z   s-    1FFFFFFFG 	Gr7   N)__name__
__module____qualname____doc__r   ibFactorylistr,   r-   r.   r/   r0   r1   r2   r6   r@    r7   r5   r(   r(   A   s#         tw|t|D11222HDGLDL..///Edgldl400111Gdgldl400111Gdgldl400111Gdgldl400111GDGLDL..///E  G G G G Gr7   r(   c              #     K   t                               |j        |          }|                    t                               | j        |                      t	                      }|j        D ]#}|| j        vr||= |                    |           $t          |                                          D ]\  }}||                    |          fV  |D ]}||	                    ||           fV  dS )zfind subrepos in ctx1 or ctx2N)
dictfromkeyssubstateupdatesetaddsorteditemssubnullsub)ctx1ctx2subpathsmissingsubpathctxs         r5   itersubreposrZ   a   s     
 }}T]D11HOODMM$-66777eeG= ! !$-''!KK   x~~//00 ( (swww'''''''  3 3t||GT22222223 3r7   c                 n   g }|rX|D ]U}||         }|                                 t          j        k    r)|                                s|                    |           V|r4|                     t          d          t          |          z             dS |                     t          d                     dS )zjReport no changes for push/pull, excluded is None or a list of
    nodes excluded from the push/pull.
    s0   no changes found (ignored %d secret changesets)
s   no changes found
N)phaser   secretextinctappendr(   r   len)uirepoexcluded
secretlistnrY   s         r5   nochangesfoundrf   {   s     J % 	% 	%Aq'Cyy{{fm++CKKMM+!!!$$$ ,
		BCC*oo	
 	
 	
 	
 	

 			!)**+++++r7   c           	         d}d}	 	  |            S #  |                                    xY w# t          j        $ r}d}|j        t          j        k    r*t          d          t          j        |j                  z  }nt          d          |j        z  }|                     t          d          |j	        pt          j        |j                  |fz             |j        s"|                     t          d                     Y d}~n]d}~wt          j        $ ri}d}|                     t          d          |j	        pt          j        |j                  t          j        |j                  fz             Y d}~nd}~wt          j        $ r}}t%          |t          j                  rd	}|                     t          d
          |z             |j        r*|                     t          d          |j        z             Y d}~n]d}~wt          j        $ r!}|                     t          d          |j        d         z             |j        d         }t%          |t/          d                    rt          j        |          }||                     d           nt%          |t2                    s|                     d|fz             na|s#|                     t          d                     n<|                     dt          j        t          j        |                    z             Y d}~n.d}~wt          j        $ r0}|                     t          d          |z             Y d}~nd}~wt          j        $ r& |                     t          d                     Y nt          j        $ rN}|j        |j        }|j        |j        }|                     |                                            Y d}~ncd}~wt          j!        $ r}|j"        cY d}~S d}~wtF          $ r}|                     t          d
          t          j        |          z             t          j        |          $                                d         }|d$                                v r#|                     t          d                     n8|d$                                v r"|                     t          d                     Y d}~n^d}~wtJ          j&        j'        $ rD}d}|                     t          d
          t          j        |          z             Y d}~nd}~wtJ          j&        j(        $ r}d}	 |j)        j        d         }n# tT          tV          f$ r
 |j)        }Y nw xY wt%          |tX                    rt          j-        |          }|                     t          d          t          j        |          z             Y d}~nWd}~wt\          t^          f$ r}tK          j0        |d          r#|j        r|j        d         t          j1        k    rnte          |dd          rte          |dd          V|                     t          d          t          j        |j                  t          j        |j                  fz             n>|                     t          d
          t          j        |j                  z             n Y d}~nPd}~wtf          $ r% |                     t          d                      Y nth          $ r}d!}|j5        }Y d}~nd}~ww xY w| 6                    d"d#          r|S |S )$zcall func() with global exception handling

    return func() if no exception happens. otherwise do some error handling
    and return an exit code accordingly. does not handle all exceptions.
       s%   timed out waiting for lock held by %rs   lock held by %rs   abort: %s: %s
s   (lock might be very busy)
Ns   abort: could not lock %s: %s

   s
   abort: %s
s   (%s)
s	   abort: %sr   r       
s    %r
s    empty string
s   
%r
s   abort: file censored %s
s6   abort: working directory revision cannot be specified
s   mpatch bdiffs(   (did you forget to compile extensions?)
s   zlibs"   (is your Python install correct?)
d   s   abort: error: %s
s   argsstrerrorfilenames   abort: %s: '%s'
s   abort: out of memory
      uis   detailed-exit-code)7	tracebackr   LockHelderrno	ETIMEDOUTr   r   bytestrlockerdescr    forcebytestrro   LockUnavailabler   
strtolocalrn   	RepoError
isinstanceRepoLookupErrorhintResponseErrorargstypesysbytesbytesellipsisCensoredNodeErrorWdirUnsupportedErrordetailed_exit_codecoarse_exit_codeformatWorkerErrorstatus_codeImportErrorsplitr   urlerr	httperrorurlerrorreasonAttributeError
IndexErrorstr
unitolocalIOErrorOSErrorsafehasattrEPIPEr   MemoryError
SystemExitcode
configbool)ra   funcr   r   instr   msgms           r5   	callcatchr      s    n%	466M	LLNNN > 8 8 8:((?@@ --FF )**T[8F
 !!yBJ3DMBBFKL	
 	
 	
 { 	8HHQ566777  
 
 

/00	CZ4T]CC#DM22	
 	
 	
 	
 	
 	
 	
 	
 ? / / /dE122 	$!#
>""T)***9 	/HHQy\\DI-... M M M
<49Q</000ilc499%% 	)#C((C;HHUOOOOC'' 	MHHX&'''' 	MHHQ)**++++HHY!1*2Ec2J2J!K!KKLLL" 9 9 9
/004788888888  P P P
MNNOOOOO;      ".!%!8 ,#4
       @ @ @
>""Z%<T%B%BBCCC#D))//11"5%%''''HHQCDDEEEE'--//!!HHQ=>>???;  D D D 
>""Z%<T%B%BBCCCCCCCC; 
M 
M 
M 	![%a(FF
+ 	! 	! 	![FFF	! fc"" 	1(00F
())J,CF,K,KKLLLLLLLLW   T7++			 	!++T:t,, 	tZ..:*++ +DM::"/>>    >**X-@-O-OOPPPP / / /
,--..... % % % !9	% 
}}U122  !!s   	 (+ ] CD] AE<<] A2H] DL55] %M224] )] 7AP  ] P] ] +CT] 9U] 2X5VXV# X"V##A#X]  C.\/] 	] 	]] c                    |dv r$t          j        t          d          |z            dD ]<}||v r6t          j        t          d          t          j        |          z            =	 t          |           d|v rt          t          j        t          d                    # t          $ r Y nw xY w|                                |k    r$t          j        t          d          |z            d S )N)   tip   .   nulls   the name '%s' is reserved)   :    rl      s   %r cannot be used in a name   _s   cannot use an integer as a names)   leading or trailing whitespace in name %r)r   
InputErrorr   r   rv   int
ValueErrorstrip)rb   lblkindcs       r5   checknewlabelr     s    %%%q!=>>DEEE(  88"011H4DQ4G4GG   	C3;; q!CDDEEE   
yy{{c:;;cA
 
 	
 s   );B$ $
B10B1c                     d| v sd| v r6t          j        t          d          t          j        |           z            dS )zFCheck that the filename f is an acceptable filename for a tracked filer   rl   s)   '\n' and '\r' disallowed in filenames: %rN)r   r   r   r   rv   fs    r5   checkfilenamer   '  sN    zzUaZZ<==q!!"
 
 	
  Zr7   c                 ,   t          |           t          |           \  }}|s|rnt          j        |          }|rVd|t	          j        |          fz  }|rt          j        |          |                     t          d          |z             dS dS dS )zECheck if filename f is portable and warn or abort depending on configs   %s: %s   warning: %s
N)
r   checkportabilityalertr   checkwinfilenamer   
shellquoter   r   warnr   )ra   r   abortr   r   s        r5   checkportabler   0  s    !'++KE4 / /#A&& 	/sH$7$:$:;;C ,&s+++GGA&''#-.....		/ 	// /r7   c                    |                      dd          }|                                }t          j        |          }t          j        p|dk    }|p|dk    }|.|s,|s*|dk    s$t          j        t          d          |z            ||fS )z_check if the user's config requests nothing, a warning, or abort for
    non-portable filenamesrq   s   portablefilenamess   abort   warnNs   ignores,   ui.portablefilenames value is invalid ('%s'))	configlowerr    	parseboolr   	iswindowsr   ConfigErrorr   )ra   vallvalbvalr   r   s         r5   r   r   =  s     ))E/
0
0C99;;D$$D2$("2E"47?D|T|U|di.?.?=>>D
 
 	
 $;r7   c                       e Zd Zd Zd ZdS )casecollisionauditorc                     || _         || _        d                    |          }t          t	          j        |                              d                    | _        || _        t                      | _	        d S )Nr   )
_ui_abortjoinrN   r   r   r   _loweredfiles	_dirstate	_newfiles)r4   ra   r   dirstateallfiless        r5   __init__zcasecollisionauditor.__init__M  sa    ::h'' !9!9!?!?!F!FGG! r7   c                 ~   || j         v rd S t          j        |          }|| j        v r`|| j        vrWt          d          |z  }| j        rt          j        |          | j	        
                    t          d          |z             | j                            |           | j                             |           d S )Ns&   possible case-folding collision for %sr   )r   r   r   r   r   r   r   r   
StateErrorr   r   rO   )r4   r   flr   s       r5   __call__zcasecollisionauditor.__call__X  s    F^A###(?(?=>>BC{ ,&s+++HMM!,--3444r"""1r7   N)rA   rB   rC   r   r   rH   r7   r5   r   r   L  s2        	 	 	
 
 
 
 
r7   r   c                    | j         }|rEt          j        | d          }|j        s|sdS t	          |j                  t	          |          f}n|j        sdS }t                      }|j                            |          }|sst          fd|j        |z  D                       }|rNt          j
                    }|D ]}	|                    d|	z             |                                }||j        |<   |S )a  build hash of filtered revisions in the current repoview.

    Multiple caches perform up-to-date validation by checking that the
    tiprev and tipnode stored in the cache file match the current repository.
    However, this is not sufficient for validating repoviews because the set
    of revisions in the view may change without the repository tiprev and
    tipnode changing.

    This function hashes all the revs filtered from the view (and, optionally,
    all obsolete revs) up to maxrev and returns that SHA-1 digest.
    s   obsoleteNc              3   (   K   | ]}|k    |V  d S r+   rH   )r<   rmaxrevs     r5   r>   zfilteredhash.<locals>.<genexpr>  s'      JJAa6kkakkkkJJr7   s   %d;)	changelogr   getrevsfilteredrevshash	frozenset_filteredrevs_hashcachegetrP   r   sha1rM   digest)
rb   r   needobsoleteclobsrevskeyresultrevssrevs
    `        r5   filteredhashr   e  s    
B 	"455 	w 	4tBO,,d7mm< 	4++'++C00F 5JJJJ7!:JJJJJ 	5A ' '#&&&&XXZZF.4B&s+Mr7   c              #      K    fd}t          t          j        dd          |rfd}nd}||rg } ||            t          j         d|          D ].\  }}}|                                 d|v r|V  t          j                            |dd	          }	t          j                            t          j                            |	d                    r|	V  |r|                    d           g |dd<   |rg }
|D ]{}t          j                            ||          } |||          rMt          j                            |          rt          |d|          D ]}|V  f|

                    |           ||
|dd<   0dS )
zyield every hg repository under path, always recursively.
    The recurse flag will only control recursion into repo working dirsc                 "    | j         k    r| d S r+   )ro   )errpaths    r5   
errhandlerzwalkrepos.<locals>.errhandler  s    <4I  r7   samestatNc                     t          j        |          t          fd| D                       }|s|                                | S )Nc              3   0   K   | ]} |          V  d S r+   rH   )r<   
lstdirstatdirstatr   s     r5   r>   z,walkrepos.<locals>.adddir.<locals>.<genexpr>  s/      OO**55OOOOOOr7   )osstatanyr_   )dirlstdirnamer   r   r   s      @r5   adddirzwalkrepos.<locals>.adddir  sZ    gg&&GOOOOOOOOOOE 'g&&&9r7   FT)topdownonerrors   .hgs   patches)r   r   r   walksortr   isdirremoveislink	walkreposr_   )r   	followsym	seen_dirsrecurser   r   rootdirsfilesqrootnewdirsdfnamehgnamer   s   `             @r5   r  r    s          rw
D11H 
X)	 	 	 	 	 	 	y	y$WT4LLL  dE		T>>JJJGLLvz::Ew}}RW\\%8899  F####QQQ 
	G * *T1--6)U++ *w~~e,, *&/tY&G&G ) )F"(LLLL)  q)))DG- r7   c                 n    |                                  }||                                 j        j        S |S )z)Return binary node id for a given basectx)noderb   nodeconstantswdirid)rY   r  s     r5   binnoder    s-    88::D|xxzz'..Kr7   c                 @    |                                  }|t          S |S )z]Return integer for a given basectx that can be used in comparison or
    arithmetic operation)r   r
   )rY   r   s     r5   intrevr    s      ''))C
{Jr7   c                     |                                  }t          |j        t          |           t	          |                     S )zzFormat changectx as '{rev}:{node|formatnode}', which is the default
    template provided by logcmdutil.changesettemplater)rb   formatrevnodera   r  r  )rY   rb   s     r5   formatchangeidr    s1     88::D&++ws||<<<r7   c                 N    | j         rt          }nt          }d| ||          fz  S )zAFormat given revision and node depending on the current verbositys   %d:%s)	debugflagr   r	   )ra   r   r  hexfuncs       r5   r  r    s0    	| sGGDMM***r7   c                    |                     d          r
|dd          }	 |                                 j                            |          }n# t          j        $ r | j                            dd          }|rdd i}| j                            |          5  | 	                    |gd          }g }|D ]S}| j        
                    |          }t          |                               |          r|                    |           Tt          |          dk    r|d         cd d d            cY S 	 d d d            n# 1 swxY w Y    w xY w|d S | j                            |           |S )	N   xr      experimental   revisions.disambiguatewithin)r#  r$  Tuserr   )
startswith
unfilteredr   _partialmatchr   AmbiguousPrefixLookupErrorra   r   configoverrideanyrevsr  r   r_   r`   r   )rb   prefixr  revsetconfigoverridesr   matchesr   s           r5   resolvehexnodeidprefixr1    s       *88@@+   <
 
  	& CDO ''88 & &||VH4|88 - -C>..s33D4yy++F33 -t,,,w<<1$$"1:& & & & & & & & & & %& & & & & & & & & & & & & & & 	%& |NtKs7   ,A A
EBE $E4E E	EE	Ec                     	 t          |          }|dk    r|dd         dk    s|t          |           k    rdS dS # t          $ r Y dS w xY w)z@Checks if the given prefix may be mistaken for a revision number   0r   r   FT)r   r`   r   )rb   r-  is      r5   mayberevnumr5    si    
KK
 dNNvac{d22qCII~~5t   uus   6< 
A
	A
c                     t          |d          } fd}                                 j        } j                            dd          }|rd}||                    d          }|                     |gd          }|||d<   |                              |v rt                    }d}	||                    d	          }	|	st          j
        t          d
          ry|j        }
t          j
        |
d          r|
                                }
t                              |
t          |                    }	|D ]}|	                    |           ||	|d	<   |	8t          |	                              |          }|d|         } ||          S t%          |t          |          dz             D ]p}g }|d|         }|D ]?} |                                         }||d|         k    r|                    |           @t          |          dk    r ||          c S q	  ||                    |                    S # t(          j        $ r t)          j                    w xY w)zFind the shortest unambiguous prefix that matches hexnode.

    If "cache" is not None, it must be a dictionary that can be used for
    caching between calls to this method.
    r   c                 &   j                             dd          rt          |           rd| z   S | S t                    }t	          t          |           t          |          dz             D ] }|d|         } t          |           s| c S !dS )zDisambiguate against revnums.r#  s   revisions.prefixhexnoder"  r   N)ra   r   r5  r   ranger`   )r-  hexnodelengthr  rb   s      r5   disambiguatez-shortesthexnodeidprefix.<locals>.disambiguate  s    7o/IJJ 	4(( f}$d))CKKW)9:: 	 	FWfW%FtV,, 	 	r7   r#  r$  Ns   disambiguationrevsetTr%  s   disambiguationnodetreenodetree
get_cindex)maxr(  r   ra   r   r   r,  r   r   r   r   r#   indexr=  r<  r`   insertshortestr8  r_   r   LookupErrorr~   )rb   r  	minlengthcacher;  r   r.  r   r9  r<  r?  r   r:  r-  r0  r   otherhexnodes   ``               r5   shortesthexnodeidprefixrF  
  s    Iq!!I      
			$BW^^O-LMMF &099455D<<<t<44D 15-.66$<<4$iiGH  99%>?? D#GZ88 D HE'|<< 3 % 0 0 2 2&//s4yyAAH! + + ****(;C78#X..t44i@@ &)#|F+++	3w<<!+;<< 0 0 &) 5 5C#'9==??Lgvg!666|444w<<1$$'<///// %&|BKKi88999 & & &#%%%&s   +I
 
#I-c                 T    	 t          | |           dS # t          j        $ r Y dS w xY w)zChecks if a symbol exists in the repo.

    See revsymbol() for details. Raises error.AmbiguousPrefixLookupError if the
    symbol is an ambiguous nodeid prefix.
    TF)	revsymbolr   r~   )rb   symbols     r5   isrevsymbolrJ  T  sA    $t    uus    ''c                    t          |t                    s(d|t          |          fz  }t          j        |          	 |dv r| |         S 	 t          |          }d|z  |k    rt          t          | j                  }|dk     r||z  }|dk     s||k    r|t          k    rt          | |         S # t          j
        $ r  t          t          t          f$ r Y nw xY wt          |          d| j        j        z  k    r]	 t          |          }| j                            |          }| |         S # t          j        $ r  t$          j        t(          f$ r Y nw xY w	 | j                            | |          }| j                            |          }| |         S # t.          $ r Y nw xY wt1          | |          }|"| j                            |          }| |         S t          j        t5          d          |z            # t          j        $ r | d         cY S t          j
        t          j        t          j        f$ r t;          | |          w xY w)zReturns a context given a single revision symbol (as string).

    This is similar to revsingle(), but accepts only a single revision symbol,
    i.e. things like ".", "tip", "1234", "deadbeef", "my-bookmark" work, but
    not "max(public())".
    sC   symbol (%s of type %s) was not a string, did you mean repo[symbol]?)r   r   r      %dr      Ns   unknown revision '%s')r}   r   r   r   ProgrammingErrorr   r   r`   r   r
   FilteredIndexErrorOverflowErrorr   r  nodelenr   r   FilteredLookupErrorbinasciir   rB  names
singlenodeKeyErrorr1  r~   r   r   FilteredRepoLookupError_filterederror)rb   rI  r   r   lr  r   s          r5   rH  rH  a  s    fe$$ * &V56 	 $S)))3+,,,<	FAqyF""  DN##A1uuQ1uuQ1<<  7N' 	 	 	M:6 	 	 	D	 v;;!d088886{{n((..Cy ,   NK0   	:((v66D.$$T**C9 	 	 	D	 &dF33.$$T**C9#A&>$?$?&$HIII    Dz !% + + +
 T6***+sr   G? A#B0 0&CG? C#G? =0D. .%EG? EG? <F 
F$!G? #F$$6G? $G? ?I6Ic                    | j                             d          r|                                 }t          ||          }|                                rt          j        | ||          }nt          d          |z  }t          d          }t          j	        ||          S t          d          }||| j         fz  }t          j	        |          S )zbuild an exception to be raised about a filtered changeid

    This is extracted in a function to help extensions (eg: evolve) to
    experiment with various message variants.   visibles   hidden revision '%s's'   use --hidden to access hidden revisionsr   s+   filtered revision '%s' (not in '%s' subset))

filternamer'  r(  rH  r   r   _getfilteredreasonr   r   rW  )rb   changeidunfilteredreporY   r   r   s         r5   rX  rX    s    
 !!*-- = **11 <<>> 	8,T8SAACC+,,x7C;<<,St<<<<
:
;
;CHdo&&C(---r7   r   c                     |s|dk    r| |         S t          | |g|          }|s!t          j        t          d                    | |                                         S )Nr   )
localaliass   empty revision set)revranger   r   r   last)rb   revspecr)   rb  rY  s        r5   	revsinglerf    sf     w!||G}yZ888A 9q!677888>r7   c                 B    t          j        |           }|o	|d         dv S )Nr   )s   ranges   rangepres	   rangeposts   rangeall)r   parse)re  trees     r5   	_pairspecrj    s/    G$$D DG    r7   c                 $    |s d          d          fS t           |          }|s!t          j        t          d                    |                                }|                                }||k    rOt          |          dk    r<t           fd|D                       s!t          j        t          d                    ||k    r8t          |          dk    r%t          |d                   s |          d          fS  |          |         fS )Nr   s   empty revision rangerM  c              3   :   K   | ]}t          |g          V  d S r+   )rc  )r<   r   rb   s     r5   r>   zrevpair.<locals>.<genexpr>  s/      66AHTA3''666666r7   s#   empty revision on one side of ranger   r   )	rc  r   r   r   firstrd  r`   allrj  )rb   r   rY  rm  seconds   `    r5   revpairrp    s    &Dz4:%%tA ;q!899:::GGIIEVVXXF 	IINN666666666  q!GHHIII 3t99>>)DG2D2D>E{DJ&&;V$$r7   c                     g }|D ]A}t          |t                    rt          j        d|          }|                    |           B|                     |d|          S )a  Execute 1 to many revsets and return the union.

    This is the preferred mechanism for executing revsets using user-specified
    config options, such as revset aliases.

    The revsets specified by ``specs`` will be executed via a chained ``OR``
    expression. If ``specs`` is empty, an empty result is returned.

    ``specs`` can contain integers, in which case they are assumed to be
    revision numbers.

    It is assumed the revsets are already formatted. If you have arguments
    that need to be expanded in the revset, call ``revsetlang.formatspec()``
    and pass the result as an element of ``specs``.

    Specifying a single revset is allowed.

    Returns a ``smartset.abstractsmartset`` which is a list-like interface over
    integer revisions.
    rL  T)r&  rb  )r}   r   r   
formatspecr_   r,  )rb   specsrb  allspecsspecs        r5   rc  rc    si    * H  dC   	6(55D<<t
<CCCr7         c              #   (   K   	 | V  | |k     r| dz  } )NTrM  rH   )
windowsize	sizelimits     r5   increasingwindowsr{  	  s0      	!!!OJr7   c                 D    sg S | j         fd} |            S )ax  Iterate over files and the revs in a "windowed" way.

    Callers most commonly need to iterate backwards over the history
    in which they are interested. Doing so has awful (quadratic-looking)
    performance, so we use iterators in a "windowed" way.

    We walk a window of revisions in the desired order.  Within the
    window, we first walk forwards to gather data, then in the desired
    order (usually backwards) to display it.

    This function returns an iterator yielding contexts. Before
    yielding each context, the iterator will first call the prepare
    function on each context in the window in forward order.c               3   `  K   t          
          } d}t                      D ]}g }t          |          D ]-}t          | d           }|d} n|                    |           .t          |          D ]"} |          } 	| |                     #|D ]} |          V  |r d S d S )NFT)iterr{  r8  nextr_   rP   )itstopiterationry  nrevsr4  r   rY   changemakefilematcherpreparer   s          r5   iteratezwalkchangerevs.<locals>.iterate#  s      $ZZ+-- 	 	JE:&& " "2tnn;$(MES!!!!e}} 3 3fSkk__S112222 " "fSkk!!!! 	 	r7   )__getitem__)rb   r   r  r  r  r  s    ``` @r5   walkchangerevsr    sS      	F       ( 799r7   c                     |                                 }t          |          dk    r|S | j        j        r|d         | t                   gS |d                                         t          |          dz
  k    rg S |S )zReturn list of meaningful (or all if debug) parentrevs for rev.

    For merges (two non-nullrev revisions) both parents are meaningful.
    Otherwise the first parent revision is considered meaningful if it
    is not the preceding revision.
    r   r   )parentsr`   ra   r  r   r   r  )rb   rY   r  s      r5   meaningfulparentsr  :  st     kkmmG
7||aw +
DM**qz~~6#;;?**	Nr7   c                 r   ||}n^| j                             dd          }|dk    r|}n:t          j        |          }|$t	          j        t          d          |z            |r'|                                 dk    r| j        fdS | j         	                    dd          rd	 S t          j        S )
a  Return a function that produced paths for presenting to the user.

    The returned function takes a repo-relative path and produces a path
    that can be presented in the UI.

    Depending on the value of ui.relative-paths, either a repo-relative or
    cwd-relative path will be produced.

    legacyrelativevalue is the value to use if ui.relative-paths=legacy

    If forcerelativevalue is not None, then that value will be used regardless
    of what ui.relative-paths is set to.
    Nrq   s   relative-pathss   legacys)   ui.relative-paths is not a boolean ('%s')r7   c                      |           S r+   rH   )r   cwdpathtos    r5   <lambda>zgetuipathfn.<locals>.<lambda>l  s    VVAs^^ r7   s   slashc                     | S r+   rH   r   s    r5   r  zgetuipathfn.<locals>.<lambda>n  s     r7   )ra   r   r    r   r   r   r   getcwdr  r   r   	localpath)rb   legacyrelativevalueforcerelativevaluerelativer   r  r  s        @@r5   getuipathfnr  K  s     %%'899Y*HH!+F33H'BCCfL    ,kkmm#:: [F++++++w%** {~r7   c                       fdS )zBCreate a new uipathfn that treats the file as relative to subpath.c                 @     t          j        |                     S r+   )	posixpathr   )r   rX   uipathfns    r5   r  z subdiruipathfn.<locals>.<lambda>u  s    XXinWa8899 r7   rH   )rX   r  s   ``r5   subdiruipathfnr  s  s    999999r7   c                 t    t          | p)|                    d          p|                    d                    S )zChecks if any patterns, including --include and --exclude were given.

    Some commands (e.g. addremove) use this condition for deciding whether to
    print absolute or relative paths.
       include   exclude)boolr   )patsoptss     r5   anypatsr  x  s4     D,,D0D0DEEEr7   c                 4   t           j        st          |           S g }| D ]w}t          j        |d          \  }}|F	 t          j        |          }n# t          j        $ r |g}Y nw xY w|r|                    |           b|	                    |           x|S )ziExpand bare globs when running on windows.
    On posix we assume it already has already been done by sh.N)
r   expandglobsrG   matchmod	_patsplitglobrer   extendr_   )r  retkindpatr   patglobbeds         r5   
expandpatsr    s      Dzz
C 
 
&w55	c< )C..8      %  

7###

7Js   AA'&A'rH      relpathc           	      v    |i }|s|dk    rt          |pg           }t                                           d           fd}||}                     ||                    d          |                    d          ||                    d          |	          }|                                rg }||fS )
zReturn a matcher and the patterns that were used.
    The matcher will warn about bad matches, unless an alternate badfn callback
    is provided.Nr  Tr  c                 |                                     j                            d |           |fz             d S )Ns   %s: %s
)rb   ra   r   )r   r   rY   r  s     r5   badzmatchandpats.<locals>.bad  s9    

;((1++s);;<<<<<r7   r  r     subrepos)listsubreposbadfn)r  r  rb   r   r   always)	rY   r  r  r  r)   r  r  r   r  s	   `       @r5   matchandpatsr    s     | &w*,,$*"%%388::4@@@H= = = = = = }		XXk** 	 	 	A 	xxzz d7Nr7   c                 8    t          | |||||          d         S )z2Return a matcher that will warn about bad matches.r  r   )r  )rY   r  r  r  r)   r  s         r5   r   r     s$     T4'GGGJJr7   c                 (    t          j                    S )z8Return a matcher that will efficiently match everything.)r  r  rb   s    r5   matchallr    s    ?r7   c                 .    t          j        ||          S )zAReturn a matcher that will efficiently match exactly these files.r  )r  exact)rb   r  r  s      r5   
matchfilesr    s    >%u----r7   c                 p   t          j        |          s-t          j        | j        |                                 |          S | |         }t          j        | j        |                                 |g|          fd|D             }t          |          dk    rt          j	        |          |d         S )zWReturn a file name from `pat` pattern suitable for usage in followlines
    logic.
    )rY   c                 *    g | ]} |          |S rH   rH   )r<   r   r   s     r5   
<listcomp>z+parsefollowlinespattern.<locals>.<listcomp>  s&    (((q11Q44((((r7   r   r   )
r  patkindr   	canonpathr  r  r   r`   r   
ParseError)rb   r   r  r   rY   r  r   s         @r5   parsefollowlinespatternr    s     C   !$)T[[]]C@@@3iN49dkkmmcUDDD((((C(((u::??"3'''Qxr7   c                     |                      dd          }|sdS t          j        |j                            |                    S )z`return a vfs suitable to save 'orig' file

    return None if no special directory is configuredrq   s   origbackuppathN)r   r   wvfsr   )ra   rb   origbackuppaths      r5   
getorigvfsr    sC     YYu&788N t749>>.11222r7   c                    t          | |          }||                    |dz             S |                    |          }|                    |          r|                    |          r|                     t          d          |                    |          z             t          t          t          j        |                              D ]f}|                    |          rO|                     t          d          |                    |          z             |                    |            ng|                    |           |                    |          rd|                    |          sO|                     t          d          |                    |          z             |                    |d           |                    |          S )a  customize where working copy backup files (.orig files) are created

    Fetch user defined path from config file: [ui] origbackuppath = <path>
    Fall back to default (filepath with .orig suffix) if not specified

    filepath is repo-relative

    Returns an absolute path
    Ns   .origs   creating directory: %s
s   removing conflicting file: %s
s#   removing conflicting directory: %s
T)forcibly)r  wjoinr   r  r  noter   r   reversedrG   r   finddirsisfileorlinkunlinkmakedirsrmtree)ra   rb   filepathorigvfsorigbackupdirr   s         r5   
backuppathr    s    T""Gzz(X-...OOH--M=='' 
(7>>-+H+H 
(
-..m1L1LLMMM $x0::;;<< 	 	A##A&& <==QOPPPq!!!
 	'''}}X 0w~~h'?'? 0
566h9O9OO	
 	
 	
 	x$///<<!!!r7   c                       e Zd ZdZd Zd ZdS )_containsnodezEproxy __contains__(node) to container.__contains__ which accepts revsc                 @    |j         j        | _        |j        | _        d S r+   )r   r   _torev__contains___revcontains)r4   rb   revcontainers      r5   r   z_containsnode.__init__  s    n((5r7   c                 R    |                      |                     |                    S r+   )r  r  )r4   r  s     r5   r  z_containsnode.__contains__  s"      T!2!2333r7   N)rA   rB   rC   rD   r   r  rH   r7   r5   r  r    s8        OO6 6 64 4 4 4 4r7   r  c           
      ,  -./0 |s|J |s|sdS t          j        |d          sd |D             }n;i }|                                D ]"\  }	}
t          |	t                    s|	f}	|
||	<   #|}|                                 0|i }|                                D ]\  }}|D ]}||v rt          |          dk    r6t          0                    d|                    	                                }nt          |          dk    reg }|D ]}|
                    |           t          0                    d||                    }|r|d         	                                }n| j        }n|d         }|||<   ֌d |                                D             }i }i }|rwi }|                                D ]8\  }}|D ]0}|D ]+}|                    |g                               |           ,19|                    0fd	
           i --fd.|D ]}0|         }t#          .fd|                                D                       }|2t#          0fd||         D                       }t#          ||          }nt#          ||          }|-|<   ||                                k    r*|                    |g                               |           ||                                k     r)|                    |g                               |           |                     d          5 }| j        }g }|                                D ]\  }}|                     |          }|sddlm} | j                            dt7          j        t6          j        |          t=          |          t=          |          fz             |                     d|||          }tA          | |          } |D ]J}!|                    |!|f           |!                    | | |!          D ]}"|                    |"df           K|r|"                    | ||           |                                D ]\  .}#tG          j$        | |.|#           |                                D ]\  .}#tG          j%        | |.|#           | j        &                    dd          }$tO          j(        | tN          j)                  r0j*        j+        //fd}%g }&tY          |                                |%
          D ]P\  }'}(t	          0fd|'D                       t	          0fd|(D                       f})|&                    |)           Q|&rtO          j-        | |&||           ntG          j.        |           r|$rt                      }|/                                D ]}'|0                    |'           |r:ddlm1}* te          || j*        j+        
          }+|*3                    | |||+|           tG          j$        | |tF          j4        |           n@ddlm1}* t          d |D                       },|,r|*5                    | j        | |,||           ddd           dS # 1 swxY w Y   dS )a  do common cleanups when old nodes are replaced by new nodes

    That includes writing obsmarkers or stripping nodes, and moving bookmarks.
    (we might also want to move working directory parent in the future)

    By default, bookmark moves are calculated automatically from 'replacements',
    but 'moves' can be used to override that. Also, 'moves' may include
    additional bookmark moves that should not have associated obsmarkers.

    replacements is {oldnode: [newnode]} or a iterable of nodes if they do not
    have replacements. operation is a string, like "rebase".

    metadata is dictionary containing metadata to be stored in obsmarker if
    obsolescence is enabled.
    Ns   itemsc                     i | ]}|fd S )rH   rH   )r<   re   s     r5   
<dictcomp>z cleanupnodes.<locals>.<dictcomp>.  s    777Qb777r7   r   s   max(%ln)r   s   max((::%n) - %ln)c                     g | ]	}|D ]}|
S rH   rH   r<   nsre   s      r5   r  z cleanupnodes.<locals>.<listcomp>U  s%    AAAbAA1AAAAr7   c                 8    |                                           S r+   )r   )re   unfis    r5   r  zcleanupnodes.<locals>.<lambda>_  s    tAw{{}} r7   )r   c                 x                         |                                 |                                           S r+   )r   r  r\   )rY   	newphasess    r5   r\   zcleanupnodes.<locals>.phaseb  s'    ==SYY[[999r7   c              3   .   K   | ]} |          V  d S r+   rH   )r<   pr\   s     r5   r>   zcleanupnodes.<locals>.<genexpr>g  s+      >>1eeAhh>>>>>>r7   c              3   L   K   | ]}|                                          V  d S r+   )r\   )r<   oldnoder  s     r5   r>   zcleanupnodes.<locals>.<genexpr>i  sD        .5DM''))     r7   s   cleanup)	bookmarkss"   moving bookmarks %r from %s to %s
s*   parents(roots(%ln & (::%n))) - parents(%n)r#  s   cleanup-as-archivedc                 2     | d         d                   S )Nr   rH   )r  torevs    r5   r  zcleanupnodes.<locals>.<lambda>  s    %%1a// r7   c              3   (   K   | ]}|         V  d S r+   rH   )r<   re   r  s     r5   r>   zcleanupnodes.<locals>.<genexpr>  s'      11T!W111111r7   c              3   (   K   | ]}|         V  d S r+   rH   )r<   r   r  s     r5   r>   zcleanupnodes.<locals>.<genexpr>  s'      8L8LQa8L8L8L8L8L8Lr7   )	operationmetadata)repairc              3   $   K   | ]}|D ]}|V  d S r+   rH   r  s      r5   r>   zcleanupnodes.<locals>.<genexpr>  s/      @@R@@1@@@@@@@r7   )backup)6r   r   rQ   r}   r?   r(  r`   r  rN   r  r  rG   nullidvalues
setdefaultr_   r  r>  r  r\   transaction
_bookmarksnodebookmarksrk   r  ra   debugr   rapplymaybebytestrr   r   r  divergent2deleteapplychangesr   retractboundaryadvanceboundaryr   r   	isenabledcreatemarkersoptr   r   rP   createmarkerssupportarchivedkeysrM   r  minbackupbundlearchiveddelayedstrip)1rb   replacementsr  movesr  fixphasetargetphaser  replsr   valueoldnodesnewnodesr  newnodeallreplacedreprootsallnewnodes	toretract	toadvance
precursorsrY   parentphaseoldphasenewphasetrbmarksbmarkchanges	oldbmarksr  
deleterevsdeletenodesnamebnodesmayusearchivedsortfuncrelsr  r   relr  r  tostripr  r\   r  r  s1                                                @@@@r5   cleanupnodesr2    sp   2 *{***   L(33 	77,777 &,,.. 	 	JCc5)) fE#JJ ??D }"."4"4"6"6 	) 	)Hh# ) )e##x==1$$"488K#B#BCCHHJJGG]]a''"$K+ 0 0#**3//// !5wLL E  ."'(--//"&+&qkG!(g)), BA|2244AAAKII C
"."4"4"6"6 	G 	GHh# G G' G GG))'266==gFFFFGG 	4444555		: 	: 	: 	: 	: # 	C 	CGw-C>>>>>>>>>K"    9CG9L     x55{K88!)Ig#))++%%$$Xr2299'BBBBCIIKK''$$Xr2299'BBB			*	%	% N % 	3 	3GW**733I ######GMM6OH$99EELLLL   =	 J (j99K! 3 3##T7O444"33D+tLL 3 3A ''D	222233
  	8b,777%OO-- 	; 	;LE5"4UE::::%OO-- 	; 	;LE5"4UE::::9OPPdH$=>> %	 N&E1111HD 2 2 4 4(CCC ! !A1111b1111158L8L8L8L!8L8L8L3L3LMC     &$)h    #D)) 	n 	%%K"'')) ' '""2&&&& $$$$$$;DN,>???##+{D)   "4V_kJJJJ      @@|@@@@@G ##GT7If $   YN N N N N N N N N N N N N N N N N Ns   )MZ		ZZc                 4   |i }||                     d          }	 t          |                     d          pd          }n/# t          $ r" t          j        t          d                    w xY w|dk     s|dk    r!t          j        t          d                    |dz  }d}| d          }t          |j                  D ]}	t          j	        |	          }
|                     d          s6
                    |	          s!t          |
                                          r|                    |	          }| j                            ||	          }t!          |	|          }	 |                    |
|||          rd	}# t          j        $ r7 | j                            t          d
           ||	          z             Y w xY w
g fd}t          j        |          }t-          | |          \  }}}}}t/          ||z             }|                                }|                    |           t          |          D ]~}| j        j        s
                    |          s[||v rt          d           ||          z  }d}nt          d           ||          z  }d}| j                            ||           t7          | ||z   ||z   ||          }|st9          | ||z   ||           D ]}|                                v r d	S |S )Ns   dry_runs
   similarityr   s   similarity must be a numberrm   s$   similarity must be between 0 and 100      Y@r  r   s#   skipping missing subrepository: %s
c                     |                                  v r                    | |                               |            d S r+   )r  r  r_   )r   r   r   rejecteds     r5   r  zaddremove.<locals>.badfn  s=    		>>EE!SMMMr7   
   adding %s
s   ui.addremove.added   removing %s
s   ui.addremove.removed)label)r   floatr   r   r   r   rP   rL   r  subdirmatcherr  r   r  rR   r  reljoinr  	addremoverB  ra   r(   badmatch_interestingfilesrN   copyrM   verbose_findrenames_markchanges)rb   matcherr-  r  r  dry_run
similarityr  wctxrX   submatchrR   	subprefixsubuipathfnr  r>  r-   r0   r/   r.   	forgotten
unknownsettoprintabsr(   r9  renamesr   r   r6  s                               @@r5   r=  r=    s   |Ahhz""GB488M227a88

 B B Bq!?@@AAABA~~c))q!HIIJJJ%J
C:D$-((  )'15588K   	AGGG$4$4 	HNN<L<L8M8M 	((7##C	))&'::I((;;K==9k4HH C$   =>>hw''(    	 H     
  E**H2Ch3 3/E7GWi Wy())JooGNN7g 0 07? 	0!''#,, 	0j  >**XXc]]:-+,,xx}}</GNN6N///a'G"3Z G  BT7Y.AAA  		>>11 Js   $A ,A0'FAGG        c                 V   t          | |fd          }g t          | |          \  }}}}}| j        j        rt	          ||z             }	|	                                }
|
                    |           t          |
          D ]E}||	v rt          d          |z  }nt          d          |z  }| j        	                    |           Ft          | d          }t          | |||z   ||z   ||          }t          | ||z   ||           D ]}||                                v r dS dS )	z[Assert that files have somehow been operated upon. files are relative to
    the repo root.c                 .                         |           S r+   )r_   )xyr6  s     r5   r  zmarktouched.<locals>.<lambda>  s    8??13E3E r7   r  r7  r8  Tr  r   r   )r  r?  ra   rA  rN   r@  rM   rP   r   r(   r  rB  rC  r  )rb   r  rF  r   r-   r0   r/   r.   rK  rL  rM  rN  r(   r  rO  r   r6  s                   @r5   marktouchedrU    sd    	4&E&E&E&EFFFAH2CD!2L2L/E7GWiw 	#9,--
//##w'?? 	# 	#Cj  >**S0+,,s2GNN6""""
 4T:::Ha'G"3Z G w*GW===  		>>11 1r7   c                    g g g g g f\  }}}}}t          j        | j        d          }| d         }| j        }	|                     |d          }|	                    |t          |j                  ddd          }
|
                                D ]\  }}|		                    |          }|j
        s+|                    |          r|                    |           L|j        s|s|                    |           k|j        r|r|                    |           |j        r|s|                    |           |j        r|                    |           |||||fS )zWalk dirstate with matcher, looking for files that addremove would care
    about.

    This is different from dirstate.status because it doesn't care about
    whether files are modified or clean.T)cachedN)includeexactF)subreposr0   r1   full)r   pathauditorr  r   narrowmatchr  rP   rL   rQ   	get_entryany_trackedcheckr_   r.   r-   )rb   rD  r-   r0   r/   r.   rK  
audit_pathrY   r   walkresultsrN  stentrys                 r5   r?  r?  .  s    35b"b"2D/E7GWi%di===J
t*C}HwT::G--%%    K $$&&  R""3''! 
	z'7'7'<'< 
	NN3- 	 	NN3] 	r 	S!!!!] 	2 	NN3[ 	LL'7GY66r7   c                 L   i }|dk    rt          j        | |||          D ]\  }}}	| j        j        s*|                    |          r|                    |          sB| j                            t          d           ||           ||          |	dz  fz             |||<   |S )z.Find renames from removed files to added ones.r   s7   recording removal of %s as rename to %s (%d%% similar)
rm   )r   findrenamesra   rA  r  r(   r   )
rb   rD  r-   r.   rF  r  rO  oldnewscores
             r5   rB  rB  R  s    GA~~&2%* 
  
 	 	OCe }}S)) }}S))
 ,   x}}hhsmmUS[A	B   GCLLNr7   c                 &   | d         }|                                  5  |                    |           |                    |           |                                D ]\  }}|                    ||           	 ddd           dS # 1 swxY w Y   dS )zmMarks the files in unknown as added, the files in deleted as removed,
    and the files in renames as copied.N)wlockforgetrO   rQ   r@  )rb   r0   r/   rO  rG  rg  rf  s          r5   rC  rC  i  s     :D	    G 	  	 HCIIc3	                                    s   ABB
B
c                 v     t          j                   r fd}|S i t                      fd}|S )Nc                     |         }|                                 }| |v r||          S |                                }| |v r||          S d S r+   )p1copiesp2copies)fnr   rY   rn  ro  rb   s        r5   
getrenamedz getrenamedfn.<locals>.getrenamedw  sQ    s)C||~~HX~~|#||~~HX~~|#4r7   c                    | vrwi | <                        |           }|D ]Z}|                    |          }|                    |                    |                    }|o|d         |          |<   |k    r n[||          v r|          |         S 	 |         |                                          S # t
          j        $ r Y dS w xY w)zlooks up all renames for a file (up to endrev) the first
        time the file is given. It indexes on the changerev and only
        parses the manifest if linkrev != changerev.
        Returns rename info for fn at changerev rev.r   N)filelinkrevrenamedr  
copysourcer   rB  )	rp  r   r   r4  lrru  endrevrcacherb   s	         r5   rq  z getrenamedfn.<locals>.getrenamed  s    
 VF2J2B  ZZ]]**RWWQZZ00!(!7WQZr
2<<E  &*":c?"	9R=++---  	 	 	44	s   B6 6C	C	)	copiesmodusechangesetcentricalgor`   )rb   rx  rq  ry  s   `` @r5   getrenamedfnr|  t  sy    (.. 	 	 	 	 	 F~T      0 r7   c                 b    t          j        |           rd }nt          | |          fd}|S )Nc                 l   |                                  rn|                                                                 }|                    |                                             t	          |                                          S t	          |                                                                           S r+   )ro  rn  r@  rM   rP   rQ   )rY   	allcopiess     r5   copiesfnzgetcopiesfn.<locals>.copiesfn  s    ||~~ 6LLNN//11	  000ioo//000cllnn2244555r7   c                     g }|                                  D ]9} ||                                           }|r|                    ||f           :|S r+   )r  r   r_   )rY   r   rp  renamerq  s       r5   r  zgetcopiesfn.<locals>.copiesfn  s\    Fiikk 0 0#B		22 0MM2v,///Mr7   )rz  r{  r|  )rb   rx  r  rq  s      @r5   getcopiesfnr    s[    (.. 	6 	6 	6 	6 "$//
	 	 	 	 	 Or7   c                    |j                             |          p|}||k    rJ|j                             |          }|j        s|j        s |s|j                             |           dS dS dS |j                             |          j        r||k    r| j        sO|                     t          d          |	                    ||          |	                    ||          fz             |j                             |          j        s|s|
                    |g           dS dS dS |s|                    ||           dS dS )zUpdate the dirstate to reflect the intent of copying src to dst. For
    different reasons it might not end with dst being marked as copied from src.
    sF   %s has not been committed yet, so no copy data will be stored for %s.
N)r   copiedr]  r-   trackedset_trackedquietr   r   r  rO   r@  )	ra   rb   rG  srcdstdryrunr  origsrcrc  s	            r5   dirstatecopyr    s    m""3''.3G
g~~'',,K 	+u} 	+f 	+M%%c*****	+ 	+ 	+ 	+ =""7++1 	$gnn8 9  {{7C00$++c32G2GH	I   =**3//7    #        	$IIgs#####	$ 	$r7   c                   
 | d         }| j         }t          |                                          }|                    |                                | j                   |                    ||          }|j        D ]}|                    |d           |j	        D ]}|                    |d           |j
        D ]}|                    |d           t          j        |||          

                    |           
fd
                                D             }|                                D ]?\  }}	|	|vs||v s|                    |          j	        sd}	|                    |	|           @|                                  dS )zMove the dirstate to newctx and adjust it as necessary.

    A matcher can be provided as an optimization. It is probably a bug to pass
    a matcher that doesn't match all the differences between the parent of the
    working copy and newctx.
    r   )r   T)
p1_trackedFc                 D    i | ]\  }}|                     ||          S rH   )r   )r<   r  r  	oldcopiess      r5   r  z movedirstate.<locals>.<dictcomp>  s-    MMMxsCc9==c**MMMr7   N)r   rJ   r   
setparentsr  r  r(   r,   update_file_p1r-   r.   rz  
pathcopiesrM   rQ   r]  r@  !_quick_access_changeid_invalidate)rb   newctxr   oldctxdsr   r   r   r  r  r  s             @r5   movedirstater    s    $ZF	B"))++FMM&++-----fE**AZ . .
!----W / /
!....Y . .
!---- $VVU;;IVMMMM9??;L;LMMMFLLNN  SfvR\\#5F5F5LC
S**,,,,,r7   c                     t           j        | v r^t                      t                      }}| D ];}|t           j        v r|                    |           &|                    |           <||fS | dfS )zfilters the requirements into two sets:

    wcreq: requirements which should be written in .hg/requires
    storereq: which should be written in .hg/store/requires

    Returns (wcreq, storereq)
    N)requirementsmodSHARESAFE_REQUIREMENTrN   WORKING_DIR_REQUIREMENTSrO   )r   wcstorer   s       r5   filterrequirementsr    sw     ,<<EE355E 	 	AO<<<q						!5yr7   c                 (    t           j        | j        v S )z;returns whether the repository is using treemanifest or not)r  TREEMANIFEST_REQUIREMENTr   r  s    r5   istreemanifestr  
  s    3t7HHHr7   c                    |r|| _         t          | j                   \  }}|t          | j        |           |t          | j        |           dS | j                            dd          r| j                            d           dS dS )zwrites requirements for the repo

    Requirements are written to .hg/requires and .hg/store/requires based
    on whether share-safe mode is enabled and which requirements are wdir
    requirements and which are store requirements
    N   formats   usestore   requires)r   r  writerequiresr   svfsra   r   	tryunlink)rb   r   wcreqstorereqs       r5   writereporequirementsr    s      )(():;;OE8dh&&&di*****			I{	3	3 )	K((((() )r7   c                      | ddd          5 }t          |          D ]}|                    d|z             	 d d d            d S # 1 swxY w Y   d S )Nr     wT)
atomictemp   %s
)rP   write)openerr   fpr   s       r5   r  r  "  s    	Td	3	3	3 "r%% 	" 	"AHHWq[!!!!	"" " " " " " " " " " " " " " " " " "s   +AAAc                   <    e Zd Zd Zd Zd Zd Zed             ZdS )filecachesubentryc                     || _         d | _        d | _        |rTt                              | j                   | _        | j        r | j                                        | _        d S d | _        d S d S r+   )r   	cachestat
_cacheabler  r   	cacheable)r4   r   r   s      r5   r   zfilecachesubentry.__init__)  sp    	 	'.33DI>>DN~ '"&.":":"<"< #'	' 	'r7   c                 z    |                                  r&t                              | j                  | _        d S d S r+   )r  r  r   r   r  r3   s    r5   refreshzfilecachesubentry.refresh7  s9    >> 	?.33DI>>DNNN	? 	?r7   c                 "    | j         | j         S dS NT)r  r3   s    r5   r  zfilecachesubentry.cacheable;  s    ?&?" tr7   c                     |                                  sdS t                              | j                  }|r)| j        "|                                 | _        | j        sdS | j        |k    r	|| _        dS dS )NTF)r  r  r   r   r  r  )r4   newstats     r5   changedzfilecachesubentry.changedB  s    ~~ 	4#((33  	t.%//11DO ? t>W$$$DN45r7   c                 N    	 t          j        |           S # t          $ r Y d S w xY wr+   )r   r  FileNotFoundError)r   s    r5   r   zfilecachesubentry.statW  s9    	>$'''  	 	 	DD	s    
$$N)	rA   rB   rC   r   r  r  r  staticmethodr   rH   r7   r5   r  r  (  sk        ' ' '? ? ?    *   \  r7   r  c                   "    e Zd ZddZd Zd ZdS )filecacheentryTc                 n    g | _         |D ]*}| j                             t          ||                     +d S r+   )_entriesr_   r  )r4   pathsr   r   s       r5   r   zfilecacheentry.__init__`  sJ     	@ 	@DM  !24!>!>????	@ 	@r7   c                 H    | j         D ]}|                                r dS dS )ztrue if any entry has changedTF)r  r  r4   rc  s     r5   r  zfilecacheentry.changede  s4    ] 	 	E}} ttur7   c                 B    | j         D ]}|                                 d S r+   )r  r  r  s     r5   r  zfilecacheentry.refreshl  s,    ] 	 	EMMOOOO	 	r7   N)T)rA   rB   rC   r   r  r  rH   r7   r5   r  r  _  sJ        @ @ @ @
      r7   r  c                   8    e Zd ZdZd Zd Zd Zd Zd	dZd Z	dS )
	filecachea  A property like decorator that tracks files under .hg/ for updates.

    On first access, the files defined as arguments are stat()ed and the
    results cached. The decorated function is called. The results are stashed
    away in a ``_filecache`` dict on the object whose method is decorated.

    On subsequent access, the cached result is used as it is set to the
    instance dictionary.

    On external property set/delete operations, the caller must update the
    corresponding _filecache entry appropriately. Use __class__.<attr>.set()
    instead of directly setting <attr>.

    When using the property API, the cached data is always used if available.
    No stat() is performed to check if the file has changed.

    Others can muck about with the state of the ``_filecache`` dict. e.g. they
    can populate an entry before the property's getter is called. In this case,
    entries in ``_filecache`` will be used during property operations,
    if available. If the underlying file changes, it is up to external callers
    to reflect this by e.g. calling ``delattr(obj, attr)`` to remove the cached
    method result as well as possibly calling ``del obj._filecache[attr]`` to
    remove the ``filecacheentry``.
    c                     || _         d S r+   r  )r4   r  s     r5   r   zfilecache.__init__  s    


r7   c                 .      fd j         D             S )Nc                 <    g | ]}                     |          S rH   )r   )r<   r   objr4   s     r5   r  z+filecache.tracked_paths.<locals>.<listcomp>  s'    <<<		#t$$<<<r7   r  )r4   r  s   ``r5   tracked_pathszfilecache.tracked_paths  s#    <<<<<<<<<r7   c                     t           )a  Used to compute the runtime path of a cached file.

        Users should subclass filecache and provide their own version of this
        function to call the appropriate join function on 'obj' (an instance
        of the class that its member function was decorated).
        )NotImplementedError)r4   r  r  s      r5   r   zfilecache.join  s
     "!r7   c                 h    || _         |j        | _        t          j        | j                  | _        | S r+   )r   rA   snamer   r   r*  )r4   r   s     r5   r   zfilecache.__call__  s+    	]
%dj11	r7   Nc                    || S | j         |j        vsJ |j                            | j                  }|r/|                                r|                     |          |_        nN|                     |          }t          |d          }|                     |          |_        ||j        | j        <   |j        |j        | j         <   |j        S r  )
r  __dict__
_filecacher   r*  r  r   r  r  r  )r4   r  r   rc  r  s        r5   __get__zfilecache.__get__  s    ;Kz----""49-- 	.}} + IIcNN	&&s++E #5$//E		#EI(-CN49%#(9TZ yr7   c                     | j         |j        vr5|                     |          }t          |d          }||j        | j         <   n|j        | j                  }||_        ||j        | j        <   d S )NF)r*  r  r  r  r  r  r  )r4   r  r  r  ces        r5   rN   zfilecache.set  so    9CN** &&s++Eu--B(*CN49%%	*B#(TZ   r7   r+   )
rA   rB   rC   rD   r   r  r   r   r  rN   rH   r7   r5   r  r  q  s}         2  = = =" " "     8) ) ) ) )r7   r  c           
         | j                             d|          }|s$t          j        t	          d          |z            i }dx}}	 |                    d          ri|dd         }t          j        t          j	        |          ddt          j
        t          j        t          j	        | j                            }|j        }nt          j        | j         |          }|D ]}d	|v r,|                                                    d	d
          \  }}	n|                                d}	}t%          j        |          }	 t%          j        |	          |t)          | |                                          <   # t          j        t          j        t          j        f$ r Y w xY w	 |r&	 |                                 n# t4          $ r Y nw xY w|r|                                 nD# |r&	 |                                 n# t4          $ r Y nw xY w|r|                                 w w xY w|rH|j        dk    r=t          j        t	          d          |t          j        |j                  fz            |S )ak  Gather a map of rev -> value dict from the specified source

    A source spec is treated as a URL, with a special case shell: type
    for parsing the output from a shell command.

    The data is parsed as a series of newline-separated records where
    each record is a revision specifier optionally followed by a space
    and a freeform string value. If the revision is known locally, it
    is converted to a rev, otherwise the record is skipped.

    Note that both key and value are treated as UTF-8 and converted to
    the local encoding. This allows uniformity between local and
    remote data sources.
    s   extdatas   unknown extdata source '%s'Ns   shell:   Trh   )shellbufsize	close_fdsstdoutr      r   r7   r   s   extdata command '%s' failed: %s)ra   r   r   Abortr   r'  
subprocessPopenr   tonativestrclosefdsPIPEr  r  r   openr   r   r   tolocalrf  r   rB  r~   r   communicater   close
returncodeexplainexit)
rb   sourceru  datar  proccmdrY  kr=   s
             r5   extdatasourcer    s     7>>*f--D Fk!:;;fDEEEDC$$??9%% 	*qrr(C#$S))"+!(33  D +CC (47D))C 
	 
	AqyywwyytQ//11wwyy#1 ##A191A!1D1DYtQ''++--..%u'<e>NO   
	  	  """"      	IIKKK  	  """"      	IIKKKK	 
1$$k011H(99:;
 
 	

 Ksg   	C6G$  7E87G$ 8&F!G$  F!!G$ (F= =
G
	G
$H%(G=<H%=
H
H%	H

H%c                   >    e Zd ZddZd Zd ZddZddZd	 Zd
 Z	dS )progressr7   Nc                     || _         d| _        || _        || _        || _        |                    dd          | _        || _        d S )Nr   s   progresss   debug)ra   postopicunittotalr   r  
_updatebar)r4   ra   	updatebarr  r  r  s         r5   r   zprogress.__init__  sE    
	
]];99
#r7   c                     | S r+   rH   r3   s    r5   	__enter__zprogress.__enter__  s    r7   c                 .    |                                   d S r+   )complete)r4   exc_type	exc_valueexc_tbs       r5   __exit__zprogress.__exit__  s    r7   c                     |J |r|| _         || _        |                     | j        | j        || j        | j                    | j        r|                     |           d S d S r+   )r  r  r  r  r  r  _printdebug)r4   r  itemr  s       r5   rM   zprogress.update  sq     	DJ
DHdDItzJJJ: 	#T"""""	# 	#r7   r   c                 D    |                      | j        |z   ||           d S r+   )rM   r  )r4   stepr
  r  s       r5   	incrementzprogress.increment'  s$    DHtOT511111r7   c                     d | _         d| _        d | _        |                     | j        | j         d| j        | j                   d S )Nr7   )r  r  r  r  r  r3   s    r5   r  zprogress.complete*  s?    	

DHc49djIIIIIr7   c           	      *   d}| j         r
d| j         z   }|rd|z   }| j        rFd| j        z  | j        z  }| j                            d| j        || j        | j        ||fz             d S | j                            d| j        || j        |fz             d S )Nr7   r  r4  s   %s:%s %d/%d%s (%4.2f%%)
s   %s:%s %d%s
)r  r  r  ra   r  r  )r4   r
  r  pcts       r5   r	  zprogress._printdebug0  s    9 	$$)#D 	$;D: 	P$("TZ/CGMM,:tTXtz4EF    
 GMM/TZtx,NNOOOOOr7   )r7   N)r   r7   N)
rA   rB   rC   r   r  r  rM   r  r  r	  rH   r7   r5   r  r    s        $ $ $ $    # # # #2 2 2 2J J JP P P P Pr7   r  c                 Z    |                      dd          p|                      dd          S )zDhelper function to know if a repo should be created as general deltar     generaldeltas   usegeneraldeltar   ra   s    r5   gdinitconfigr  A  s5     ==O44 %9 9 r7   c                 .    |                      dd          S )z=helper function to know if incoming delta should be optimisedr  r  r  r  s    r5   gddeltaconfigr  I  s     ==O444r7   c                   .    e Zd ZdZdZddZd	dZddZdS )
simplekeyvaluefilezA simple file with key=value lines

    Keys must be alphanumerics and start with a letter, values must not
    contain '
' characterss   __firstlineNc                 "    || _         || _        d S r+   )r   r   )r4   r   r   r  s       r5   r   zsimplekeyvaluefile.__init__W  s    			r7   Fc                    | j                             | j                  }i }|r@|s#t          d          }t	          j        |          |d         dd         || j        <   |d= 	 t          d |D                       }| j        |v r+t          d          }t	          j        || j        z            |                    |           n8# t          $ r+}t	          j        t          j        |                    d}~ww xY w|S )zRead the contents of a simple key-value file

        'firstlinenonkeyval' indicates whether the first line of file should
        be treated as a key-value pair or reuturned fully under the
        __firstline key.s   empty simplekeyvalue filer   Nrh   c              3   z   K   | ]6}|                                 |d d                             dd          V  7d S )Nrh      =r   )r   r   )r<   lines     r5   r>   z*simplekeyvaluefile.read.<locals>.<genexpr>o  sY        -1djjllSbS	a((     r7   s   %r can't be used as a key)r   	readlinesr   r   r   CorruptedStatefirstlinekeyrJ   rM   r   r    ry   )r4   firstlinenonkeyvallinesr  e
updatedicts         r5   readzsimplekeyvaluefile.read[  s2    ""49-- 	 .233*1---#(8CRC=Ad a	C   5:    J  J..233*1t/@+@AAAHHZ     	C 	C 	C&z'>q'A'ABBB	Cs   %A"C 
C=&C88C=c                    g }||                     d|z             |                                D ]\  }}|| j        k    rd| j        z  }t          j        |          |dd                                         sd}t          j        |          |                                sd}t          j        |          d|v rd	}t          j        |          |                     d
||fz             |                     | j        dd          5 }|	                    d
                    |                     ddd           dS # 1 swxY w Y   dS )a   Write key=>value mapping to a file
        data is a dict. Keys must be alphanumerical and start with a letter.
        Values must not contain newline characters.

        If 'firstline' is not None, it is written to file before
        everything else, as it is, not in a key=value formNr  s   key name '%s' is reservedr   r   s1   keys must start with a letter in a key-value files+   invalid key name in a simple key-value filerl   s(   invalid value in a simple key-value files   %s=%s
s   wbT)moder  r7   )r_   rQ   r!  r   rN  isalphaisalnumr   r   r  r   )r4   r  	firstliner#  r  r=   r$  r  s           r5   r  zsimplekeyvaluefile.writez  s     LL9,---JJLL 	. 	.DAqD%%%043DD,Q///QqS6>>## 0H,Q///99;; 0B,Q///zz?,Q///LLq!f,----XXdieX== 	&HHSXXe__%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s   )EE
Er+   F)rA   rB   rC   rD   r!  r   r&  r  rH   r7   r5   r  r  O  sa         
 "L      >& & & & & &r7   r  )s   debugobsolete   pulls   pushs   serve   unbundler-  r.  c                 P      fdfd|D             }t           |           dS )a`  Invokes the registered file prefetch functions, allowing extensions to
    ensure the corresponding files are available locally, before the command
    uses them.

    Args:
      revmatches: a list of (revision, match) tuples to indicate the files to
      fetch at each revision. If any of the match elements is None, it matches
      all files.
    c                     | r2t          | t          j                  sJ t          j        | d           S t	                    S )Nc                     d S r+   rH   )rp  r   s     r5   r  z1prefetchfiles.<locals>._matcher.<locals>.<lambda>  s     r7   )r}   r  basematcherr>  r  )r   rb   s    r5   _matcherzprefetchfiles.<locals>._matcher  sI     	"a!566666 $Q(<(<===D>>!r7   c                 0    g | ]\  }}| |          fS rH   rH   )r<   r   r   r3  s      r5   r  z!prefetchfiles.<locals>.<listcomp>  s*    KKKec88E??+KKKr7   N)fileprefetchhooks)rb   
revmatchesrevbadmatchesr3  s   `  @r5   prefetchfilesr8    sO    " " " " " LKKK
KKKMdM*****r7   r7   c                     fd}g  fd}|fd            } |t                     r|fd            }t          j         t          j                  r> j                            dd          r#g dfd            |fd	            } |t                    r|d
             }	|fd            }
dS dS )zregister a callback to issue a summary after the transaction is closed

    If as_validator is true, then the callbacks are registered as transaction
    validators instead
    c                 :    t          fd| D                       S )Nc              3   B   K   | ]}                     |          V  d S r+   )r'  )r<   r  txnnames     r5   r>   z;registersummarycallback.<locals>.txmatch.<locals>.<genexpr>  s1      DD&7%%f--DDDDDDr7   )r   )sourcesr<  s    r5   txmatchz(registersummarycallback.<locals>.txmatch  s&    DDDDGDDDDDDr7   c                 "    j         t          j                                                   fd}dt	                    z  }r                    ||           n                    ||                               |           |S )zdecorator for report callbacks.c                 j                 }r|J |                               } ||            d S r+   )filtered)r$  rb   r]  r   reporefs     r5   wrappedz?registersummarycallback.<locals>.reportsummary.<locals>.wrapped  sF    799D 1'''}}Z00DrNNNNNr7   s   %02i-txnreport)r]  weakrefrefr(  r`   addvalidatoraddpostcloser_   )	r   rC  newcatr]  rB  as_validator
categoriesotrrb   s	   `  @@r5   reportsummaryz.registersummarycallback.<locals>.reportsummary  s     _
+doo//00	 	 	 	 	 	 	 #S__4 	.VW----VW---&!!!r7   c                    |j                             dd          }|j                             dd          }|j                             dd          }|j                             dd          }|s|s|r]d}|rt          d          |z  }t          d          }rt          d	          }| J | j                            |||||fz             d S d S )
Ns   changegroup-count-changesetsr   s   changegroup-count-revisionss   changegroup-count-filess   changegroup-count-headsr7   s    (%+d heads)s2   added %d changesets with %d changes to %d files%s
s3   adding %d changesets with %d changes to %d files%s
)changesr   r   ra   r(   )	rb   r$  cgchangesetscgrevisionscgfilescgheadshtextr   rI  s	           r5   reportchangegroupz2registersummarycallback.<locals>.reportchangegroup  s    z~~&EqIIjnn%CQGG*..!;Q??*..!;Q?? 	N; 	N' 	NE 5/**W4JKKC QOPP###GNN3,We!LLMMMMM	N 	Nr7   c                 v   t          j        | |          }t          |j                            dd                    }|r*| j                            t          d          |z             |rLt          d          }rt          d          }| j                            |t          |          z             d S d S )Ns
   obsmarkersrH   s   %i new obsolescence markers
s   obsoleted %i changesets
s   obsoleting %i changesets
)r   getobsoletedr`   rN  r   ra   r(   r   )rb   r$  	obsoleted
newmarkersr   rI  s        r5   reportobsoletedz0registersummarycallback.<locals>.reportobsoleted  s    ,T266IRZ^^M2>>??J Qq!ABBZOPPP 5455 ;9::CsS^^344444	5 5r7   r#  s   evolution.report-instabilities))   orphanrZ  )s   phase-divergents   phasedivergent)s   content-divergents   contentdivergentc           	          | j         j        }i }D ]:\  }}t          t          t	          j        | |                    |z
            ||<   ;|S r+   )r   r   r`   rN   r   r   )rb   rA  countsinstabilityr.  instabilitytypess        r5   getinstabilitycountsz5registersummarycallback.<locals>.getinstabilitycounts  sa    ~2HF'7  #V&)(v6677(B' '{## Mr7   c                      |           }D ]B\  }}||         	|         z
  }t          ||          }|r| j                            |           Cd S r+   )getinstabilitymessagera   r   )
rb   r$  newinstabilitycountsr]  r.  deltar   r_  r^  oldinstabilitycountss
          r5   reportnewinstabilitiesz7registersummarycallback.<locals>.reportnewinstabilities  sz    #7#7#=#= '7 & &#V(5*;78  ,E;?? &GLL%%%& &r7   c                    |j                             dt          |                     }|                                 }|t          |          k    rdS t	          j        | |          }|r| |                                         | |                                         }}||k    r|}nd||fz  }t          |                     d|                    }t          |                     d|                    }	|s|	st          d          |z  }
nd|r|	rt          d          }
|
|||	fz  }
nH|rt          d	          }
|
||fz  }
n/|	rt          d
          }
|
||	fz  }
nd}t          j        |          | j                            |
           |j                             dd          }|                    d||          }| j        fd|D             }|r.d}
| j                            |
t          |          z             dS dS )z3Report the range of new revisions pulled/unbundled.   origrepolenN)starts   %s:%ss   %ld and draft()s   %ld and secret()s   new changesets %s
s*   new changesets %s (%d drafts, %d secrets)
s   new changesets %s (%d drafts)
s   new changesets %s (%d secrets)
s   entered unreachable conditions   revduplicatesrH   s   (%d: + %ld) and obsolete()c                     g | ]}|v|	S rH   rH   )r<   r   r   s     r5   r  z@registersummarycallback.<locals>.reportnewcs.<locals>.<listcomp>U  s    ???!1B;;A;;;r7   s*   (%d other changesets obsolete on arrival)
)rN  r   r`   r(  r   spansetr  r>  r   r   r   rN  ra   r(   r   )rb   r$  origrepolenr  r   minrevr   rc  draftr]   r   errormsg
duplicatesobsaddedextinctaddedr   s                  @r5   reportnewcsz,registersummarycallback.<locals>.reportnewcs,  sA    *..TCCK??$$Dc$ii'' #D<<<D $!%dhhjj!14

3CV##%HH'66*::HDII&8$??@@TYY':DAABB ; ;233h>CC ;v ;JKKCHeV44CC ;>??CHe,,CC ;?@@CHf--CC?H0:::s### (8"==Jyy-{J H B????x???L 8 EsS%6%66777778 8r7   c                    |j                             dt          |                     g }|j                             dg           D ]:\  }\  }}|t          j        k    r|                    fd|D                        ;|sdS t          d          }rt          d          }| j                            |t          |          z             dS )zfReport statistics of phase changes for changesets pre-existing
            pull/unbundle.
            rg  s   phasesc              3   (   K   | ]}|k     |V  d S r+   rH   )r<   r   rk  s     r5   r>   zFregistersummarycallback.<locals>.reportphasechanges.<locals>.<genexpr>g  s-       J Jk8I8I8I8I8I8I J Jr7   Ns   %d local changesets published
s&   %d local changesets will be published
)	rN  r   r`   r   publicr  r   ra   r(   )	rb   r$  	publishedr   rf  rg  r   rk  rI  s	          @r5   reportphasechangesz3registersummarycallback.<locals>.reportphasechanges]  s    
 *..TCCKI$&JNN9b$A$A K K jsC&-''   J J J J J J JJJJJ 677C DBCCGNN3Y/00000r7   N)_reportobsoletedsourcer   r  r	  ra   r   _reportnewcssource)rb   rK  r<  rI  r>  rL  rT  rY  re  rr  rw  rJ  r_  r^  rd  s   ````       @@@@r5   registersummarycallbackrz    s   E E E E E J       2 N N N N ]N w%&& 5			5 		5 		5 		5 
		5 h'   &
'

:  &

 
 
	 	 	 	 	  43D99			& 		& 		& 		& 		& 		& 
		& w!"" C1	.	8 .	8 
.	8` 
	1 	1 	1 	1 
	1 	1 	1iC1 C1r7   c                 :    | dk    rt          d          | |fz  S dS )zfunction to return the message to show warning about new instabilities

    exists as a separate function so that extension can wrap to show more
    information like how to fix instabilitiesr   s   %i new %s changesets
Nr   )rc  r]  s     r5   ra  ra  p  s-    
 qyy*++uk.BBB yr7      c                    t          |          |k    s| j        j        rd                    d |D                       S d                    d |d |         D                       }t	          d          |t          |          |z
  fz  S )Nr  c              3   4   K   | ]}t          |          V  d S r+   r	   r<   hs     r5   r>   z nodesummaries.<locals>.<genexpr>{  s(      11aq111111r7   c              3   4   K   | ]}t          |          V  d S r+   r  r  s     r5   r>   z nodesummaries.<locals>.<genexpr>|  s(      <<1eAhh<<<<<<r7   s   %s and %d others)r`   ra   rA  r   r   )rb   r,  maxnumnodesrm  s       r5   nodesummariesr  y  s    
5zz[  DGO yy115111111II<<l{l(;<<<<<E !!UCJJ,D$EEEr7   c                 x   |dv rdS |                      |          }|                                }|D ]}|                    ||          }t          |          dk    r[t	          d          }	|	|z  }	t	          d          }
|
t          |          t          | |          fz  }
t          j        |	|
          dS )z-check that no named branch has multiple heads)s   strips   repairN)closedr   s'   rejecting multiple heads on branch "%s"s   %d heads: %sr\  )rA  	branchmapbranchheadsr`   r   r  r   r  )rb   r$  rx   accountclosedr]  visiblebmr*  headsr   r   s              r5   enforcesingleheadr    s    $$$mmJ''G					B . .tM::u::>>>??C4KC_%%DSZZtU!;!;<<D+c---- . .r7   c                     | S )zAllow extensions to wrap the sink returned by convcmd.convertsink()
    before it is used, whether or not the convert extension was formally loaded.
    rH   )sinks    r5   wrapconvertsinkr    s	     Kr7   c                 Z   |s| S | j         r| j                            dd          s| S | j         dvr| S t                      }|D ]T}	 t	          j        |          }n# t          j        $ r Y )w xY w|                    t	          j	        |                     U|s| S t          | |          }|s| S |dk    r_|                                 d                    fd|D                       }| j                            t          d          |z             |                     d|          S )	a(  parse the user specs and unhide changesets whose hash or revision number
    is passed.

    hiddentype can be: 1) 'warn': warn while unhiding changesets
                       2) 'nowarn': don't warn while unhiding changesets

    returns a repo object with the required changesets unhidden
    r#  s   directaccess)r[     visible-hiddenr   s   , c                 D    g | ]}t          j        |                   S rH   )r   rv   )r<   rY  r  s     r5   r  z&unhidehashlikerevs.<locals>.<listcomp>  s(    EEE1X-d1g66EEEr7   s=   warning: accessing hidden changesets for write operation: %s
r  )r]  ra   r   rN   r   rh  r   r  rM   gethashlikesymbols_getrevsfromsymbolsr(  r   r   r   rA  )	rb   rs  
hiddentypesymbolsru  ri  r   revstrr  s	           @r5   unhidehashlikerevsr    s|     ? $'"4"4# #  ===eeG < <	#D))DD 	 	 	H	 	z4T::;;;; tW--D W  EEEEEEEFF#  		
 	
 	
 ==*D111s   AA/.A/c                    t                      }|                                 }|j        }| j        }t          |          }| j                            dd          }|D ]}	 t          |          }	|	|k    r|s|	|vr|                    |	           5n# t          $ r Y nw xY w	 t          ||          }n## t          j        t          j        f$ r d}Y nw xY w|.|                    |          }
|
|vr|                    |
           |S )zkparse the list of symbols and returns a set of revision numbers of hidden
    changesets present in symbolsr#  s   directaccess.revnumsN)rN   r(  r   r`   ra   r   r   rO   r   r1  r   rB  r   r   )rb   r  r   r  unficlr   tiprevallowrevnumsr   re   r   s              r5   r  r    s;    55D??D^F	B[[F7%%o7NOOL  
	AAF{{# {{   	 	 	D		&tQ//AA!5#89 	 	 	AAA	 =**Q--C"}}Ks*    B8B
B B $B55CCc                 F    |                      t          |                    S )zSelect revisions reachable by a given bookmark

    If the bookmarked revision isn't a head, an empty set will be returned.
    )r   format_bookmark_revspec)rb   marks     r5   bookmarkrevsr    s    
 99,T22333r7   c                 :    d| z   } t          j        d| | |           S )zOBuild a revset expression to select revisions reachable by a given
    bookmarks   literal:sm   ancestors(bookmark(%s)) - ancestors(head() and not bookmark(%s)) - ancestors(bookmark() and not bookmark(%s)))r   rr  )r  s    r5   r  r    s3     D 	6 	  r7   r+   r,  )FNF)r   N)r   N)rv  rw  )FN)rH   NFr  N)NNFNT)rP  )r7   F)r|  )rS  rt   r  r   r  r  r  rD  i18nr   r  r   r   r   r	   r
   r   r   
thirdpartyr   rk   r   rz  r   r   r   r  r   r   r   r   r   r   r  r   r   r   r   r   r   utilsr   r   r    r   r!   scmplatformr"   	importmodr#   
importrust
rustrevlogtermsizer   r(   rZ   rf   r   r   r   r   r   r   r   r  r  r  r  r  r1  r5  rF  rJ  rH  rX  rf  rj  rp  rc  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r2  r=  rU  r?  rB  rC  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rx  ry  r8  hooksr5  _reportstroubledchangesetsrz  ra  r  r  r  r  r  r  r  rH   r7   r5   <module>r     ss      				     				                                                                         (           *+++++++))))))
&
9
%
%Vx((
 dG G G G G G G  G>3 3 34, , , ,({  {  { |
 
 
4
 
 

/ 
/ 
/         2! ! ! !H. . . .b    = = =+ + +  @  G& G& G& G&T
 
 
@+ @+ @+F. . .4     % % %4D D D D:   ' ' 'T  "% % % %P: : :
F F F  * GK   D GKK K K K  
. . . .
  3 3 3!" !" !"H4 4 4 4 4 4 4 4 t t t tnB B B BJ       F!7 !7 !7H  .     + + + +\   4$ $ $ $2- - - -D  &I I I
) ) ) )&" " "4 4 4 4 4 4 4 4n       $V) V) V) V) V) V) V) V)rA A AH0P 0P 0P 0P 0P 0P 0P 0Pf  5 5 5E& E& E& E& E& E& E& E&P     + + +4 DJLL  " h1 h1 h1 h1VC C CF F F F. . .$  22 22 22j     F4 4 4    r7   