[PATCH default] patch: clarify binary hunk parsing loop

Patrick Mezard patrick at mezard.eu
Wed May 2 05:00:13 CDT 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1335691191 -7200
# Branch stable
# Node ID 7db0c15bbb5ca9e646974030d431f13f78843177
# Parent  979b1b7340fba32b4d7f499e6d89093758147520
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 @@
             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)


More information about the Mercurial-devel mailing list