# HG changeset patch # User Patrick Mezard # Date 2012-04-29 09:19:51 # Node ID aef3d0d4631c6c5fcfe4b594473701fc2f2ee006 # Parent ae6dddffe4f1b44850ac467a814719c6896df793 patch: clarify binary hunk parsing loop diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1040,12 +1040,13 @@ class binhunk(object): hunk.append(l) return l.rstrip('\r\n') - line = getline(lr, self.hunk) - while line and not line.startswith('literal '): + while True: line = getline(lr, self.hunk) - if not line: - raise PatchError(_('could not extract "%s" binary data') - % self._fname) + if not line: + raise PatchError(_('could not extract "%s" binary data') + % self._fname) + if line.startswith('literal '): + break size = int(line[8:].rstrip()) dec = [] line = getline(lr, self.hunk)