##// END OF EJS Templates
trydiff: extract function that generates filename pairs...
Martin von Zweigbergk -
r24106:9cf9432a default
parent child Browse files
Show More
@@ -1736,6 +1736,44 b' def diffui(*args, **kw):'
1736 '''like diff(), but yields 2-tuples of (output, label) for ui.write()'''
1736 '''like diff(), but yields 2-tuples of (output, label) for ui.write()'''
1737 return difflabel(diff, *args, **kw)
1737 return difflabel(diff, *args, **kw)
1738
1738
1739 def _filepairs(ctx1, modified, added, removed, copy, opts):
1740 '''generates tuples (f1, f2, copyop), where f1 is the name of the file
1741 before and f2 is the the name after. For added files, f1 will be None,
1742 and for removed files, f2 will be None. copyop may be set to None, 'copy'
1743 or 'rename' (the latter two only if opts.git is set).'''
1744 gone = set()
1745
1746 copyto = dict([(v, k) for k, v in copy.items()])
1747
1748 addedset, removedset = set(added), set(removed)
1749 # Fix up added, since merged-in additions appear as
1750 # modifications during merges
1751 for f in modified:
1752 if f not in ctx1:
1753 addedset.add(f)
1754
1755 for f in sorted(modified + added + removed):
1756 copyop = None
1757 f1, f2 = f, f
1758 if f in addedset:
1759 f1 = None
1760 if f in copy:
1761 if opts.git:
1762 f1 = copy[f]
1763 if f1 in removedset and f1 not in gone:
1764 copyop = 'rename'
1765 gone.add(f1)
1766 else:
1767 copyop = 'copy'
1768 elif f in removedset:
1769 f2 = None
1770 if opts.git:
1771 # have we already reported a copy above?
1772 if (f in copyto and copyto[f] in addedset
1773 and copy[copyto[f]] == f):
1774 continue
1775 yield f1, f2, copyop
1776
1739 def trydiff(repo, revs, ctx1, ctx2, modified, added, removed,
1777 def trydiff(repo, revs, ctx1, ctx2, modified, added, removed,
1740 copy, getfilectx, opts, losedatafn, prefix):
1778 copy, getfilectx, opts, losedatafn, prefix):
1741
1779
@@ -1760,38 +1798,10 b' def trydiff(repo, revs, ctx1, ctx2, modi'
1760 date1 = util.datestr(ctx1.date())
1798 date1 = util.datestr(ctx1.date())
1761 date2 = util.datestr(ctx2.date())
1799 date2 = util.datestr(ctx2.date())
1762
1800
1763 gone = set()
1764 gitmode = {'l': '120000', 'x': '100755', '': '100644'}
1801 gitmode = {'l': '120000', 'x': '100755', '': '100644'}
1765
1802
1766 copyto = dict([(v, k) for k, v in copy.items()])
1803 for f1, f2, copyop in _filepairs(
1767
1804 ctx1, modified, added, removed, copy, opts):
1768 addedset, removedset = set(added), set(removed)
1769 # Fix up added, since merged-in additions appear as
1770 # modifications during merges
1771 for f in modified:
1772 if f not in ctx1:
1773 addedset.add(f)
1774 for f in sorted(modified + added + removed):
1775 copyop = None
1776 f1, f2 = f, f
1777 if f in addedset:
1778 f1 = None
1779 if f in copy:
1780 if opts.git:
1781 f1 = copy[f]
1782 if f1 in removedset and f1 not in gone:
1783 copyop = 'rename'
1784 gone.add(f1)
1785 else:
1786 copyop = 'copy'
1787 elif f in removedset:
1788 f2 = None
1789 if opts.git:
1790 # have we already reported a copy above?
1791 if (f in copyto and copyto[f] in addedset
1792 and copy[copyto[f]] == f):
1793 continue
1794
1795 content1 = None
1805 content1 = None
1796 content2 = None
1806 content2 = None
1797 if f1:
1807 if f1:
@@ -1811,7 +1821,7 b' def trydiff(repo, revs, ctx1, ctx2, modi'
1811 if losedatafn and not opts.git:
1821 if losedatafn and not opts.git:
1812 if (binary or
1822 if (binary or
1813 # copy/rename
1823 # copy/rename
1814 f in copy or
1824 f2 in copy or
1815 # empty file creation
1825 # empty file creation
1816 (not f1 and not content2) or
1826 (not f1 and not content2) or
1817 # empty file deletion
1827 # empty file deletion
@@ -1820,7 +1830,7 b' def trydiff(repo, revs, ctx1, ctx2, modi'
1820 (not f1 and flag2) or
1830 (not f1 and flag2) or
1821 # change flags
1831 # change flags
1822 (f1 and f2 and flag1 != flag2)):
1832 (f1 and f2 and flag1 != flag2)):
1823 losedatafn(f)
1833 losedatafn(f2 or f1)
1824
1834
1825 path1 = posixpath.join(prefix, f1 or f2)
1835 path1 = posixpath.join(prefix, f1 or f2)
1826 path2 = posixpath.join(prefix, f2 or f1)
1836 path2 = posixpath.join(prefix, f2 or f1)
General Comments 0
You need to be logged in to leave comments. Login now