comparison hgsubversion/editor.py @ 633:37b2adc64fb3

editor: convert two assertions in apply_textdelta() into raising an IOError I noticed these in the traceback filed as issue2261 in the Mercurial bug tracker. We should always fail in cases where the Subversion server gives us invalid data, so using assertions is wrong.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Thu, 08 Jul 2010 21:46:54 +0200
parents 0fe490ce2fbb
children 32089d080ff8
comparison
equal deleted inserted replaced
632:eea224fa1156 633:37b2adc64fb3
1 import errno
1 import cStringIO 2 import cStringIO
2 import sys 3 import sys
3 4
4 from mercurial import util as hgutil 5 from mercurial import util as hgutil
5 from mercurial import revlog 6 from mercurial import revlog
328 # 2) Missing a base text (bail quick since we have to fetch a full plaintext) 329 # 2) Missing a base text (bail quick since we have to fetch a full plaintext)
329 # 3) Has a base text in self.current.files, apply deltas 330 # 3) Has a base text in self.current.files, apply deltas
330 base = '' 331 base = ''
331 if not self.meta.is_path_valid(self.current.file): 332 if not self.meta.is_path_valid(self.current.file):
332 return lambda x: None 333 return lambda x: None
333 assert self.current.file not in self.current.deleted, ( 334
334 'Cannot apply_textdelta to a deleted file: %s' % self.current.file) 335 if self.current.file in self.current.deleted:
335 assert (self.current.file in self.current.files 336 msg = ('cannot apply textdelta to %s: file is deleted'
336 or self.current.file in self.current.missing), '%s not found' % self.current.file 337 % self.current.file)
338 raise IOError(errno.ENOENT, msg)
339
340 if (self.current.file not in self.current.files and
341 self.current.file not in self.current.missing):
342 msg = ('cannot apply textdelta to %s: file not found'
343 % self.current.file)
344 raise IOError(errno.ENOENT, msg)
345
337 if self.current.file in self.current.missing: 346 if self.current.file in self.current.missing:
338 return lambda x: None 347 return lambda x: None
339 base = self.current.files[self.current.file] 348 base = self.current.files[self.current.file]
340 target = cStringIO.StringIO() 349 target = cStringIO.StringIO()
341 self.stream = target 350 self.stream = target