~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/patches.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-11-16 21:11:35 UTC
  • mfrom: (4797.1.5 2.1.0b4-dev)
  • Revision ID: pqm@pqm.ubuntu.com-20091116211135-yrz2cqc5t8h56lve
(jam) Merge 2.1.0b3 back to trunk, and start 2.1.0dev4

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import re
18
18
 
19
19
 
 
20
binary_files_re = 'Binary files (.*) and (.*) differ\n'
 
21
 
 
22
 
20
23
class BinaryFiles(Exception):
21
24
 
22
25
    def __init__(self, orig_name, mod_name):
66
69
def get_patch_names(iter_lines):
67
70
    try:
68
71
        line = iter_lines.next()
69
 
        match = re.match('Binary files (.*) and (.*) differ\n', line)
 
72
        match = re.match(binary_files_re, line)
70
73
        if match is not None:
71
74
            raise BinaryFiles(match.group(1), match.group(2))
72
75
        if not line.startswith("--- "):
350
353
 
351
354
 
352
355
def iter_file_patch(iter_lines):
 
356
    regex = re.compile(binary_files_re)
353
357
    saved_lines = []
354
358
    orig_range = 0
355
359
    for line in iter_lines:
360
364
        elif orig_range > 0:
361
365
            if line.startswith('-') or line.startswith(' '):
362
366
                orig_range -= 1
363
 
        elif line.startswith('--- '):
 
367
        elif line.startswith('--- ') or regex.match(line):
364
368
            if len(saved_lines) > 0:
365
369
                yield saved_lines
366
370
            saved_lines = []