##// END OF EJS Templates
eol: extract parsing error handling in parseeol()
Patrick Mezard -
r13614:40d0cf79 default
parent child Browse files
Show More
@@ -166,17 +166,23 b' class eolfile(object):'
166 ui.warn(_("ignoring unknown EOL style '%s' from %s\n")
166 ui.warn(_("ignoring unknown EOL style '%s' from %s\n")
167 % (style, self.cfg.source('patterns', pattern)))
167 % (style, self.cfg.source('patterns', pattern)))
168
168
169 def parseeol(ui, repo, node=None):
169 def parseeol(ui, repo, nodes):
170 try:
170 try:
171 if node is None:
171 for node in nodes:
172 # Cannot use workingctx.data() since it would load
172 try:
173 # and cache the filters before we configure them.
173 if node is None:
174 data = repo.wfile('.hgeol').read()
174 # Cannot use workingctx.data() since it would load
175 else:
175 # and cache the filters before we configure them.
176 data = repo[node]['.hgeol'].data()
176 data = repo.wfile('.hgeol').read()
177 return eolfile(ui, repo.root, data)
177 else:
178 except (IOError, LookupError):
178 data = repo[node]['.hgeol'].data()
179 return None
179 return eolfile(ui, repo.root, data)
180 except (IOError, LookupError):
181 pass
182 except error.ParseError, inst:
183 ui.warn(_("warning: ignoring .hgeol file due to parse error "
184 "at %s: %s\n") % (inst.args[1], inst.args[0]))
185 return None
180
186
181 def hook(ui, repo, node, hooktype, **kwargs):
187 def hook(ui, repo, node, hooktype, **kwargs):
182 """verify that files have expected EOLs"""
188 """verify that files have expected EOLs"""
@@ -202,11 +208,7 b' def hook(ui, repo, node, hooktype, **kwa'
202
208
203 def preupdate(ui, repo, hooktype, parent1, parent2):
209 def preupdate(ui, repo, hooktype, parent1, parent2):
204 #print "preupdate for %s: %s -> %s" % (repo.root, parent1, parent2)
210 #print "preupdate for %s: %s -> %s" % (repo.root, parent1, parent2)
205 try:
211 repo.loadeol([parent1])
206 repo.loadeol(parent1)
207 except error.ParseError, inst:
208 ui.warn(_("warning: ignoring .hgeol file due to parse error "
209 "at %s: %s\n") % (inst.args[1], inst.args[0]))
210 return False
212 return False
211
213
212 def uisetup(ui):
214 def uisetup(ui):
@@ -234,21 +236,15 b' def reposetup(ui, repo):'
234
236
235 class eolrepo(repo.__class__):
237 class eolrepo(repo.__class__):
236
238
237 def loadeol(self, node=None):
239 def loadeol(self, nodes):
238 eol = parseeol(self.ui, self, node)
240 eol = parseeol(self.ui, self, nodes)
239 if eol is None:
241 if eol is None:
240 return None
242 return None
241 eol.setfilters(self.ui)
243 eol.setfilters(self.ui)
242 return eol.match
244 return eol.match
243
245
244 def _hgcleardirstate(self):
246 def _hgcleardirstate(self):
245 try:
247 self._eolfile = self.loadeol([None, 'tip'])
246 self._eolfile = (self.loadeol() or self.loadeol('tip'))
247 except error.ParseError, inst:
248 ui.warn(_("warning: ignoring .hgeol file due to parse error "
249 "at %s: %s\n") % (inst.args[1], inst.args[0]))
250 self._eolfile = None
251
252 if not self._eolfile:
248 if not self._eolfile:
253 self._eolfile = util.never
249 self._eolfile = util.never
254 return
250 return
General Comments 0
You need to be logged in to leave comments. Login now