~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Martin Pool
  • Date: 2005-05-10 07:15:48 UTC
  • Revision ID: mbp@sourcefrog.net-20050510071548-697b9223be79541e
- Fix from Lalo for unidiff output of newly added 
  and changed files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
179
179
        # idlabel = '      {%s}' % fid
180
180
        idlabel = ''
181
181
 
182
 
        # FIXME: Something about the diff format makes patch unhappy
183
 
        # with newly-added files.
184
 
 
185
182
        def diffit(oldlines, newlines, **kw):
186
183
            
187
184
            # FIXME: difflib is wrong if there is no trailing newline.
210
207
                nonl = True
211
208
 
212
209
            ud = difflib.unified_diff(oldlines, newlines, **kw)
 
210
 
 
211
            # work-around for difflib being too smart for its own good
 
212
            # if /dev/null is "1,0", patch won't recognize it as /dev/null
 
213
            if not oldlines:
 
214
                ud = list(ud)
 
215
                ud[2] = ud[2].replace('-1,0', '-0,0')
 
216
            elif not newlines:
 
217
                ud = list(ud)
 
218
                ud[2] = ud[2].replace('+1,0', '+0,0')
 
219
            
213
220
            sys.stdout.writelines(ud)
214
221
            if nonl:
215
222
                print "\\ No newline at end of file"