Mercurial > hg
comparison mercurial/patch.py @ 17944:7ac2a7720724
diff: rewrite diffline
Make diffline more readable, using strings with placeholders
rather than appending to a list from many ifs that makes
difficult to understand the actual output format.
author | Guillermo Pérez <bisho@fb.com> |
---|---|
date | Thu, 15 Nov 2012 13:57:03 -0800 |
parents | 66b9832331c9 |
children | 45766e2a7384 |
comparison
equal
deleted
inserted
replaced
17943:66b9832331c9 | 17944:7ac2a7720724 |
---|---|
1662 | 1662 |
1663 def join(f): | 1663 def join(f): |
1664 return os.path.join(prefix, f) | 1664 return os.path.join(prefix, f) |
1665 | 1665 |
1666 def diffline(a, b, revs): | 1666 def diffline(a, b, revs): |
1667 if repo.ui.quiet and not opts.git: | |
1668 return '' | |
1669 parts = ['diff'] | |
1670 if opts.git: | 1667 if opts.git: |
1671 parts.append('--git') | 1668 line = 'diff --git a/%s b/%s\n' % (a, b) |
1672 if revs and not opts.git: | 1669 elif not repo.ui.quiet: |
1673 parts.append(' '.join(["-r %s" % rev for rev in revs])) | 1670 if revs: |
1674 if opts.git: | 1671 revinfo = ' '.join(["-r %s" % rev for rev in revs]) |
1675 parts.append('a/%s' % a) | 1672 line = 'diff %s %s\n' % (revinfo, a) |
1676 parts.append('b/%s' % b) | 1673 else: |
1674 line = 'diff %s\n' % a | |
1677 else: | 1675 else: |
1678 parts.append(a) | 1676 line = '' |
1679 return ' '.join(parts) + '\n' | 1677 return line |
1680 | 1678 |
1681 date1 = util.datestr(ctx1.date()) | 1679 date1 = util.datestr(ctx1.date()) |
1682 man1 = ctx1.manifest() | 1680 man1 = ctx1.manifest() |
1683 | 1681 |
1684 gone = set() | 1682 gone = set() |