comparison mercurial/context.py @ 23688:20932983d520

filectx.parents: filter nullrev parent sooner We are going to introduce a linkrev-correction phases when computing parents. It will be more convenient to have the nullid parent filtered out earlier. I had to make a minimal adjustment to the rename handling logic to keep it functional. That logic have been documented in the process since it took me some time to check all the cases out.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 23 Dec 2014 18:29:03 -0800
parents 8f32dcfbc338
children fe17a6fb220d
comparison
equal deleted inserted replaced
23687:8f32dcfbc338 23688:20932983d520
734 return True 734 return True
735 735
736 def parents(self): 736 def parents(self):
737 _path = self._path 737 _path = self._path
738 fl = self._filelog 738 fl = self._filelog
739 pl = [(_path, n, fl) for n in self._filelog.parents(self._filenode)] 739 parents = self._filelog.parents(self._filenode)
740 pl = [(_path, node, fl) for node in parents if node != nullid]
740 741
741 r = self._filelog.renamed(self._filenode) 742 r = self._filelog.renamed(self._filenode)
742 if r: 743 if r:
743 pl[0] = (r[0], r[1], None) 744 # - In the simple rename case, both parent are nullid, pl is empty.
744 745 # - In case of merge, only one of the parent is null id and should
745 return [filectx(self._repo, p, fileid=n, filelog=l) 746 # be replaced with the rename information. This parent is -always-
746 for p, n, l in pl if n != nullid] 747 # the first one.
748 #
749 # As null id have alway been filtered out in the previous list
750 # comprehension, inserting to 0 will always result in "replacing
751 # first nullid parent with rename information.
752 pl.insert(0, (r[0], r[1], None))
753
754 return [filectx(self._repo, p, fileid=n, filelog=l) for p, n, l in pl]
747 755
748 def p1(self): 756 def p1(self):
749 return self.parents()[0] 757 return self.parents()[0]
750 758
751 def p2(self): 759 def p2(self):