##// END OF EJS Templates
eol: fix silly test-gendoc breakage by escaping control characters
Matt Mackall -
r14857:5b46c16e default
parent child Browse files
Show More
@@ -1,344 +1,344
1 """automatically manage newlines in repository files
1 """automatically manage newlines in repository files
2
2
3 This extension allows you to manage the type of line endings (CRLF or
3 This extension allows you to manage the type of line endings (CRLF or
4 LF) that are used in the repository and in the local working
4 LF) that are used in the repository and in the local working
5 directory. That way you can get CRLF line endings on Windows and LF on
5 directory. That way you can get CRLF line endings on Windows and LF on
6 Unix/Mac, thereby letting everybody use their OS native line endings.
6 Unix/Mac, thereby letting everybody use their OS native line endings.
7
7
8 The extension reads its configuration from a versioned ``.hgeol``
8 The extension reads its configuration from a versioned ``.hgeol``
9 configuration file found in the root of the working copy. The
9 configuration file found in the root of the working copy. The
10 ``.hgeol`` file use the same syntax as all other Mercurial
10 ``.hgeol`` file use the same syntax as all other Mercurial
11 configuration files. It uses two sections, ``[patterns]`` and
11 configuration files. It uses two sections, ``[patterns]`` and
12 ``[repository]``.
12 ``[repository]``.
13
13
14 The ``[patterns]`` section specifies how line endings should be
14 The ``[patterns]`` section specifies how line endings should be
15 converted between the working copy and the repository. The format is
15 converted between the working copy and the repository. The format is
16 specified by a file pattern. The first match is used, so put more
16 specified by a file pattern. The first match is used, so put more
17 specific patterns first. The available line endings are ``LF``,
17 specific patterns first. The available line endings are ``LF``,
18 ``CRLF``, and ``BIN``.
18 ``CRLF``, and ``BIN``.
19
19
20 Files with the declared format of ``CRLF`` or ``LF`` are always
20 Files with the declared format of ``CRLF`` or ``LF`` are always
21 checked out and stored in the repository in that format and files
21 checked out and stored in the repository in that format and files
22 declared to be binary (``BIN``) are left unchanged. Additionally,
22 declared to be binary (``BIN``) are left unchanged. Additionally,
23 ``native`` is an alias for checking out in the platform's default line
23 ``native`` is an alias for checking out in the platform's default line
24 ending: ``LF`` on Unix (including Mac OS X) and ``CRLF`` on
24 ending: ``LF`` on Unix (including Mac OS X) and ``CRLF`` on
25 Windows. Note that ``BIN`` (do nothing to line endings) is Mercurial's
25 Windows. Note that ``BIN`` (do nothing to line endings) is Mercurial's
26 default behaviour; it is only needed if you need to override a later,
26 default behaviour; it is only needed if you need to override a later,
27 more general pattern.
27 more general pattern.
28
28
29 The optional ``[repository]`` section specifies the line endings to
29 The optional ``[repository]`` section specifies the line endings to
30 use for files stored in the repository. It has a single setting,
30 use for files stored in the repository. It has a single setting,
31 ``native``, which determines the storage line endings for files
31 ``native``, which determines the storage line endings for files
32 declared as ``native`` in the ``[patterns]`` section. It can be set to
32 declared as ``native`` in the ``[patterns]`` section. It can be set to
33 ``LF`` or ``CRLF``. The default is ``LF``. For example, this means
33 ``LF`` or ``CRLF``. The default is ``LF``. For example, this means
34 that on Windows, files configured as ``native`` (``CRLF`` by default)
34 that on Windows, files configured as ``native`` (``CRLF`` by default)
35 will be converted to ``LF`` when stored in the repository. Files
35 will be converted to ``LF`` when stored in the repository. Files
36 declared as ``LF``, ``CRLF``, or ``BIN`` in the ``[patterns]`` section
36 declared as ``LF``, ``CRLF``, or ``BIN`` in the ``[patterns]`` section
37 are always stored as-is in the repository.
37 are always stored as-is in the repository.
38
38
39 Example versioned ``.hgeol`` file::
39 Example versioned ``.hgeol`` file::
40
40
41 [patterns]
41 [patterns]
42 **.py = native
42 **.py = native
43 **.vcproj = CRLF
43 **.vcproj = CRLF
44 **.txt = native
44 **.txt = native
45 Makefile = LF
45 Makefile = LF
46 **.jpg = BIN
46 **.jpg = BIN
47
47
48 [repository]
48 [repository]
49 native = LF
49 native = LF
50
50
51 .. note::
51 .. note::
52 The rules will first apply when files are touched in the working
52 The rules will first apply when files are touched in the working
53 copy, e.g. by updating to null and back to tip to touch all files.
53 copy, e.g. by updating to null and back to tip to touch all files.
54
54
55 The extension uses an optional ``[eol]`` section read from both the
55 The extension uses an optional ``[eol]`` section read from both the
56 normal Mercurial configuration files and the ``.hgeol`` file, with the
56 normal Mercurial configuration files and the ``.hgeol`` file, with the
57 latter overriding the former. You can use that section to control the
57 latter overriding the former. You can use that section to control the
58 overall behavior. There are three settings:
58 overall behavior. There are three settings:
59
59
60 - ``eol.native`` (default ``os.linesep``) can be set to ``LF`` or
60 - ``eol.native`` (default ``os.linesep``) can be set to ``LF`` or
61 ``CRLF`` to override the default interpretation of ``native`` for
61 ``CRLF`` to override the default interpretation of ``native`` for
62 checkout. This can be used with :hg:`archive` on Unix, say, to
62 checkout. This can be used with :hg:`archive` on Unix, say, to
63 generate an archive where files have line endings for Windows.
63 generate an archive where files have line endings for Windows.
64
64
65 - ``eol.only-consistent`` (default True) can be set to False to make
65 - ``eol.only-consistent`` (default True) can be set to False to make
66 the extension convert files with inconsistent EOLs. Inconsistent
66 the extension convert files with inconsistent EOLs. Inconsistent
67 means that there is both ``CRLF`` and ``LF`` present in the file.
67 means that there is both ``CRLF`` and ``LF`` present in the file.
68 Such files are normally not touched under the assumption that they
68 Such files are normally not touched under the assumption that they
69 have mixed EOLs on purpose.
69 have mixed EOLs on purpose.
70
70
71 - ``eol.fix-trailing-newline`` (default False) can be set to True to
71 - ``eol.fix-trailing-newline`` (default False) can be set to True to
72 ensure that converted files end with a EOL character (either ``\n``
72 ensure that converted files end with a EOL character (either ``\\n``
73 or ``\r\n`` as per the configured patterns).
73 or ``\\r\\n`` as per the configured patterns).
74
74
75 The extension provides ``cleverencode:`` and ``cleverdecode:`` filters
75 The extension provides ``cleverencode:`` and ``cleverdecode:`` filters
76 like the deprecated win32text extension does. This means that you can
76 like the deprecated win32text extension does. This means that you can
77 disable win32text and enable eol and your filters will still work. You
77 disable win32text and enable eol and your filters will still work. You
78 only need to these filters until you have prepared a ``.hgeol`` file.
78 only need to these filters until you have prepared a ``.hgeol`` file.
79
79
80 The ``win32text.forbid*`` hooks provided by the win32text extension
80 The ``win32text.forbid*`` hooks provided by the win32text extension
81 have been unified into a single hook named ``eol.checkheadshook``. The
81 have been unified into a single hook named ``eol.checkheadshook``. The
82 hook will lookup the expected line endings from the ``.hgeol`` file,
82 hook will lookup the expected line endings from the ``.hgeol`` file,
83 which means you must migrate to a ``.hgeol`` file first before using
83 which means you must migrate to a ``.hgeol`` file first before using
84 the hook. ``eol.checkheadshook`` only checks heads, intermediate
84 the hook. ``eol.checkheadshook`` only checks heads, intermediate
85 invalid revisions will be pushed. To forbid them completely, use the
85 invalid revisions will be pushed. To forbid them completely, use the
86 ``eol.checkallhook`` hook. These hooks are best used as
86 ``eol.checkallhook`` hook. These hooks are best used as
87 ``pretxnchangegroup`` hooks.
87 ``pretxnchangegroup`` hooks.
88
88
89 See :hg:`help patterns` for more information about the glob patterns
89 See :hg:`help patterns` for more information about the glob patterns
90 used.
90 used.
91 """
91 """
92
92
93 from mercurial.i18n import _
93 from mercurial.i18n import _
94 from mercurial import util, config, extensions, match, error
94 from mercurial import util, config, extensions, match, error
95 import re, os
95 import re, os
96
96
97 # Matches a lone LF, i.e., one that is not part of CRLF.
97 # Matches a lone LF, i.e., one that is not part of CRLF.
98 singlelf = re.compile('(^|[^\r])\n')
98 singlelf = re.compile('(^|[^\r])\n')
99 # Matches a single EOL which can either be a CRLF where repeated CR
99 # Matches a single EOL which can either be a CRLF where repeated CR
100 # are removed or a LF. We do not care about old Machintosh files, so a
100 # are removed or a LF. We do not care about old Machintosh files, so a
101 # stray CR is an error.
101 # stray CR is an error.
102 eolre = re.compile('\r*\n')
102 eolre = re.compile('\r*\n')
103
103
104
104
105 def inconsistenteol(data):
105 def inconsistenteol(data):
106 return '\r\n' in data and singlelf.search(data)
106 return '\r\n' in data and singlelf.search(data)
107
107
108 def tolf(s, params, ui, **kwargs):
108 def tolf(s, params, ui, **kwargs):
109 """Filter to convert to LF EOLs."""
109 """Filter to convert to LF EOLs."""
110 if util.binary(s):
110 if util.binary(s):
111 return s
111 return s
112 if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
112 if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
113 return s
113 return s
114 if ui.configbool('eol', 'fix-trailing-newline', False) and s and s[-1] != '\n':
114 if ui.configbool('eol', 'fix-trailing-newline', False) and s and s[-1] != '\n':
115 s = s + '\n'
115 s = s + '\n'
116 return eolre.sub('\n', s)
116 return eolre.sub('\n', s)
117
117
118 def tocrlf(s, params, ui, **kwargs):
118 def tocrlf(s, params, ui, **kwargs):
119 """Filter to convert to CRLF EOLs."""
119 """Filter to convert to CRLF EOLs."""
120 if util.binary(s):
120 if util.binary(s):
121 return s
121 return s
122 if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
122 if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
123 return s
123 return s
124 if ui.configbool('eol', 'fix-trailing-newline', False) and s and s[-1] != '\n':
124 if ui.configbool('eol', 'fix-trailing-newline', False) and s and s[-1] != '\n':
125 s = s + '\n'
125 s = s + '\n'
126 return eolre.sub('\r\n', s)
126 return eolre.sub('\r\n', s)
127
127
128 def isbinary(s, params):
128 def isbinary(s, params):
129 """Filter to do nothing with the file."""
129 """Filter to do nothing with the file."""
130 return s
130 return s
131
131
132 filters = {
132 filters = {
133 'to-lf': tolf,
133 'to-lf': tolf,
134 'to-crlf': tocrlf,
134 'to-crlf': tocrlf,
135 'is-binary': isbinary,
135 'is-binary': isbinary,
136 # The following provide backwards compatibility with win32text
136 # The following provide backwards compatibility with win32text
137 'cleverencode:': tolf,
137 'cleverencode:': tolf,
138 'cleverdecode:': tocrlf
138 'cleverdecode:': tocrlf
139 }
139 }
140
140
141 class eolfile(object):
141 class eolfile(object):
142 def __init__(self, ui, root, data):
142 def __init__(self, ui, root, data):
143 self._decode = {'LF': 'to-lf', 'CRLF': 'to-crlf', 'BIN': 'is-binary'}
143 self._decode = {'LF': 'to-lf', 'CRLF': 'to-crlf', 'BIN': 'is-binary'}
144 self._encode = {'LF': 'to-lf', 'CRLF': 'to-crlf', 'BIN': 'is-binary'}
144 self._encode = {'LF': 'to-lf', 'CRLF': 'to-crlf', 'BIN': 'is-binary'}
145
145
146 self.cfg = config.config()
146 self.cfg = config.config()
147 # Our files should not be touched. The pattern must be
147 # Our files should not be touched. The pattern must be
148 # inserted first override a '** = native' pattern.
148 # inserted first override a '** = native' pattern.
149 self.cfg.set('patterns', '.hg*', 'BIN')
149 self.cfg.set('patterns', '.hg*', 'BIN')
150 # We can then parse the user's patterns.
150 # We can then parse the user's patterns.
151 self.cfg.parse('.hgeol', data)
151 self.cfg.parse('.hgeol', data)
152
152
153 isrepolf = self.cfg.get('repository', 'native') != 'CRLF'
153 isrepolf = self.cfg.get('repository', 'native') != 'CRLF'
154 self._encode['NATIVE'] = isrepolf and 'to-lf' or 'to-crlf'
154 self._encode['NATIVE'] = isrepolf and 'to-lf' or 'to-crlf'
155 iswdlf = ui.config('eol', 'native', os.linesep) in ('LF', '\n')
155 iswdlf = ui.config('eol', 'native', os.linesep) in ('LF', '\n')
156 self._decode['NATIVE'] = iswdlf and 'to-lf' or 'to-crlf'
156 self._decode['NATIVE'] = iswdlf and 'to-lf' or 'to-crlf'
157
157
158 include = []
158 include = []
159 exclude = []
159 exclude = []
160 for pattern, style in self.cfg.items('patterns'):
160 for pattern, style in self.cfg.items('patterns'):
161 key = style.upper()
161 key = style.upper()
162 if key == 'BIN':
162 if key == 'BIN':
163 exclude.append(pattern)
163 exclude.append(pattern)
164 else:
164 else:
165 include.append(pattern)
165 include.append(pattern)
166 # This will match the files for which we need to care
166 # This will match the files for which we need to care
167 # about inconsistent newlines.
167 # about inconsistent newlines.
168 self.match = match.match(root, '', [], include, exclude)
168 self.match = match.match(root, '', [], include, exclude)
169
169
170 def copytoui(self, ui):
170 def copytoui(self, ui):
171 for pattern, style in self.cfg.items('patterns'):
171 for pattern, style in self.cfg.items('patterns'):
172 key = style.upper()
172 key = style.upper()
173 try:
173 try:
174 ui.setconfig('decode', pattern, self._decode[key])
174 ui.setconfig('decode', pattern, self._decode[key])
175 ui.setconfig('encode', pattern, self._encode[key])
175 ui.setconfig('encode', pattern, self._encode[key])
176 except KeyError:
176 except KeyError:
177 ui.warn(_("ignoring unknown EOL style '%s' from %s\n")
177 ui.warn(_("ignoring unknown EOL style '%s' from %s\n")
178 % (style, self.cfg.source('patterns', pattern)))
178 % (style, self.cfg.source('patterns', pattern)))
179 # eol.only-consistent can be specified in ~/.hgrc or .hgeol
179 # eol.only-consistent can be specified in ~/.hgrc or .hgeol
180 for k, v in self.cfg.items('eol'):
180 for k, v in self.cfg.items('eol'):
181 ui.setconfig('eol', k, v)
181 ui.setconfig('eol', k, v)
182
182
183 def checkrev(self, repo, ctx, files):
183 def checkrev(self, repo, ctx, files):
184 failed = []
184 failed = []
185 for f in (files or ctx.files()):
185 for f in (files or ctx.files()):
186 if f not in ctx:
186 if f not in ctx:
187 continue
187 continue
188 for pattern, style in self.cfg.items('patterns'):
188 for pattern, style in self.cfg.items('patterns'):
189 if not match.match(repo.root, '', [pattern])(f):
189 if not match.match(repo.root, '', [pattern])(f):
190 continue
190 continue
191 target = self._encode[style.upper()]
191 target = self._encode[style.upper()]
192 data = ctx[f].data()
192 data = ctx[f].data()
193 if (target == "to-lf" and "\r\n" in data
193 if (target == "to-lf" and "\r\n" in data
194 or target == "to-crlf" and singlelf.search(data)):
194 or target == "to-crlf" and singlelf.search(data)):
195 failed.append((str(ctx), target, f))
195 failed.append((str(ctx), target, f))
196 break
196 break
197 return failed
197 return failed
198
198
199 def parseeol(ui, repo, nodes):
199 def parseeol(ui, repo, nodes):
200 try:
200 try:
201 for node in nodes:
201 for node in nodes:
202 try:
202 try:
203 if node is None:
203 if node is None:
204 # Cannot use workingctx.data() since it would load
204 # Cannot use workingctx.data() since it would load
205 # and cache the filters before we configure them.
205 # and cache the filters before we configure them.
206 data = repo.wfile('.hgeol').read()
206 data = repo.wfile('.hgeol').read()
207 else:
207 else:
208 data = repo[node]['.hgeol'].data()
208 data = repo[node]['.hgeol'].data()
209 return eolfile(ui, repo.root, data)
209 return eolfile(ui, repo.root, data)
210 except (IOError, LookupError):
210 except (IOError, LookupError):
211 pass
211 pass
212 except error.ParseError, inst:
212 except error.ParseError, inst:
213 ui.warn(_("warning: ignoring .hgeol file due to parse error "
213 ui.warn(_("warning: ignoring .hgeol file due to parse error "
214 "at %s: %s\n") % (inst.args[1], inst.args[0]))
214 "at %s: %s\n") % (inst.args[1], inst.args[0]))
215 return None
215 return None
216
216
217 def _checkhook(ui, repo, node, headsonly):
217 def _checkhook(ui, repo, node, headsonly):
218 # Get revisions to check and touched files at the same time
218 # Get revisions to check and touched files at the same time
219 files = set()
219 files = set()
220 revs = set()
220 revs = set()
221 for rev in xrange(repo[node].rev(), len(repo)):
221 for rev in xrange(repo[node].rev(), len(repo)):
222 revs.add(rev)
222 revs.add(rev)
223 if headsonly:
223 if headsonly:
224 ctx = repo[rev]
224 ctx = repo[rev]
225 files.update(ctx.files())
225 files.update(ctx.files())
226 for pctx in ctx.parents():
226 for pctx in ctx.parents():
227 revs.discard(pctx.rev())
227 revs.discard(pctx.rev())
228 failed = []
228 failed = []
229 for rev in revs:
229 for rev in revs:
230 ctx = repo[rev]
230 ctx = repo[rev]
231 eol = parseeol(ui, repo, [ctx.node()])
231 eol = parseeol(ui, repo, [ctx.node()])
232 if eol:
232 if eol:
233 failed.extend(eol.checkrev(repo, ctx, files))
233 failed.extend(eol.checkrev(repo, ctx, files))
234
234
235 if failed:
235 if failed:
236 eols = {'to-lf': 'CRLF', 'to-crlf': 'LF'}
236 eols = {'to-lf': 'CRLF', 'to-crlf': 'LF'}
237 msgs = []
237 msgs = []
238 for node, target, f in failed:
238 for node, target, f in failed:
239 msgs.append(_(" %s in %s should not have %s line endings") %
239 msgs.append(_(" %s in %s should not have %s line endings") %
240 (f, node, eols[target]))
240 (f, node, eols[target]))
241 raise util.Abort(_("end-of-line check failed:\n") + "\n".join(msgs))
241 raise util.Abort(_("end-of-line check failed:\n") + "\n".join(msgs))
242
242
243 def checkallhook(ui, repo, node, hooktype, **kwargs):
243 def checkallhook(ui, repo, node, hooktype, **kwargs):
244 """verify that files have expected EOLs"""
244 """verify that files have expected EOLs"""
245 _checkhook(ui, repo, node, False)
245 _checkhook(ui, repo, node, False)
246
246
247 def checkheadshook(ui, repo, node, hooktype, **kwargs):
247 def checkheadshook(ui, repo, node, hooktype, **kwargs):
248 """verify that files have expected EOLs"""
248 """verify that files have expected EOLs"""
249 _checkhook(ui, repo, node, True)
249 _checkhook(ui, repo, node, True)
250
250
251 # "checkheadshook" used to be called "hook"
251 # "checkheadshook" used to be called "hook"
252 hook = checkheadshook
252 hook = checkheadshook
253
253
254 def preupdate(ui, repo, hooktype, parent1, parent2):
254 def preupdate(ui, repo, hooktype, parent1, parent2):
255 #print "preupdate for %s: %s -> %s" % (repo.root, parent1, parent2)
255 #print "preupdate for %s: %s -> %s" % (repo.root, parent1, parent2)
256 repo.loadeol([parent1])
256 repo.loadeol([parent1])
257 return False
257 return False
258
258
259 def uisetup(ui):
259 def uisetup(ui):
260 ui.setconfig('hooks', 'preupdate.eol', preupdate)
260 ui.setconfig('hooks', 'preupdate.eol', preupdate)
261
261
262 def extsetup(ui):
262 def extsetup(ui):
263 try:
263 try:
264 extensions.find('win32text')
264 extensions.find('win32text')
265 ui.warn(_("the eol extension is incompatible with the "
265 ui.warn(_("the eol extension is incompatible with the "
266 "win32text extension\n"))
266 "win32text extension\n"))
267 except KeyError:
267 except KeyError:
268 pass
268 pass
269
269
270
270
271 def reposetup(ui, repo):
271 def reposetup(ui, repo):
272 uisetup(repo.ui)
272 uisetup(repo.ui)
273 #print "reposetup for", repo.root
273 #print "reposetup for", repo.root
274
274
275 if not repo.local():
275 if not repo.local():
276 return
276 return
277 for name, fn in filters.iteritems():
277 for name, fn in filters.iteritems():
278 repo.adddatafilter(name, fn)
278 repo.adddatafilter(name, fn)
279
279
280 ui.setconfig('patch', 'eol', 'auto')
280 ui.setconfig('patch', 'eol', 'auto')
281
281
282 class eolrepo(repo.__class__):
282 class eolrepo(repo.__class__):
283
283
284 def loadeol(self, nodes):
284 def loadeol(self, nodes):
285 eol = parseeol(self.ui, self, nodes)
285 eol = parseeol(self.ui, self, nodes)
286 if eol is None:
286 if eol is None:
287 return None
287 return None
288 eol.copytoui(self.ui)
288 eol.copytoui(self.ui)
289 return eol.match
289 return eol.match
290
290
291 def _hgcleardirstate(self):
291 def _hgcleardirstate(self):
292 self._eolfile = self.loadeol([None, 'tip'])
292 self._eolfile = self.loadeol([None, 'tip'])
293 if not self._eolfile:
293 if not self._eolfile:
294 self._eolfile = util.never
294 self._eolfile = util.never
295 return
295 return
296
296
297 try:
297 try:
298 cachemtime = os.path.getmtime(self.join("eol.cache"))
298 cachemtime = os.path.getmtime(self.join("eol.cache"))
299 except OSError:
299 except OSError:
300 cachemtime = 0
300 cachemtime = 0
301
301
302 try:
302 try:
303 eolmtime = os.path.getmtime(self.wjoin(".hgeol"))
303 eolmtime = os.path.getmtime(self.wjoin(".hgeol"))
304 except OSError:
304 except OSError:
305 eolmtime = 0
305 eolmtime = 0
306
306
307 if eolmtime > cachemtime:
307 if eolmtime > cachemtime:
308 ui.debug("eol: detected change in .hgeol\n")
308 ui.debug("eol: detected change in .hgeol\n")
309 wlock = None
309 wlock = None
310 try:
310 try:
311 wlock = self.wlock()
311 wlock = self.wlock()
312 for f in self.dirstate:
312 for f in self.dirstate:
313 if self.dirstate[f] == 'n':
313 if self.dirstate[f] == 'n':
314 # all normal files need to be looked at
314 # all normal files need to be looked at
315 # again since the new .hgeol file might no
315 # again since the new .hgeol file might no
316 # longer match a file it matched before
316 # longer match a file it matched before
317 self.dirstate.normallookup(f)
317 self.dirstate.normallookup(f)
318 # Touch the cache to update mtime.
318 # Touch the cache to update mtime.
319 self.opener("eol.cache", "w").close()
319 self.opener("eol.cache", "w").close()
320 wlock.release()
320 wlock.release()
321 except error.LockUnavailable:
321 except error.LockUnavailable:
322 # If we cannot lock the repository and clear the
322 # If we cannot lock the repository and clear the
323 # dirstate, then a commit might not see all files
323 # dirstate, then a commit might not see all files
324 # as modified. But if we cannot lock the
324 # as modified. But if we cannot lock the
325 # repository, then we can also not make a commit,
325 # repository, then we can also not make a commit,
326 # so ignore the error.
326 # so ignore the error.
327 pass
327 pass
328
328
329 def commitctx(self, ctx, error=False):
329 def commitctx(self, ctx, error=False):
330 for f in sorted(ctx.added() + ctx.modified()):
330 for f in sorted(ctx.added() + ctx.modified()):
331 if not self._eolfile(f):
331 if not self._eolfile(f):
332 continue
332 continue
333 data = ctx[f].data()
333 data = ctx[f].data()
334 if util.binary(data):
334 if util.binary(data):
335 # We should not abort here, since the user should
335 # We should not abort here, since the user should
336 # be able to say "** = native" to automatically
336 # be able to say "** = native" to automatically
337 # have all non-binary files taken care of.
337 # have all non-binary files taken care of.
338 continue
338 continue
339 if inconsistenteol(data):
339 if inconsistenteol(data):
340 raise util.Abort(_("inconsistent newline style "
340 raise util.Abort(_("inconsistent newline style "
341 "in %s\n" % f))
341 "in %s\n" % f))
342 return super(eolrepo, self).commitctx(ctx, error)
342 return super(eolrepo, self).commitctx(ctx, error)
343 repo.__class__ = eolrepo
343 repo.__class__ = eolrepo
344 repo._hgcleardirstate()
344 repo._hgcleardirstate()
General Comments 0
You need to be logged in to leave comments. Login now