comparison mercurial/patch.py @ 17941:9a6e4d5d7ea8

diff: move diffline to patch module diffline is not part of diff computation, so it makes more sense to place it with other header generation in patch module. In upcoming patches we will generalize this approach for all headers added in the patch, including the git index header.
author Guillermo Pérez <bisho@fb.com>
date Thu, 15 Nov 2012 12:19:03 -0800
parents c84ef0047a94
children 5e655418aa8d
comparison
equal deleted inserted replaced
17940:c84ef0047a94 17941:9a6e4d5d7ea8
1661 def trydiff(repo, revs, ctx1, ctx2, modified, added, removed, 1661 def trydiff(repo, revs, ctx1, ctx2, modified, added, removed,
1662 copy, getfilectx, opts, losedatafn, prefix): 1662 copy, getfilectx, opts, losedatafn, prefix):
1663 1663
1664 def join(f): 1664 def join(f):
1665 return os.path.join(prefix, f) 1665 return os.path.join(prefix, f)
1666
1667 def diffline(revs, a, b, opts):
1668 parts = ['diff']
1669 if opts.git:
1670 parts.append('--git')
1671 if revs and not opts.git:
1672 parts.append(' '.join(["-r %s" % rev for rev in revs]))
1673 if opts.git:
1674 parts.append('a/%s' % a)
1675 parts.append('b/%s' % b)
1676 else:
1677 parts.append(a)
1678 return ' '.join(parts) + '\n'
1666 1679
1667 date1 = util.datestr(ctx1.date()) 1680 date1 = util.datestr(ctx1.date())
1668 man1 = ctx1.manifest() 1681 man1 = ctx1.manifest()
1669 1682
1670 gone = set() 1683 gone = set()
1747 elif binary or nflag != oflag: 1760 elif binary or nflag != oflag:
1748 losedatafn(f) 1761 losedatafn(f)
1749 1762
1750 if dodiff: 1763 if dodiff:
1751 if opts.git or revs: 1764 if opts.git or revs:
1752 header.insert(0, mdiff.diffline(revs, join(a), join(b), opts)) 1765 header.insert(0, diffline(revs, join(a), join(b), opts))
1753 if dodiff == 'binary': 1766 if dodiff == 'binary':
1754 text = mdiff.b85diff(to, tn) 1767 text = mdiff.b85diff(to, tn)
1755 else: 1768 else:
1756 text = mdiff.unidiff(to, date1, 1769 text = mdiff.unidiff(to, date1,
1757 # ctx2 date may be dynamic 1770 # ctx2 date may be dynamic