# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1278618414 -7200 # Node ID 37b2adc64fb3605089ba22582121e139eec59629 # Parent eea224fa1156a26c23f08cf8b10739d9b5e98ddf 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. diff --git a/hgsubversion/editor.py b/hgsubversion/editor.py --- a/hgsubversion/editor.py +++ b/hgsubversion/editor.py @@ -1,3 +1,4 @@ +import errno import cStringIO import sys @@ -330,10 +331,18 @@ class HgEditor(svnwrap.Editor): base = '' if not self.meta.is_path_valid(self.current.file): return lambda x: None - assert self.current.file not in self.current.deleted, ( - 'Cannot apply_textdelta to a deleted file: %s' % self.current.file) - assert (self.current.file in self.current.files - or self.current.file in self.current.missing), '%s not found' % self.current.file + + if self.current.file in self.current.deleted: + msg = ('cannot apply textdelta to %s: file is deleted' + % self.current.file) + raise IOError(errno.ENOENT, msg) + + if (self.current.file not in self.current.files and + self.current.file not in self.current.missing): + msg = ('cannot apply textdelta to %s: file not found' + % self.current.file) + raise IOError(errno.ENOENT, msg) + if self.current.file in self.current.missing: return lambda x: None base = self.current.files[self.current.file]