New patch against lp:bzr (looks the same for 2.0.x)  that gives
parse_patches() and the necessary functions that it calls an allow_dirty
parameter.  allow_dirty turns on the new behaviour of allowing junk at
the beginning and end of individual patches within the patch file.

The default is to use the current behaviour.  I'll have a patch for bzr-
gtk (diff.py and bzr-handle-patch) to set allow_dirty next.

Looking at the code in iter_file_patch() I note one thing.  The current
algorithm allows some non-diff output anywhere if it has special
characters in front.  You might want to change that as it accepts
patches like this:

"""
=== Hey bro! I'm pretendin' to be a dumb patch
*** That takes advantage of iter_file_patch()'s
# algorithm to parse ...
--- bzrlib/patches.py>--2009-11-03 15:45:56 +0000
+++ bzrlib/patches.py>--2010-01-23 17:57:32 +0000
@@ -250,7 +250,13 @@
         return shift


-def iter_hunks(iter_lines):
===
=== ... something that isn't even a valid patch!
# Yep, I can drop text beginning with any of the allowed special chars
# in the patch itself!
===
===
+def iter_hunks(iter_lines, allow_dirty=False):
+    '''
+    :arg iter_lines: iterable of lines to parse for hunks
+    :kwarg allow_dirty: If True, when we encounter something that is not
+        a hunk header when we're looking for one, assume the rest of the lines
+        are not part of the patch (comments or other junk).  Default False
+    '''
     hunk = None
     for line in iter_lines:
         if line == "\n":
"""

** Attachment added: "bzr-allow-dirty.patch"
   http://launchpadlibrarian.net/38308476/bzr-allow-dirty.patch

-- 
bzr-handle-patch doesn't like patch files containing "diff" lines before each 
patch
https://bugs.launchpad.net/bugs/502076
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to