mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
Backed out changeset 86e4750e16d8
util.binary heuristic cannot be trusted when decoding working directory files.
This commit is contained in:
parent
054ab4657a
commit
db062e7060
@ -22,7 +22,6 @@
|
||||
# [hooks]
|
||||
# pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf
|
||||
|
||||
from mercurial import util
|
||||
from mercurial.i18n import gettext as _
|
||||
from mercurial.node import bin, short
|
||||
import re
|
||||
@ -47,15 +46,19 @@ def dumbdecode(s, cmd, ui=None, repo=None, filename=None, **kwargs):
|
||||
def dumbencode(s, cmd):
|
||||
return s.replace('\r\n', '\n')
|
||||
|
||||
def clevertest(s, cmd):
|
||||
if '\0' in s: return False
|
||||
return True
|
||||
|
||||
def cleverdecode(s, cmd, **kwargs):
|
||||
if util.binary(s):
|
||||
return s
|
||||
return dumbdecode(s, cmd, **kwargs)
|
||||
if clevertest(s, cmd):
|
||||
return dumbdecode(s, cmd, **kwargs)
|
||||
return s
|
||||
|
||||
def cleverencode(s, cmd):
|
||||
if util.binary(s):
|
||||
return s
|
||||
return dumbencode(s, cmd)
|
||||
if clevertest(s, cmd):
|
||||
return dumbencode(s, cmd)
|
||||
return s
|
||||
|
||||
_filters = {
|
||||
'dumbdecode:': dumbdecode,
|
||||
@ -72,7 +75,7 @@ def forbidcrlf(ui, repo, hooktype, node, **kwargs):
|
||||
if f not in c:
|
||||
continue
|
||||
data = c[f].data()
|
||||
if not util.binary(data) and '\r\n' in data:
|
||||
if '\0' not in data and '\r\n' in data:
|
||||
if not halt:
|
||||
ui.warn(_('Attempt to commit or push text file(s) '
|
||||
'using CRLF line endings\n'))
|
||||
|
Loading…
Reference in New Issue
Block a user