comparison mercurial/changegroup.py @ 36760:7bf80d9d9543

merge with stable There were a handful of merge conflicts in the wire protocol code due to significant refactoring in default. When resolving the conflicts, I tried to produce the minimal number of changes to make the incoming security patches work with the new code. I will send some follow-up commits to get the security patches better integrated into default.
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 06 Mar 2018 14:32:14 -0800
parents 2a5024109490 d031609b3cb7
children 5bc7ff103081
comparison
equal deleted inserted replaced
36747:4c71a26a4009 36760:7bf80d9d9543
772 yield chunk 772 yield chunk
773 self._verbosenote(_('%8.i %s\n') % (size, fname)) 773 self._verbosenote(_('%8.i %s\n') % (size, fname))
774 progress(msgbundling, None) 774 progress(msgbundling, None)
775 775
776 def deltaparent(self, revlog, rev, p1, p2, prev): 776 def deltaparent(self, revlog, rev, p1, p2, prev):
777 if not revlog.candelta(prev, rev):
778 raise error.ProgrammingError('cg1 should not be used in this case')
777 return prev 779 return prev
778 780
779 def revchunk(self, revlog, rev, prev, linknode): 781 def revchunk(self, revlog, rev, prev, linknode):
780 node = revlog.node(rev) 782 node = revlog.node(rev)
781 p1, p2 = revlog.parentrevs(rev) 783 p1, p2 = revlog.parentrevs(rev)
831 # be smaller in the common case. However, computing a delta against 833 # be smaller in the common case. However, computing a delta against
832 # p1 may require resolving the raw text of p1, which could be 834 # p1 may require resolving the raw text of p1, which could be
833 # expensive. The revlog caches should have prev cached, meaning 835 # expensive. The revlog caches should have prev cached, meaning
834 # less CPU for changegroup generation. There is likely room to add 836 # less CPU for changegroup generation. There is likely room to add
835 # a flag and/or config option to control this behavior. 837 # a flag and/or config option to control this behavior.
836 return prev 838 base = prev
837 elif dp == nullrev: 839 elif dp == nullrev:
838 # revlog is configured to use full snapshot for a reason, 840 # revlog is configured to use full snapshot for a reason,
839 # stick to full snapshot. 841 # stick to full snapshot.
840 return nullrev 842 base = nullrev
841 elif dp not in (p1, p2, prev): 843 elif dp not in (p1, p2, prev):
842 # Pick prev when we can't be sure remote has the base revision. 844 # Pick prev when we can't be sure remote has the base revision.
843 return prev 845 return prev
844 else: 846 else:
845 return dp 847 base = dp
848 if base != nullrev and not revlog.candelta(base, rev):
849 base = nullrev
850 return base
846 851
847 def builddeltaheader(self, node, p1n, p2n, basenode, linknode, flags): 852 def builddeltaheader(self, node, p1n, p2n, basenode, linknode, flags):
848 # Do nothing with flags, it is implicitly 0 in cg1 and cg2 853 # Do nothing with flags, it is implicitly 0 in cg1 and cg2
849 return struct.pack(self.deltaheader, node, p1n, p2n, basenode, linknode) 854 return struct.pack(self.deltaheader, node, p1n, p2n, basenode, linknode)
850 855