
    q&f              	       J   d Z ddlZddlmZ ddlmZ ddlmZmZm	Z	 ddl
mZ dZi Z e	j                  e      Z edd	d
        ej                  dej                         ZdddZdddZd"dZd Zd Zd Zd Zd Zd Zd Zd ZeeeeeeeedZd Zd Zd Z d Z!d  Z"d! Z#y)#a  perform automatic newline conversion (DEPRECATED)

  Deprecation: The win32text extension requires each user to configure
  the extension again and again for each clone since the configuration
  is not copied when cloning.

  We have therefore made the ``eol`` as an alternative. The ``eol``
  uses a version controlled file for its configuration and each clone
  will therefore use the right settings from the start.

To perform automatic newline conversion, use::

  [extensions]
  win32text =
  [encode]
  ** = cleverencode:
  # or ** = macencode:

  [decode]
  ** = cleverdecode:
  # or ** = macdecode:

If not doing conversion, to make sure you do not commit CRLF/CR by accident::

  [hooks]
  pretxncommit.crlf = python:hgext.win32text.forbidcrlf
  # or pretxncommit.cr = python:hgext.win32text.forbidcr

To do the same check on a server to prevent CRLF/CR from being
pushed or pulled::

  [hooks]
  pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf
  # or pretxnchangegroup.cr = python:hgext.win32text.forbidcr
    N)_)short)cmdutil
extensions	registrar)
stringutils   ships-with-hg-core	   win32text   warnT)defaults	   (^|[^])
s   CRLFs   CR)   
   s   clevers   macc                     || v rJ|rG|rD|rA|j                  t        d      |t        |   |j                  j	                  d      fz         y y y y y )Ns   WARNING: %s already has %s line endings
and does not need EOL conversion by the win32text plugin.
Before your next commit, please reconsider your encode/decode settings in 
Mercurial.ini or %s.
s   hgrc)warnr   
newlinestrvfsjoin)snewlineuirepofilenames        1/usr/lib/python3/dist-packages/hgext/win32text.pychecknewliner   M   sZ    
 !|xD
F G,dhhmmG.DEF	
 -1x|    c                 H    t        | dfi | t        j                  d|       S )Nr   s   \1
)r   re_single_lfsubr   cmdkwargss      r   
dumbdecoder!   ^   s$    G&v&J**r   c                 &    | j                  dd      S )Nr      
replacer   r   s     r   
dumbencoder'   d   s    99We$$r   c                 @    t        | dfi | | j                  dd      S Nr   r#   )r   r%   r   s      r   macdumbdecoder*   h   s"    E$V$99UE""r   c                 &    | j                  dd      S r)   r$   r&   s     r   macdumbencoder,   m   s    99UE""r   c                 J    t        j                  |       st        | |fi |S | S N)r   binaryr!   r   s      r   cleverdecoder0   q   s'    Q!S+F++Hr   c                 H    t        j                  |       st        | |      S | S r.   )r   r/   r'   r&   s     r   cleverencoder2   w   s"    Q!S!!Hr   c                 J    t        j                  |       st        | |fi |S | S r.   )r   r/   r*   r   s      r   	macdecoder4   }   s'    QQ.v..Hr   c                 H    t        j                  |       st        | |      S | S r.   )r   r/   r,   r&   s     r   	macencoder6      s"    QQ$$Hr   )s   dumbdecode:s   dumbencode:s   cleverdecode:s   cleverencode:s   macdumbdecode:s   macdumbencode:s
   macdecode:s
   macencode:c           	         d}t               }|d   }t        |j                  j                         ||   j	                         dz
  d      D ]  }	||	   }
|
j                         D ]  }||v s||vs||
vr|j                  |       |
|   j                         }t        j                  |      rJ||v sO|s$| j                  t        d      t        |   z         | j                  t        d      t        |
j                               |fz         d}  |rF|dk(  rAt        |   j                         }t         |   }| j                  t        d	      ||||fz         |S )
NFs   tip   s=   attempt to commit or push text file(s) using %s line endings
s
   in %s: %s
Ts   pretxnchangegroups   
To prevent this mistake in your local repository,
add to Mercurial.ini or .hg/hgrc:

[hooks]
pretxncommit.%s = python:hgext.win32text.forbid%s

and also consider adding:

[extensions]
win32text =
[encode]
** = %sencode:
[decode]
** = %sdecode:
)setrange	changelogtiprevrevfilesadddatar   r/   r   r   r   r   nodelower	filterstr)r   r   hooktyperB   r   r    haltseentipr>   cfrA   crlffilters                  r   forbidnewlinerM      sd   D5D v,CT^^**,d4jnn.>.BBG I 	ADyASLAQJHHQKQ499;D$$T*w$GG7 %W-	. .)U1668_a,@@A	$ 00'"((*7#
$  T66*!+	
& Kr   c                 "    t        | |||dfi |S )Nr   rM   r   r   rE   rB   r    s        r   
forbidcrlfrQ      s    T8T7EfEEr   c                 "    t        | |||dfi |S )Nr   rO   rP   s        r   forbidcrrS      s    T8T5CFCCr   c                     |j                         sy t        j                         D ]  \  }}|j                  ||        y r.   )local_filtersitemsadddatafilter)r   r   namefns       r   	reposetupr[      s8    ::<NN$ %b4$%r   c                     |j                   }|d   d   D ]V  }	|j                  |	      }
|
|
j                  s$|j                  |	|
j                  |
j                  |
j
                         X  | |||||g|i |S )Ns   revertr   )
p1_trackedp2_info)dirstate	get_entryr]   hacky_extension_update_filetrackedr^   )origr   ctxnamesuipathfnactionsargsr    dsr   entrys              r   wrap_revertrk      s    	BI&q) X& ..MM$//!MM	 / " c5(GEdEfEEr   c                     | j                  dd      r| j                  t        d             t        j                  t
        dt               y )Nr	   r
   sK   win32text is deprecated: https://mercurial-scm.org/wiki/Win32TextExtension
_performrevert)
configboolr   r   r   wrapfunctionr   rk   )r   s    r   extsetuprp      s?    	}}\7+
G	
 G%5{Cr   )NNN)$__doc__remercurial.i18nr   mercurial.noder   	mercurialr   r   r   mercurial.utilsr   
testedwithconfigtable
configitemcompile	MULTILINEr   r   rD   r   r!   r'   r*   r,   r0   r2   r4   r6   rV   rM   rQ   rS   r[   rk   rp    r   r   <module>r}      s   "J 
    
 ' #
!Y!!+.
 
 rzz.",,7u-
/	
"+%#
# ""$$	1hFD%F.	Dr   