
    6h              	      R   S r SSKJr  SSKrSSKJr  SSKJr  SSKJ	r	J
r
Jr  SSKJr  Sr0 r\R                   " \5      r\" S	S
SS9  \R"                  " S\R$                  5      rSSS.rSSS.rS#S jrS rS rS rS rS rS rS rS r\\\\\\\\S.rS r S r!S r"S  r#S! r$S" r%g)$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
    )annotationsN)_)short)cmdutil
extensions	registrar)
stringutils   ships-with-hg-core	   win32text   warnT)defaults	   (^|[^])
s   CRLFs   CR)   
   s   clevers   macc                    X;   aY  U(       aQ  U(       aI  U(       aA  UR                  [        S5      U[        U   UR                  R	                  S5      4-  5        g g g g g )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   N   sX    
 |xD
F G,dhhmmG.DEF	
 -1x|    c                H    [        U S40 UD6  [        R                  SU 5      $ )Nr   s   \1
)r   re_single_lfsubr   cmdkwargss      r   
dumbdecoder"   _   s$    G&v&J**r   c                &    U R                  SS5      $ )Nr      
replacer   r    s     r   
dumbencoder(   e   s    99We$$r   c                @    [        U S40 UD6  U R                  SS5      $ Nr   r$   )r   r&   r   s      r   macdumbdecoder+   i   s"    E$V$99UE""r   c                &    U R                  SS5      $ r*   r%   r'   s     r   macdumbencoder-   n   s    99UE""r   c                T    [         R                  " U 5      (       d  [        X40 UD6$ U $ N)r	   binaryr"   r   s      r   cleverdecoder1   r   s(    Q!+F++Hr   c                R    [         R                  " U 5      (       d  [        X5      $ U $ r/   )r	   r0   r(   r'   s     r   cleverencoder3   x   s#    Q!!!Hr   c                T    [         R                  " U 5      (       d  [        X40 UD6$ U $ r/   )r	   r0   r+   r   s      r   	macdecoder5   ~   s(    QQ.v..Hr   c                R    [         R                  " U 5      (       d  [        X5      $ U $ r/   )r	   r0   r-   r'   s     r   	macencoder7      s#    QQ$$Hr   )s   dumbdecode:s   dumbencode:s   cleverdecode:s   cleverencode:s   macdumbdecode:s   macdumbencode:s
   macdecode:s
   macencode:c           	        Sn[        5       nUS   n[        UR                  R                  5       X   R	                  5       S-
  S5       H  n	X   n
U
R                  5        H  nX;   d
  X;  d  X;  a  M  UR                  U5        X   R                  5       n[        R                  " U5      (       a  MT  XL;   d  M[  U(       d$  U R                  [        S5      [        U   -  5        U R                  [        S5      [        U
R                  5       5      U4-  5        SnM     M     U(       aE  US:X  a?  [        U   R                  5       n[         U   nU R                  [        S	5      XX4-  5        U$ )
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	   r0   r   r   r   r   nodelower	filterstr)r   r   hooktyperC   r   r!   haltseentipr?   cfrB   crlffilters                  r   forbidnewlinerN      sL   D5D v,CT^^**,djnn.>.BBGIAyALAJHHQK499;D$$T**wGG7 %W-	. .)U1668_a,@@A  H$ 00'"((*7#
$  6*!+	
& Kr   c                    [        XX#S40 UD6$ )Nr   rN   r   r   rF   rC   r!   s        r   
forbidcrlfrR      s    87EfEEr   c                    [        XX#S40 UD6$ )Nr   rP   rQ   s        r   forbidcrrT      s    85CFCCr   c                    UR                  5       (       d  g [        R                  5        H  u  p#UR                  X#5        M     g r/   )local_filtersitemsadddatafilter)r   r   namefns       r   	reposetupr\      s1    ::<<NN$4$ %r   c                   UR                   nUS   S    H\  n	UR                  U	5      n
U
c  M  U
R                  (       d  M,  UR                  U	U
R                  U
R                  U
R
                  S9  M^     U " XX4U/UQ70 UD6$ )Ns   revertr   )
p1_trackedp2_info)dirstate	get_entryr^   hacky_extension_update_filetrackedr_   )origr   ctxnamesuipathfnactionsargsr!   dsr   entrys              r   wrap_revertrl      s    	BI&q)X& ..MM$//!MM	 /  *" 5GEdEfEEr   c                    U R                  SS5      (       a  U R                  [        S5      5        [        R                  " [
        S[        5        g )Nr
   r   sK   win32text is deprecated: https://mercurial-scm.org/wiki/Win32TextExtension
_performrevert)
configboolr   r   r   wrapfunctionr   rl   )r   s    r   extsetuprq      sB    	}}\7++
G	
 G%5{Cr   )NNN)&__doc__
__future__r   remercurial.i18nr   mercurial.noder   	mercurialr   r   r   mercurial.utilsr	   
testedwithconfigtable
configitemcompile	MULTILINEr   r   rE   r   r"   r(   r+   r-   r1   r3   r5   r7   rW   rN   rR   rT   r\   rl   rq    r   r   <module>r      s   "H # 	    
 ' #
!!+.
 
 zz.",,7u-
/	
"+%#
# ""$$	1hFD%F.	Dr   