
    q&fj(                         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	 ddl
mZ i Zi Z ej                  ee      Zd Z edd	      d
        Zi Zd ZddZ	 	 	 ddZ	 	 	 	 	 ddZy)    N   )_)errorpycompat	registrarrequirements)
stringutilc                       y )N )argskwargss     8/usr/lib/python3/dist-packages/mercurial/admin/verify.py	noop_funcr      s    
    s   working-copy.dirstates   dirstate)aliasc                    | j                  t        d             |j                  j                         \  }}||   j	                         }||   j	                         }d}t
        j                  |j
                  v }|r|j                         nd }	|j                  j                  |||	      D ]!  }
| j                  |
d   |
dd  z         |dz  }# |S )Ns   checking dirstate
r      )
statusr   dirstateparentsmanifestr   NARROW_REQUIREMENTnarrowmatchverifywarn)uirepooptionsparent1parent2m1m2errors	is_narrownarrow_matchererrs              r   check_dirstater'      s    IIa&'(}},,.GW	g			!B	g			!BF//43D3DDI+4T%%'$N}}##BN; 
AQR !! Mr   c                 ,   t        | j                         d d      D ]t  \  }}|}|j                  d      }|dd D ]  }|j                  |i       }|} |j	                  |d         ||f||d   <   V|t
        us_d}t        j                  |       y)zuCreate a pyramid of checks of the registered checks.
    It is a name-based hierarchy that can be arbitrarily nested.c                     | d   S )Nr   r   )xs    r   <lambda>zbuild_pyramid.<locals>.<lambda>7   s
    1Q4 r   T)keyreverse   .Ns2   intermediate checks need to use `verify.noop_func`)sorteditemssplit
setdefaultgetr   r   ProgrammingError)	tablefull_pyramidentryfunccursorlevelslevelcurrent_nodems	            r   build_pyramidr?   4   s     ekkmN 
,tT"CR[ 	"E!,,UB7L!F	" ::fRj!)"'F6":"EA((++
,r   c                 2   |t         }|t        }| dk(  r|S i }|j                  |       }|y|j                  |       }||} |j                  |       }nT| j                  dd      }t	        |      dk(  r4|j                  |d         }|d||d   fz  } |j                  |       }n| }| j                  d      }|F|st        ||       t        j                          t        j                  |j                                nt        |t               t        }	|D ]x  }
|	j                  |
      }	|	t        j                  t        |      t        |      z   |       }t        j                  |      }t        j                  t        d| z        |       t!        |	t"              rnt        |	j                               }|rQ|j%                         \  }}t!        |t"              r |j'                  |j                                n|d   ||d   <   |rQ|S ||| <   |S )	a  Find all checks for a given name and returns a dict of
    (qualified_check_name, check_function)

    # Examples

    Using a full qualified name:
    "working-copy.dirstate" -> {
        "working-copy.dirstate": CF,
    }

    Using a *prefix* of a qualified name:
    "store.revlogs" -> {
        "store.revlogs.changelog": CF,
        "store.revlogs.manifestlog": CF,
        "store.revlogs.filelog": CF,
    }

    Using a defined alias:
    "revlogs" -> {
        "store.revlogs.changelog": CF,
        "store.revlogs.manifestlog": CF,
        "store.revlogs.filelog": CF,
    }

    Using something that is none of the above will be an error.
    s   fullr.   r   r   r   s   %s.%ss   unknown check %shint)verify_tableverify_alias_tabler4   r2   lenr?   pyramidclearupdater1   r   
getsimilarlistsimilarity_hint
InputErrorr   
isinstancedictpopextend)namer6   alias_tabler7   checkscheckqualified_namer2   r;   subtreer<   rB   stackcurrent_namer8   s                  r   find_checksrY   D   s   6 }(wF IIdOE}$.%!DIIdOEJJtQ'E5zQ!,q!:!-#~uQx&@@D!IIdOE ZZF%.|))+,eW%G M++e$?##D$5U$CTJD((.D""1%84%?#@tLLM '4 W]]_%"'))+L%%&U[[]+ $)8uQx   M tMr   c           	        ! | j                  d       t        j                  t              }|st	        j
                  t        d            t        |      D ]C  }|j                  d      }t        d      }	t	        j                  t        d      |z  |	      }
t        |      dk7  r|
|\  }}|s|
|j                  d      }t        |      dk7  r|
|\  !}|s|
d	|!fz  }t        ||||
      }|D ]  }|j                  |      }|%t        d      }t	        j                  ||!fz        t        |d      sJ t        |j                  d      s#t	        j                  t        d      |!fz        	 t        !fd|j                  j                   D              }|\  }}}d}t%        |t&              r=t)        j*                  |      }|#t	        j                  t        d      ||fz        |}nlt%        |t,              r=t)        j.                  |      }|#t	        j                  t        d      ||fz        |}nt	        j0                  dt3        |            !||   v r#t	        j                  t        d      !|fz        |J |||   !<    F |j5                         D ]  \  }}||vsi ||<    |j5                         D ]  \  }}|j                  |      }||   }i }|J |j                  J t        |j                  d      sJ |j                  j                   r\|j                  j                   D ci c]  }|d   t7        j8                  |d           }}|r|j5                         D ]
  \  }} | ||<    t;        j<                  |      }t?        j@                  |fi |||<   | j                  d||fz          |S # t"        $ r$ t	        j                  t        d      |!fz        w xY wc c}w )zGiven a dict of checks (fully qualified name to function), and a list
    of options as given by the user, pass each option down to the right check
    function.s#   passing options to check functions
s   `checks` required   :s@   syntax is 'check:option=value', eg. revlogs.changelog:copies=yess   invalid option '%s'rA   r      =s   %s:%sr6   rR   r7   Ns0   specified option '%s' for unselected check '%s'
r9   r   s   check '%s' has no option '%s'c              3   4   K   | ]  }|d    k(  s|  yw)r   Nr   ).0ooption_names     r   	<genexpr>zpass_options.<locals>.<genexpr>   s     J1adk6IQJs   s   '%s' is not a boolean ('%s')s   '%s' is not a list ('%s')s   unsupported type %ss   duplicated option '%s' for '%s'r   r   s   merged options for '%s': '%r'
)!debugcollectionsdefaultdictrN   r   Errorr   r0   r2   rL   rE   rY   r4   hasattrr9   nextr   StopIterationrM   boolr	   	parseboolrJ   	parselistr5   typer1   copydeepcopyr   	strkwargs	functoolspartial)"r   rS   r   r6   rR   r7   	to_modifyoptionr2   rB   option_error
check_nameoption_valuevaluepathmatching_checksrQ   rT   msgmatching_option_nametyp
_docstringas_typedas_boolas_listfcmd_optionsr9   merged_optionsr`   kvra   s"                                    @r   pass_optionsr      s_    HH45''-Ikk!0122/ Q8T"0
 ''$%.T
 u:?#( 
L""4(u:?"U:{33%#%	
 $ 1	8DJJt$E}LM&&sdK-@'@AA5&)))5::y1&&674:MM "&J

 2 2J# &5"E3
H#t$$..u5?**9:dE]J  #C&$..u5?**674-G  #,,-CT#YOOio-&&89[$<OO   +++/7	$,c1	8AQ8j <<> !ay  IdO!
 $-??#4 M
K

:&j!   zz%%%uzz9---:: 49::3E3E./!dmmAaD))N  '--/ *DAq()N1%*$$^4&..t?w?z
3z76KKL'M* M} ! &&674:MM hs   9(O#P-O?c           
      T   i }|g }|g }|D ]I  }t        ||||      }	dj                  |	      }
|j                  d|
|fz         |j                  |	       K |j	                         D ci c]  \  }}|t        j                  |||        }}}t        ||||||      }|S c c}}w )a'  Given a list of function names and optionally a list of
    options, return matched checks with merged options (command line options
    values take precedence on default ones)

    It runs find checks, then resolve options and returns a dict of matched
    functions with resolved options.
    r]   s   , s    found checks '%s' for name '%s'
)rY   joinrc   rH   r1   rq   rr   r   )r   r   namesr   r6   rR   r7   funcsrQ   matchedmatched_namesnr   rS   s                 r   
get_checksr   %  s      E}  	#%	
 

7+
58MMNW	 <A;;=I41aQ	!!!R..IEI 
!F M Js   ,"B$)NNN)NNNNN)rd   rn   rq   i18nr    r   r   r   r   utilsr	   rC   rD   verify_checkrT   r   r'   rF   r?   rY   r   r   r   r   r   <module>r      s        7 7   	|-?@ {3 4& , [D @L 
0r   