##// END OF EJS Templates
eol: don't refer to a random name-captured ui object...
Bryan O'Sullivan -
r17955:4ae21a75 default
parent child Browse files
Show More
@@ -1,349 +1,349 b''
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 testedwith = 'internal'
97 testedwith = 'internal'
98
98
99 # Matches a lone LF, i.e., one that is not part of CRLF.
99 # Matches a lone LF, i.e., one that is not part of CRLF.
100 singlelf = re.compile('(^|[^\r])\n')
100 singlelf = re.compile('(^|[^\r])\n')
101 # Matches a single EOL which can either be a CRLF where repeated CR
101 # Matches a single EOL which can either be a CRLF where repeated CR
102 # are removed or a LF. We do not care about old Macintosh files, so a
102 # are removed or a LF. We do not care about old Macintosh files, so a
103 # stray CR is an error.
103 # stray CR is an error.
104 eolre = re.compile('\r*\n')
104 eolre = re.compile('\r*\n')
105
105
106
106
107 def inconsistenteol(data):
107 def inconsistenteol(data):
108 return '\r\n' in data and singlelf.search(data)
108 return '\r\n' in data and singlelf.search(data)
109
109
110 def tolf(s, params, ui, **kwargs):
110 def tolf(s, params, ui, **kwargs):
111 """Filter to convert to LF EOLs."""
111 """Filter to convert to LF EOLs."""
112 if util.binary(s):
112 if util.binary(s):
113 return s
113 return s
114 if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
114 if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
115 return s
115 return s
116 if (ui.configbool('eol', 'fix-trailing-newline', False)
116 if (ui.configbool('eol', 'fix-trailing-newline', False)
117 and s and s[-1] != '\n'):
117 and s and s[-1] != '\n'):
118 s = s + '\n'
118 s = s + '\n'
119 return eolre.sub('\n', s)
119 return eolre.sub('\n', s)
120
120
121 def tocrlf(s, params, ui, **kwargs):
121 def tocrlf(s, params, ui, **kwargs):
122 """Filter to convert to CRLF EOLs."""
122 """Filter to convert to CRLF EOLs."""
123 if util.binary(s):
123 if util.binary(s):
124 return s
124 return s
125 if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
125 if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
126 return s
126 return s
127 if (ui.configbool('eol', 'fix-trailing-newline', False)
127 if (ui.configbool('eol', 'fix-trailing-newline', False)
128 and s and s[-1] != '\n'):
128 and s and s[-1] != '\n'):
129 s = s + '\n'
129 s = s + '\n'
130 return eolre.sub('\r\n', s)
130 return eolre.sub('\r\n', s)
131
131
132 def isbinary(s, params):
132 def isbinary(s, params):
133 """Filter to do nothing with the file."""
133 """Filter to do nothing with the file."""
134 return s
134 return s
135
135
136 filters = {
136 filters = {
137 'to-lf': tolf,
137 'to-lf': tolf,
138 'to-crlf': tocrlf,
138 'to-crlf': tocrlf,
139 'is-binary': isbinary,
139 'is-binary': isbinary,
140 # The following provide backwards compatibility with win32text
140 # The following provide backwards compatibility with win32text
141 'cleverencode:': tolf,
141 'cleverencode:': tolf,
142 'cleverdecode:': tocrlf
142 'cleverdecode:': tocrlf
143 }
143 }
144
144
145 class eolfile(object):
145 class eolfile(object):
146 def __init__(self, ui, root, data):
146 def __init__(self, ui, root, data):
147 self._decode = {'LF': 'to-lf', 'CRLF': 'to-crlf', 'BIN': 'is-binary'}
147 self._decode = {'LF': 'to-lf', 'CRLF': 'to-crlf', 'BIN': 'is-binary'}
148 self._encode = {'LF': 'to-lf', 'CRLF': 'to-crlf', 'BIN': 'is-binary'}
148 self._encode = {'LF': 'to-lf', 'CRLF': 'to-crlf', 'BIN': 'is-binary'}
149
149
150 self.cfg = config.config()
150 self.cfg = config.config()
151 # Our files should not be touched. The pattern must be
151 # Our files should not be touched. The pattern must be
152 # inserted first override a '** = native' pattern.
152 # inserted first override a '** = native' pattern.
153 self.cfg.set('patterns', '.hg*', 'BIN')
153 self.cfg.set('patterns', '.hg*', 'BIN')
154 # We can then parse the user's patterns.
154 # We can then parse the user's patterns.
155 self.cfg.parse('.hgeol', data)
155 self.cfg.parse('.hgeol', data)
156
156
157 isrepolf = self.cfg.get('repository', 'native') != 'CRLF'
157 isrepolf = self.cfg.get('repository', 'native') != 'CRLF'
158 self._encode['NATIVE'] = isrepolf and 'to-lf' or 'to-crlf'
158 self._encode['NATIVE'] = isrepolf and 'to-lf' or 'to-crlf'
159 iswdlf = ui.config('eol', 'native', os.linesep) in ('LF', '\n')
159 iswdlf = ui.config('eol', 'native', os.linesep) in ('LF', '\n')
160 self._decode['NATIVE'] = iswdlf and 'to-lf' or 'to-crlf'
160 self._decode['NATIVE'] = iswdlf and 'to-lf' or 'to-crlf'
161
161
162 include = []
162 include = []
163 exclude = []
163 exclude = []
164 for pattern, style in self.cfg.items('patterns'):
164 for pattern, style in self.cfg.items('patterns'):
165 key = style.upper()
165 key = style.upper()
166 if key == 'BIN':
166 if key == 'BIN':
167 exclude.append(pattern)
167 exclude.append(pattern)
168 else:
168 else:
169 include.append(pattern)
169 include.append(pattern)
170 # This will match the files for which we need to care
170 # This will match the files for which we need to care
171 # about inconsistent newlines.
171 # about inconsistent newlines.
172 self.match = match.match(root, '', [], include, exclude)
172 self.match = match.match(root, '', [], include, exclude)
173
173
174 def copytoui(self, ui):
174 def copytoui(self, ui):
175 for pattern, style in self.cfg.items('patterns'):
175 for pattern, style in self.cfg.items('patterns'):
176 key = style.upper()
176 key = style.upper()
177 try:
177 try:
178 ui.setconfig('decode', pattern, self._decode[key])
178 ui.setconfig('decode', pattern, self._decode[key])
179 ui.setconfig('encode', pattern, self._encode[key])
179 ui.setconfig('encode', pattern, self._encode[key])
180 except KeyError:
180 except KeyError:
181 ui.warn(_("ignoring unknown EOL style '%s' from %s\n")
181 ui.warn(_("ignoring unknown EOL style '%s' from %s\n")
182 % (style, self.cfg.source('patterns', pattern)))
182 % (style, self.cfg.source('patterns', pattern)))
183 # eol.only-consistent can be specified in ~/.hgrc or .hgeol
183 # eol.only-consistent can be specified in ~/.hgrc or .hgeol
184 for k, v in self.cfg.items('eol'):
184 for k, v in self.cfg.items('eol'):
185 ui.setconfig('eol', k, v)
185 ui.setconfig('eol', k, v)
186
186
187 def checkrev(self, repo, ctx, files):
187 def checkrev(self, repo, ctx, files):
188 failed = []
188 failed = []
189 for f in (files or ctx.files()):
189 for f in (files or ctx.files()):
190 if f not in ctx:
190 if f not in ctx:
191 continue
191 continue
192 for pattern, style in self.cfg.items('patterns'):
192 for pattern, style in self.cfg.items('patterns'):
193 if not match.match(repo.root, '', [pattern])(f):
193 if not match.match(repo.root, '', [pattern])(f):
194 continue
194 continue
195 target = self._encode[style.upper()]
195 target = self._encode[style.upper()]
196 data = ctx[f].data()
196 data = ctx[f].data()
197 if (target == "to-lf" and "\r\n" in data
197 if (target == "to-lf" and "\r\n" in data
198 or target == "to-crlf" and singlelf.search(data)):
198 or target == "to-crlf" and singlelf.search(data)):
199 failed.append((str(ctx), target, f))
199 failed.append((str(ctx), target, f))
200 break
200 break
201 return failed
201 return failed
202
202
203 def parseeol(ui, repo, nodes):
203 def parseeol(ui, repo, nodes):
204 try:
204 try:
205 for node in nodes:
205 for node in nodes:
206 try:
206 try:
207 if node is None:
207 if node is None:
208 # Cannot use workingctx.data() since it would load
208 # Cannot use workingctx.data() since it would load
209 # and cache the filters before we configure them.
209 # and cache the filters before we configure them.
210 data = repo.wfile('.hgeol').read()
210 data = repo.wfile('.hgeol').read()
211 else:
211 else:
212 data = repo[node]['.hgeol'].data()
212 data = repo[node]['.hgeol'].data()
213 return eolfile(ui, repo.root, data)
213 return eolfile(ui, repo.root, data)
214 except (IOError, LookupError):
214 except (IOError, LookupError):
215 pass
215 pass
216 except error.ParseError, inst:
216 except error.ParseError, inst:
217 ui.warn(_("warning: ignoring .hgeol file due to parse error "
217 ui.warn(_("warning: ignoring .hgeol file due to parse error "
218 "at %s: %s\n") % (inst.args[1], inst.args[0]))
218 "at %s: %s\n") % (inst.args[1], inst.args[0]))
219 return None
219 return None
220
220
221 def _checkhook(ui, repo, node, headsonly):
221 def _checkhook(ui, repo, node, headsonly):
222 # Get revisions to check and touched files at the same time
222 # Get revisions to check and touched files at the same time
223 files = set()
223 files = set()
224 revs = set()
224 revs = set()
225 for rev in xrange(repo[node].rev(), len(repo)):
225 for rev in xrange(repo[node].rev(), len(repo)):
226 revs.add(rev)
226 revs.add(rev)
227 if headsonly:
227 if headsonly:
228 ctx = repo[rev]
228 ctx = repo[rev]
229 files.update(ctx.files())
229 files.update(ctx.files())
230 for pctx in ctx.parents():
230 for pctx in ctx.parents():
231 revs.discard(pctx.rev())
231 revs.discard(pctx.rev())
232 failed = []
232 failed = []
233 for rev in revs:
233 for rev in revs:
234 ctx = repo[rev]
234 ctx = repo[rev]
235 eol = parseeol(ui, repo, [ctx.node()])
235 eol = parseeol(ui, repo, [ctx.node()])
236 if eol:
236 if eol:
237 failed.extend(eol.checkrev(repo, ctx, files))
237 failed.extend(eol.checkrev(repo, ctx, files))
238
238
239 if failed:
239 if failed:
240 eols = {'to-lf': 'CRLF', 'to-crlf': 'LF'}
240 eols = {'to-lf': 'CRLF', 'to-crlf': 'LF'}
241 msgs = []
241 msgs = []
242 for node, target, f in failed:
242 for node, target, f in failed:
243 msgs.append(_(" %s in %s should not have %s line endings") %
243 msgs.append(_(" %s in %s should not have %s line endings") %
244 (f, node, eols[target]))
244 (f, node, eols[target]))
245 raise util.Abort(_("end-of-line check failed:\n") + "\n".join(msgs))
245 raise util.Abort(_("end-of-line check failed:\n") + "\n".join(msgs))
246
246
247 def checkallhook(ui, repo, node, hooktype, **kwargs):
247 def checkallhook(ui, repo, node, hooktype, **kwargs):
248 """verify that files have expected EOLs"""
248 """verify that files have expected EOLs"""
249 _checkhook(ui, repo, node, False)
249 _checkhook(ui, repo, node, False)
250
250
251 def checkheadshook(ui, repo, node, hooktype, **kwargs):
251 def checkheadshook(ui, repo, node, hooktype, **kwargs):
252 """verify that files have expected EOLs"""
252 """verify that files have expected EOLs"""
253 _checkhook(ui, repo, node, True)
253 _checkhook(ui, repo, node, True)
254
254
255 # "checkheadshook" used to be called "hook"
255 # "checkheadshook" used to be called "hook"
256 hook = checkheadshook
256 hook = checkheadshook
257
257
258 def preupdate(ui, repo, hooktype, parent1, parent2):
258 def preupdate(ui, repo, hooktype, parent1, parent2):
259 repo.loadeol([parent1])
259 repo.loadeol([parent1])
260 return False
260 return False
261
261
262 def uisetup(ui):
262 def uisetup(ui):
263 ui.setconfig('hooks', 'preupdate.eol', preupdate)
263 ui.setconfig('hooks', 'preupdate.eol', preupdate)
264
264
265 def extsetup(ui):
265 def extsetup(ui):
266 try:
266 try:
267 extensions.find('win32text')
267 extensions.find('win32text')
268 ui.warn(_("the eol extension is incompatible with the "
268 ui.warn(_("the eol extension is incompatible with the "
269 "win32text extension\n"))
269 "win32text extension\n"))
270 except KeyError:
270 except KeyError:
271 pass
271 pass
272
272
273
273
274 def reposetup(ui, repo):
274 def reposetup(ui, repo):
275 uisetup(repo.ui)
275 uisetup(repo.ui)
276
276
277 if not repo.local():
277 if not repo.local():
278 return
278 return
279 for name, fn in filters.iteritems():
279 for name, fn in filters.iteritems():
280 repo.adddatafilter(name, fn)
280 repo.adddatafilter(name, fn)
281
281
282 ui.setconfig('patch', 'eol', 'auto')
282 ui.setconfig('patch', 'eol', 'auto')
283
283
284 class eolrepo(repo.__class__):
284 class eolrepo(repo.__class__):
285
285
286 def loadeol(self, nodes):
286 def loadeol(self, nodes):
287 eol = parseeol(self.ui, self, nodes)
287 eol = parseeol(self.ui, self, nodes)
288 if eol is None:
288 if eol is None:
289 return None
289 return None
290 eol.copytoui(self.ui)
290 eol.copytoui(self.ui)
291 return eol.match
291 return eol.match
292
292
293 def _hgcleardirstate(self):
293 def _hgcleardirstate(self):
294 self._eolfile = self.loadeol([None, 'tip'])
294 self._eolfile = self.loadeol([None, 'tip'])
295 if not self._eolfile:
295 if not self._eolfile:
296 self._eolfile = util.never
296 self._eolfile = util.never
297 return
297 return
298
298
299 try:
299 try:
300 cachemtime = os.path.getmtime(self.join("eol.cache"))
300 cachemtime = os.path.getmtime(self.join("eol.cache"))
301 except OSError:
301 except OSError:
302 cachemtime = 0
302 cachemtime = 0
303
303
304 try:
304 try:
305 eolmtime = os.path.getmtime(self.wjoin(".hgeol"))
305 eolmtime = os.path.getmtime(self.wjoin(".hgeol"))
306 except OSError:
306 except OSError:
307 eolmtime = 0
307 eolmtime = 0
308
308
309 if eolmtime > cachemtime:
309 if eolmtime > cachemtime:
310 ui.debug("eol: detected change in .hgeol\n")
310 self.ui.debug("eol: detected change in .hgeol\n")
311 wlock = None
311 wlock = None
312 try:
312 try:
313 wlock = self.wlock()
313 wlock = self.wlock()
314 for f in self.dirstate:
314 for f in self.dirstate:
315 if self.dirstate[f] == 'n':
315 if self.dirstate[f] == 'n':
316 # all normal files need to be looked at
316 # all normal files need to be looked at
317 # again since the new .hgeol file might no
317 # again since the new .hgeol file might no
318 # longer match a file it matched before
318 # longer match a file it matched before
319 self.dirstate.normallookup(f)
319 self.dirstate.normallookup(f)
320 # Create or touch the cache to update mtime
320 # Create or touch the cache to update mtime
321 self.opener("eol.cache", "w").close()
321 self.opener("eol.cache", "w").close()
322 wlock.release()
322 wlock.release()
323 except error.LockUnavailable:
323 except error.LockUnavailable:
324 # If we cannot lock the repository and clear the
324 # If we cannot lock the repository and clear the
325 # dirstate, then a commit might not see all files
325 # dirstate, then a commit might not see all files
326 # as modified. But if we cannot lock the
326 # as modified. But if we cannot lock the
327 # repository, then we can also not make a commit,
327 # repository, then we can also not make a commit,
328 # so ignore the error.
328 # so ignore the error.
329 pass
329 pass
330
330
331 def commitctx(self, ctx, error=False):
331 def commitctx(self, ctx, error=False):
332 for f in sorted(ctx.added() + ctx.modified()):
332 for f in sorted(ctx.added() + ctx.modified()):
333 if not self._eolfile(f):
333 if not self._eolfile(f):
334 continue
334 continue
335 try:
335 try:
336 data = ctx[f].data()
336 data = ctx[f].data()
337 except IOError:
337 except IOError:
338 continue
338 continue
339 if util.binary(data):
339 if util.binary(data):
340 # We should not abort here, since the user should
340 # We should not abort here, since the user should
341 # be able to say "** = native" to automatically
341 # be able to say "** = native" to automatically
342 # have all non-binary files taken care of.
342 # have all non-binary files taken care of.
343 continue
343 continue
344 if inconsistenteol(data):
344 if inconsistenteol(data):
345 raise util.Abort(_("inconsistent newline style "
345 raise util.Abort(_("inconsistent newline style "
346 "in %s\n" % f))
346 "in %s\n" % f))
347 return super(eolrepo, self).commitctx(ctx, error)
347 return super(eolrepo, self).commitctx(ctx, error)
348 repo.__class__ = eolrepo
348 repo.__class__ = eolrepo
349 repo._hgcleardirstate()
349 repo._hgcleardirstate()
General Comments 0
You need to be logged in to leave comments. Login now