comparison mercurial/context.py @ 26978:9b9d4bcc915e

filectx: add isabsent method This will indicate whether this filectx represents a file that is *not* in a changectx. This will be used by merge and filemerge code to know about when a conflict is a change/delete conflict. While this is kind of hacky, it is the least bad of all the alternatives. Other options considered but rejected include: - isinstance(fctx, ...) -- not very Pythonic, doesn't support duck typing - fctx.size() is None -- the 'size()' call on workingfilectxes causes a disk stat - fctx.filenode() == nullid -- the semantics around filenode are incredibly confusing. In particular, for workingfilectxes, filenode() is always None no matter whether the file is present on disk or in either parent. Having different behavior for None versus nullid in the merge code is just asking for pain. Thanks to Pierre-Yves David for early review feedback here.
author Siddharth Agarwal <sid0@fb.com>
date Mon, 16 Nov 2015 11:27:27 -0800
parents bd19561b98d9
children 448cbdab5883
comparison
equal deleted inserted replaced
26977:bd19561b98d9 26978:9b9d4bcc915e
744 return False 744 return False
745 def isexec(self): 745 def isexec(self):
746 return 'x' in self.flags() 746 return 'x' in self.flags()
747 def islink(self): 747 def islink(self):
748 return 'l' in self.flags() 748 return 'l' in self.flags()
749
750 def isabsent(self):
751 """whether this filectx represents a file not in self._changectx
752
753 This is mainly for merge code to detect change/delete conflicts. This is
754 expected to be True for all subclasses of basectx."""
755 return False
749 756
750 _customcmp = False 757 _customcmp = False
751 def cmp(self, fctx): 758 def cmp(self, fctx):
752 """compare with other file context 759 """compare with other file context
753 760