a +b @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)  scleversmaccCs<||vr8|r8|r8|r8|td|t||jdfdS)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 newlinestrZvfsjoin)snewlineuirepofilenamer5/usr/lib64/python3.9/site-packages/hgext/win32text.py checknewlineOsrcKst|dfi|td|S)Nr s\1 )r re_single_lfsubrcmdkwargsrrr dumbdecode`srcCs |ddS)Nr  replacerrrrr dumbencodefsr$cKst|dfi||ddSNrr )rr"rrrr macdumbdecodejsr&cCs |ddSr%r!r#rrr macdumbencodeosr'cKs t|st||fi|S|SN)r binaryrrrrr cleverdecodess r*cCst|st||S|Sr()r r)r$r#rrr cleverencodeys  r+cKs t|st||fi|S|Sr()r r)r&rrrr macdecodes r,cCst|st||S|Sr()r r)r'r#rrr macencodes  r-)s dumbdecode:s dumbencode:s cleverdecode:s cleverencode:smacdumbdecode:smacdumbencode:s macdecode:s macencode:cKsd}t}|d}t|j||ddD]} || } | D]} | |vsF| |vsF| | vrdqF|| | | } t | sF|| vrF|s| t dt || t dt| | fd}qFq2|r |dkr t |} 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: )setrZxrangeZ changelogZtiprevrevfilesadddatar r)rrrrnodelower filterstr)rrhooktyper5rrZhaltseenZtipr1cfr4Zcrlffilterrrr forbidnewlinesD     r=cKst||||dfi|S)Nr r=rrr8r5rrrr forbidcrlfsr@cKst||||dfi|S)Nrr>r?rrrforbidcrsrAcCs0|s dSttD]\}}|||qdSr()localrZ iteritems_filtersZ adddatafilter)rrnamefnrrr reposetupsrFc Os|j}|P|ddD]2} || } | dur| jr|j| | jd| jdqWdn1sd0Y||||||g|Ri|S)NsrevertrT) p1_trackedp2_info)ZdirstateZ parentchangeZ get_entryrGZ update_fileZtrackedrH) ZorigrctxnamesZuipathfnactionsargsrZdsrentryrrr wrap_reverts  &rNcCs,|ddr|tdttdtdS)Nr r sKwin32text is deprecated: https://mercurial-scm.org/wiki/Win32TextExtension Z_performrevert)Z configboolrrrZ wrapfunctionrrN)rrrrextsetups rO)NNN)'__doc__Z __future__rreZmercurial.i18nrZmercurial.noderZ mercurialrrrrZmercurial.utilsr Z testedwithZ configtableZ configitemcompile MULTILINErrr7rrr$r&r'r*r+r,r-rCr=r@rArFrNrOrrrrsR$         6