o ]Lb @s*dZddlmZddlZddlmZddlmZddlm Z m Z m Z m Z ddl mZdZiZe eZed d d d ed ejZdddZdddZd2ddZddZddZddZddZddZdd Zd!d"Zd#d$Zeeeeeeeed%Z d&d'Z!d(d)Z"d*d+Z#d,d-Z$d.d/Z%d0d1Z&dS)3aperform 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 )absolute_importN)_)short)cmdutil extensionspycompat registrar) stringutilsships-with-hg-core win32textwarnT)defaults (^|[^ ]) sCRLFsCR)  scleversmaccCsL||vr|r |r"|r$|td|t||jdfdSdSdSdSdS)NsWARNING: %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. shgrc)warnr newlinestrvfsjoin)snewlineuirepofilenamer1/usr/lib/python3/dist-packages/hgext/win32text.py checknewlineOsrcKst|dfi|td|S)Nr s\1 )r re_single_lfsubrcmdkwargsrrr dumbdecode`s r cC |ddS)Nr  replacerrrrr dumbencodef r&cKst|dfi||ddSNrr")rr$rrrr macdumbdecodejs r)cCr!r(r#r%rrr macdumbencodeor'r*cK t|st||fi|S|SN)r binaryr rrrr cleverdecodes r.cCt|s t||S|Sr,)r r-r&r%rrr cleverencodey  r1cKr+r,)r r-r)rrrr macdecoder/r3cCr0r,)r r-r*r%rrr macencoder2r4)s dumbdecode:s dumbencode:s cleverdecode:s cleverencode:smacdumbdecode:smacdumbencode:s macdecode:s macencode:cKs d}t}|d}t|j||ddD]L} || } | D]A} | |vs1| |vs1| | vr2q#|| | | } t | sd|| vrd|sS| t dt || t dt| | fd}q#q|r|dkrt |} t|}| t d | | ||f|S) NFstips=attempt to commit or push text file(s) using %s line endings s in %s: %s Tspretxnchangegroups 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: )setrxrange changelogtiprevrevfilesadddatar r-rrrrnodelower filterstr)rrhooktyper?rrhaltseentipr;cfr>crlffilterrrr forbidnewlinesH      rJcKt||||dfi|S)Nr rJrrrBr?rrrr forbidcrlfrNcKrK)NrrLrMrrrforbidcrrOrPcCs0|sdSttD] \}}|||q dSr,)localr iteritems_filters adddatafilter)rrnamefnrrr reposetups rWc Os|j}|(|ddD]} || } | dur'| jr'|j| | jd| jdqWdn1s2wY||||||g|Ri|S)NsrevertrT) p1_trackedp2_info)dirstate parentchange get_entryrX update_filetrackedrY) origrctxnamesuipathfnactionsargsrdsrentryrrr wrap_reverts    rgcCs,|ddr |tdttdtdS)Nr r sKwin32text is deprecated: https://mercurial-scm.org/wiki/Win32TextExtension _performrevert) configboolrrr wrapfunctionrrg)rrrrextsetups rk)NNN)'__doc__ __future__rremercurial.i18nrmercurial.noder mercurialrrrrmercurial.utilsr testedwith configtable configitemcompile MULTILINErrrArr r&r)r*r.r1r3r4rSrJrNrPrWrgrkrrrrsT $        6