~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/rio.py

  • Committer: Aaron Bentley
  • Date: 2007-03-01 18:30:50 UTC
  • mto: (2323.6.9 0.15-integration)
  • mto: This revision was merged to the branch mainline in revision 2330.
  • Revision ID: abentley@panoramicfeedback.com-20070301183050-g05fxlw903g99b1h
Handle trailing whitepace cleanly

Show diffs side-by-side

added added

removed removed

Lines of Context:
326
326
            while len(line) > 0:
327
327
                partline = line[:max_rio_width]
328
328
                line = line[max_rio_width:]
 
329
                partline = re.sub('\r', '\\\\r', partline)
 
330
                blank_line = False
329
331
                if len(line) > 0:
330
332
                    partline += '\\'
331
 
                lines.append('# ' + re.sub('\r', '\\\\r', partline+ '\n'))
 
333
                elif re.search(' $', partline):
 
334
                    partline += '\\'
 
335
                    blank_line = True
 
336
                lines.append('# ' + partline + '\n')
 
337
                if blank_line:
 
338
                    lines.append('# \n')
332
339
    return lines
333
340
 
334
341
def _patch_stanza_iter(line_iter):
340
347
 
341
348
    last_line = None
342
349
    for line in line_iter:
343
 
        assert line.startswith('# ')
 
350
        assert line.startswith('#')
344
351
        line = line[2:]
345
352
        line = re.sub('\r', '', line)
346
353
        line = re.sub('\\\\(.|\n)', mapget, line)