a
    %0É_™  ã                	   @   s¤   d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
 i Ze	 e¡ZdZeddd	d
edƒedƒfddd
edƒedƒfgedƒejdddd„ƒZddd„ZdS )an  erase file content at a given revision

The censor command instructs Mercurial to erase all content of a file at a given
revision *without updating the changeset hash.* This allows existing history to
remain valid while preventing future clones/pulls from receiving the erased
data.

Typical uses for censor are due to security or legal requirements, including::

 * Passwords, private keys, cryptographic material
 * Licensed data/code/libraries for which the license has expired
 * Personally Identifiable Information or other private data

Censored nodes can interrupt mercurial's typical operation whenever the excised
data needs to be materialized. Some commands, like ``hg cat``/``hg revert``,
simply fail when asked to produce censored data. Others, like ``hg verify`` and
``hg update``, must be capable of tolerating censored data to continue to
function in a meaningful way. Such commands only tolerate censored file
revisions if they are allowed by the "censor.policy=ignore" config option.

A few informative commands such as ``hg grep`` will unconditionally
ignore censored data and merely report that it was encountered.
é    )Úabsolute_import)Ú_)Úshort)ÚerrorÚ	registrarÚscmutils   ships-with-hg-coreó   censoró   rs   revó    s#   censor file from specified revisions   REVó   ts	   tombstones   replacement tombstone datas   TEXTs   -r REV [-t TEXT] [FILE])Zhelpcategoryc              	   K   sz   |  ¡ ^ | ¡ 6 t| ||||fi |¤ŽW  d   ƒ W  d   ƒ S 1 sN0    Y  W d   ƒ n1 sl0    Y  d S )N)ZwlockÚlockÚ	_docensor)ÚuiÚrepoÚpathÚrevÚ	tombstoneÚopts© r   ú./usr/lib/python3/dist-packages/hgext/censor.pyÚcensor3   s    r   c                 K   sú  |st  tdƒ¡‚|s$t  tdƒ¡‚|d  }t ||f¡}| ¡ sRt| ¡ ƒdkr`t  tdƒ¡‚| ¡ d }| |¡}t|ƒsŒt  tdƒ¡‚t 	|||¡ 
¡ }z|| }	W n$ tyÎ   t  tdƒ| ¡‚Y n0 z|	 |¡}
W n( t jy   t  tdƒ| ¡‚Y n0 |
 ¡ }g }| ¡ D ]2}|| }||v r| |¡|kr| |¡ q|r„d	 d
d„ |D ƒ¡}t jtdƒ| tdƒd‚| ¡ }|	 ¡ dd„ |D ƒv rºt jtdƒtdƒd‚| d¡ }|j|||d W d   ƒ n1 sì0    Y  d S )Ns    must specify file path to censors   must specify revision to censoré   s%   can only specify an explicit filenamer   s"   cannot censor file with no historys   invalid revision identifier %ss"   file does not exist at revision %ss   , c                 S   s   g | ]}t | ¡ ƒ‘qS r   )r   Únode)Ú.0Úcr   r   r   Ú
<listcomp>i   r
   z_docensor.<locals>.<listcomp>s    cannot censor file in heads (%s)s   clean/delete and commit first)Úhintc                 S   s   g | ]}|  ¡ ‘qS r   )r   )r   Úpr   r   r   r   p   r
   s   cannot censor working directorys   clean/delete/update firstr   )r   )r   ZAbortr   r   ÚmatchZanypatsÚlenÚfilesÚfileZ	revsingler   ÚKeyErrorZfilectxÚLookupErrorZfilenodeÚheadsÚappendÚjoinÚparentsr   ZtransactionZcensorrevision)r   r   r   r   r   r   ZwctxÚmZflogÚctxZfctxZfnoder$   ZheadnodeZhcZheadlistZwpZtrr   r   r   r   G   sR    

þþr   N)r
   r
   )r
   r
   )Ú__doc__Z
__future__r   Zmercurial.i18nr   Zmercurial.noder   Z	mercurialr   r   r   ZcmdtableZcommandZ
testedwithZCATEGORY_MAINTENANCEr   r   r   r   r   r   Ú<module>   s,   
ûø
ó