~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/patches.py

  • Committer: Aaron Bentley
  • Date: 2008-10-10 23:14:42 UTC
  • mto: (3363.19.2 fix-iter-changes)
  • mto: This revision was merged to the branch mainline in revision 3781.
  • Revision ID: aaron@aaronbentley.com-20081010231442-6be32m59zo304a90
Allow patching directly from parsed hunks

Show diffs side-by-side

added added

removed removed

Lines of Context:
393
393
    """Iterate through a series of lines with a patch applied.
394
394
    This handles a single file, and does exact, not fuzzy patching.
395
395
    """
396
 
    if orig_lines is not None:
397
 
        orig_lines = orig_lines.__iter__()
398
 
    seen_patch = []
399
396
    patch_lines = iter_lines_handle_nl(patch_lines.__iter__())
400
397
    get_patch_names(patch_lines)
 
398
    return iter_patched_from_hunks(orig_lines, iter_hunks(patch_lines))
 
399
 
 
400
def iter_patched_from_hunks(orig_lines, hunks):
 
401
    seen_patch = []
401
402
    line_no = 1
402
 
    for hunk in iter_hunks(patch_lines):
 
403
    if orig_lines is not None:
 
404
        orig_lines = orig_lines.__iter__()
 
405
    for hunk in hunks:
403
406
        while line_no < hunk.orig_pos:
404
407
            orig_line = orig_lines.next()
405
408
            yield orig_line