bzrlib.patches should provide a means of accessing file modified patch headers

Bug #1400567 reported by Kit Randel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Kit Randel
Launchpad itself
Fix Released
Undecided
Kit Randel

Bug Description

bzrlib.patches.parse_patch() currently ignores modified file headers in patches e.g.

    "=== modified file 'foo/bar.py'"
    "--- foo/bar.py 19:00:00.000000000 -0500"
    "+++ foo/bar.py 15:53:57.000000000 -0400"
    "@@ -0,0 +1,2 @@"
    etc...

It would be valuable if these headers could be parsed, and made accessible from a Patch.get_modified_header() method, similar to the existing method for returning patch headers Patch.get_header().

== Motivation ==

Launchpad currently provides emails to users when inline diff comments are made in the context of a branch merge proposal. These emails tend to be very verbose (https://bugs.launchpad.net/launchpad/+bug/1334577) and a branch has been provided to try to address this (https://code.launchpad.net/~blr/launchpad/bug-1334577-verbose-diff/+merge/243751), by discarding patches and hunks without comments. The implementation parses launchpad diffs with bzrlib.patches, however in order for comment line numbers and diff line numbers to correspond correctly, bzrlib.patches need to be aware of file modified headers.

Related branches

Kit Randel (blr)
tags: added: feature
tags: added: bzrlib.patches
description: updated
description: updated
description: updated
Kit Randel (blr)
description: updated
Changed in launchpad:
assignee: nobody → Bayard 'kit' Randel (blr)
Revision history for this message
Kit Randel (blr) wrote :

Since this bug was logged, my thinking around how this should be handled has changed a bit. Dirty 'file state' headers, even those directly adjacent to a patch, are not valid entities in a unified diff and should not really be directly associated with a patch object. With our launchpad usecase however, we really need to not only allow parsing of these headers (allowed by allow_dirty), but also to preserve them.

Vincent Ladeuil (vila)
Changed in bzr:
assignee: nobody → Bayard 'kit' Randel (blr)
status: New → Fix Committed
importance: Undecided → High
milestone: none → 2.7b1
Colin Watson (cjwatson)
Changed in launchpad:
status: New → Fix Released
Vincent Ladeuil (vila)
Changed in bzr:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.