comparison mercurial/patch.py @ 17940:c84ef0047a94

diff: unify calls to diffline diffline was called from trydiff for binary diffs and from unidiff for text diffs. In this patch we unify those calls into one. diffline is also a header, not part of diff mechanisms, so it makes sense to remove that responsibility from the mdiff module. In upcoming patches we will move diffline to patch module and keep grouping responsibilities.
author Guillermo Pérez <bisho@fb.com>
date Thu, 15 Nov 2012 12:16:08 -0800
parents d587925680d9
children 9a6e4d5d7ea8
comparison
equal deleted inserted replaced
17939:d587925680d9 17940:c84ef0047a94
1744 _addmodehdr(header, gitmode[oflag], gitmode[nflag]) 1744 _addmodehdr(header, gitmode[oflag], gitmode[nflag])
1745 if binary: 1745 if binary:
1746 dodiff = 'binary' 1746 dodiff = 'binary'
1747 elif binary or nflag != oflag: 1747 elif binary or nflag != oflag:
1748 losedatafn(f) 1748 losedatafn(f)
1749 if opts.git: 1749
1750 if dodiff:
1751 if opts.git or revs:
1750 header.insert(0, mdiff.diffline(revs, join(a), join(b), opts)) 1752 header.insert(0, mdiff.diffline(revs, join(a), join(b), opts))
1751
1752 if dodiff:
1753 if dodiff == 'binary': 1753 if dodiff == 'binary':
1754 text = mdiff.b85diff(to, tn) 1754 text = mdiff.b85diff(to, tn)
1755 else: 1755 else:
1756 text = mdiff.unidiff(to, date1, 1756 text = mdiff.unidiff(to, date1,
1757 # ctx2 date may be dynamic 1757 # ctx2 date may be dynamic
1758 tn, util.datestr(ctx2.date()), 1758 tn, util.datestr(ctx2.date()),
1759 join(a), join(b), revs, opts=opts) 1759 join(a), join(b), opts=opts)
1760 if header and (text or len(header) > 1): 1760 if header and (text or len(header) > 1):
1761 yield ''.join(header) 1761 yield ''.join(header)
1762 if text: 1762 if text:
1763 yield text 1763 yield text
1764 1764