Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 24024:a5c7e86a81c1
trydiff: move check for quietness out of diffline()
By moving the condition out of diffline(), the call site becomes
clearer and diffline() no longer closes on any variables.
Note that this changes the value of the header variable from [''] to
[], but there is no difference in how these two are treated by the
following code. The new value seems more natural anyway.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 16 Jan 2015 15:27:04 -0800 |
parents | 163e25931f65 |
children | bbb011f4eb32 |
comparison
equal
deleted
inserted
replaced
24023:163e25931f65 | 24024:a5c7e86a81c1 |
---|---|
1752 else: | 1752 else: |
1753 aprefix = 'a/' | 1753 aprefix = 'a/' |
1754 bprefix = 'b/' | 1754 bprefix = 'b/' |
1755 | 1755 |
1756 def diffline(f, revs): | 1756 def diffline(f, revs): |
1757 if not repo.ui.quiet: | 1757 revinfo = ' '.join(["-r %s" % rev for rev in revs]) |
1758 revinfo = ' '.join(["-r %s" % rev for rev in revs]) | 1758 return 'diff %s %s\n' % (revinfo, f) |
1759 line = 'diff %s %s\n' % (revinfo, f) | |
1760 else: | |
1761 line = '' | |
1762 return line | |
1763 | 1759 |
1764 date1 = util.datestr(ctx1.date()) | 1760 date1 = util.datestr(ctx1.date()) |
1765 date2 = util.datestr(ctx2.date()) | 1761 date2 = util.datestr(ctx2.date()) |
1766 | 1762 |
1767 gone = set() | 1763 gone = set() |
1852 header.append('old mode %s\n' % mode1) | 1848 header.append('old mode %s\n' % mode1) |
1853 header.append('new mode %s\n' % mode2) | 1849 header.append('new mode %s\n' % mode2) |
1854 if op is not None: | 1850 if op is not None: |
1855 header.append('%s from %s\n' % (op, path1)) | 1851 header.append('%s from %s\n' % (op, path1)) |
1856 header.append('%s to %s\n' % (op, path2)) | 1852 header.append('%s to %s\n' % (op, path2)) |
1857 elif revs: | 1853 elif revs and not repo.ui.quiet: |
1858 header.append(diffline(path1, revs)) | 1854 header.append(diffline(path1, revs)) |
1859 | 1855 |
1860 if binarydiff and not opts.nobinary: | 1856 if binarydiff and not opts.nobinary: |
1861 text = mdiff.b85diff(content1, content2) | 1857 text = mdiff.b85diff(content1, content2) |
1862 if text and opts.git: | 1858 if text and opts.git: |