comparison hgext/eol.py @ 13505:9b617c56eb65 stable

eol: do not abort on parse error Handle parse errors in the .hgeol similarly to how parse errors in the .hgtags file are handled: by issuing a warning. This allows the user to revert the file using 'hg revert' or 'hg update -C'.
author Martin Geisler <mg@aragost.com>
date Mon, 28 Feb 2011 15:46:48 +0100
parents c0f252757b41
children b30a488762e1
comparison
equal deleted inserted replaced
13504:85840c4ae2ad 13505:9b617c56eb65
150 break 150 break
151 151
152 152
153 def preupdate(ui, repo, hooktype, parent1, parent2): 153 def preupdate(ui, repo, hooktype, parent1, parent2):
154 #print "preupdate for %s: %s -> %s" % (repo.root, parent1, parent2) 154 #print "preupdate for %s: %s -> %s" % (repo.root, parent1, parent2)
155 repo.readhgeol(parent1) 155 try:
156 repo.readhgeol(parent1)
157 except error.ParseError, inst:
158 ui.warn(_("warning: ignoring .hgeol file due to parse error "
159 "at %s: %s\n") % (inst.args[1], inst.args[0]))
156 return False 160 return False
157 161
158 def uisetup(ui): 162 def uisetup(ui):
159 ui.setconfig('hooks', 'preupdate.eol', preupdate) 163 ui.setconfig('hooks', 'preupdate.eol', preupdate)
160 164
231 # This will match the files for which we need to care 235 # This will match the files for which we need to care
232 # about inconsistent newlines. 236 # about inconsistent newlines.
233 return match.match(self.root, '', [], include, exclude) 237 return match.match(self.root, '', [], include, exclude)
234 238
235 def _hgcleardirstate(self): 239 def _hgcleardirstate(self):
236 self._eolfile = self.readhgeol() or self.readhgeol('tip') 240 try:
241 self._eolfile = self.readhgeol() or self.readhgeol('tip')
242 except error.ParseError, inst:
243 ui.warn(_("warning: ignoring .hgeol file due to parse error "
244 "at %s: %s\n") % (inst.args[1], inst.args[0]))
245 self._eolfile = None
237 246
238 if not self._eolfile: 247 if not self._eolfile:
239 self._eolfile = util.never 248 self._eolfile = util.never
240 return 249 return
241 250