^c!\ddlZddlZddlmZddlmZddlmZmZm Z GddZ dS)N)_)getattr)encodingerrorutilceZdZddZdZdZdZdZdZdZ d Z d Z dd Z d Z d ZdZdZdZddZdZdZddZddZdS)configNcd|_i|_g|_|r=|jD]$}|||j|<%|jdz|_dSdS)Nrr)_current_source_level_data_unsetcopy)selfdataks 2/usr/lib/python3/dist-packages/mercurial/config.py__init__zconfig.__init__sm%&"   HZ / / $Q  1 )-)Ca)GD & & & H Hc&|xjdz c_dS)zYincrement the source counter This is used to define source priority when readingrN)r rs r new_sourcezconfig.new_sources ""a'""""rc t|SN)r rs rrz config.copy%sd||rc||jvSr)r rsections r __contains__zconfig.__contains__(s$*$$rc<||j|ivSrr getrritems rhasitemzconfig.hasitem+stz~~gr2222rc8|j|iSrr rs r __getitem__zconfig.__getitem__.sz~~gr***rc#@K|D]}|VdSr)sections)rds r__iter__zconfig.__iter__1s2  AGGGG  rcD|j}|dz }|j}|jD]P\}}|j|d}|.||vr*||j|<|j||=Q|D]}|j|d}|r||j|<nt j|j|<|j|D]3\}}|\} } } | |z } t| |}| | | f|j||<4||_dS)Nr) r rr r! preparewriter cowsortdictitemsmax) rsrc current_level max_levelsndsrvvaluesourcelevels rupdatez config.update5sG2  . J % %DAq4((B~!r'' " 1 1 1 JqM!$ : :A4((B 3 " 1 1 1 $ 0 2 2 1  ! **,, : :1'($vu&}55 $)65#9 1 a   : &/"""rc^|j|i|Srr r"s r_getz config._getKs&z~~gr**..t444rcF|||}||S|dS)Nrr<)rrr#defaultresults rr!z config.getNs)7D)) >Nayrc` |j||}||f|zS#t$r||fcYSwxYw)zreturn a tuple allowing restore to reinstall a previous value The main reason we need it is because it handles the "no data" case. )r KeyError)rrkeyr#s rbackupz config.backupTsV  ):g&s+DS>D( ( " " "S> ! ! ! "s --cF|||}|dS|dS)Nrrr>rrr#r@s rr8z config.source`s)7D)) >3ayrcF|||}|dS|dS)Nr>rFs rr9z config.levelfs)7D)) >4ayrcNt|jSr)sortedr keysrs rr(zconfig.sectionslsdjoo''(((rct|j|i}d|DS)Nc(g|]\}}||dfS)r).0rr6s r z config.items..qs$...fq!AaD ...r)r r!r.)rrr.s rr.z config.itemsos7 w++1133......rrc~t|tr Jdt|tr Jdt|tr Jd||vrtj|j|<n'|j||j|<|||jf|j||<dS)Ns5config section may not be unicode strings on Python 3s2config item may not be unicode strings on Python 3s4config values may not be unicode strings on Python 3) isinstancestrrr-r r,r )rrr#r7r8s rsetz config.setss S   D D C D D D #   A A @ A A A 3   C C B C C C $  "&"2"4"4DJw  "&*W"5"B"B"D"DDJw %*FD4N$O 7D!!!rc|j||}t|}|f|ddz}t||ksJ||j||<dS)zsalter a value without altering its source or level This method is meant to be used by `ui.fixconfig` only.rN)r len)rrrC new_valuer#sizenew_items ralterz config.altersbz'"3'4yy<$qrr(*8}}$$$$#+ 7C   rc.t|dkrP|dd\}}|dd}|j||j|<||j||<dS|\}}||jvr#|j||ddSdS)z$restore data returned by self.backuprHN)rVr r,pop)rrrrCr#s rrestorezconfig.restores t99>>8LGS8D"&*W"5"B"B"D"DDJw '+DJw  $ $ $!MGT$*$$ 7#''d33333%$rc tjd}tjd}tjd}tjd} tjd} tjd} tjd} d} d}d }d }|r|| | } |d D]<}|d z }|d kr|d r |dd}|r| |rE||}|rT|r| |vrc|| |dz|d z}|| ||d||fzd}d }| |}|r|rtj |d } ||||no#t$rb}|j tj krCtjtd|t!j|jfzd||fzYd}~nd}~wwxYwu| |r||}|rN|d } |r|| | } | |vrtj|j| <||}|rQ|d }d }|r| |vr'|| ||dd||fzY| |}|r|d }|r| |vr|| |5|j| |j| <|j| |=|j| |f|}|drd|z}tj|d||fzdS)Ns \[([^\[]+)\]s([^=\s][^=]*?)\s*=\s*(.*\S|)s\s+(\S|\S.*\S)\s*$s (;|#|\s*$)s(;|#)s%unset\s+(\S+)s%include\s+(\S|\S.*\S)\s*$rrFTrs s%s:%dremapr(scannot include %s (%s)rH s!unexpected leading whitespace: %s)rrecompiler! splitlines startswithmatchgrouprT expandpathIOErrorerrnoENOENTr ConfigErrorrr strtolocalstrerrorr-r r,rappendrstrip)rr0rr(rbinclude sectionreitemrecontreemptyre commentreunsetre includererr#linecontlmr6expandedinstnamemessages rparsez config.parsesgGOO$455 !ABB!788'//.11GOOI.. '//"455GOO$BCC   2ii11G&&? G? GA AIDqyyQ\\/::yabbE ??1%%LLOO!G8$;$; $//%7!''!**DAHHWdAx3+/EFFF""A W ?1771::66GHEHEEEEEzU\11#/788')H#Gh#t.DFF F? G? GsH I?AI::I?cT|stj|d}t|dddksJd||jfzt j|fd}|| |||dS)Nsrbmoderbs=config files must be opened in binary mode, got fp=%r mode=%rctjtj|}|||dS)Nra)ospathnormpathjoinreadr)relrbr(absdirrs rrszconfig.read..includesV'""27<<S#9#9::C IIcI : : : OO     r)r(rbrs) rr posixfilerrrrdirnamerr)rrfpr(rbrsrs` @rrz config.reads  -e,,B B % % - - - K  GO   . - - good##       "''))heW      rr)r)NNN)__name__ __module__ __qualname__rrrrr$r&r*r:r<r!rDr8r9r(r.rTrZr]rrrNrrr r sjHHHH((( %%%333+++///,555 ) ) )  )))///PPPP ,,, 4 4 4OGOGOGOGb      rr ) rlri18nrpycompatrrrrr rNrrrs l l l l l l l l l l r