##// END OF EJS Templates
Backed out changeset 7f4257b5cbfc...
Patrick Mezard -
r6473:9c897ffd default
parent child Browse files
Show More
@@ -22,7 +22,6 b''
22 # [hooks]
22 # [hooks]
23 # pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf
23 # pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf
24
24
25 from mercurial import util
26 from mercurial.i18n import gettext as _
25 from mercurial.i18n import gettext as _
27 from mercurial.node import bin, short
26 from mercurial.node import bin, short
28 import re
27 import re
@@ -47,15 +46,19 b' def dumbdecode(s, cmd, ui=None, repo=Non'
47 def dumbencode(s, cmd):
46 def dumbencode(s, cmd):
48 return s.replace('\r\n', '\n')
47 return s.replace('\r\n', '\n')
49
48
49 def clevertest(s, cmd):
50 if '\0' in s: return False
51 return True
52
50 def cleverdecode(s, cmd, **kwargs):
53 def cleverdecode(s, cmd, **kwargs):
51 if util.binary(s):
54 if clevertest(s, cmd):
55 return dumbdecode(s, cmd, **kwargs)
52 return s
56 return s
53 return dumbdecode(s, cmd, **kwargs)
54
57
55 def cleverencode(s, cmd):
58 def cleverencode(s, cmd):
56 if util.binary(s):
59 if clevertest(s, cmd):
60 return dumbencode(s, cmd)
57 return s
61 return s
58 return dumbencode(s, cmd)
59
62
60 _filters = {
63 _filters = {
61 'dumbdecode:': dumbdecode,
64 'dumbdecode:': dumbdecode,
@@ -72,7 +75,7 b' def forbidcrlf(ui, repo, hooktype, node,'
72 if f not in c:
75 if f not in c:
73 continue
76 continue
74 data = c[f].data()
77 data = c[f].data()
75 if not util.binary(data) and '\r\n' in data:
78 if '\0' not in data and '\r\n' in data:
76 if not halt:
79 if not halt:
77 ui.warn(_('Attempt to commit or push text file(s) '
80 ui.warn(_('Attempt to commit or push text file(s) '
78 'using CRLF line endings\n'))
81 'using CRLF line endings\n'))
General Comments 0
You need to be logged in to leave comments. Login now