comparison mercurial/localrepo.py @ 22405:6f63c47cbb86

dirstate: wrap setparent calls with begin/endparentchange (issue4353) This wraps all the locations of dirstate.setparent with the appropriate begin/endparentchange calls. This will prevent exceptions during those calls from causing incoherent dirstates (issue4353).
author Durham Goode <durham@fb.com>
date Fri, 05 Sep 2014 11:36:20 -0700
parents 12bc7f06fc41
children e6e7ef68c879
comparison
equal deleted inserted replaced
22404:12bc7f06fc41 22405:6f63c47cbb86
756 def parents(self, changeid=None): 756 def parents(self, changeid=None):
757 '''get list of changectxs for parents of changeid''' 757 '''get list of changectxs for parents of changeid'''
758 return self[changeid].parents() 758 return self[changeid].parents()
759 759
760 def setparents(self, p1, p2=nullid): 760 def setparents(self, p1, p2=nullid):
761 self.dirstate.beginparentchange()
761 copies = self.dirstate.setparents(p1, p2) 762 copies = self.dirstate.setparents(p1, p2)
762 pctx = self[p1] 763 pctx = self[p1]
763 if copies: 764 if copies:
764 # Adjust copy records, the dirstate cannot do it, it 765 # Adjust copy records, the dirstate cannot do it, it
765 # requires access to parents manifests. Preserve them 766 # requires access to parents manifests. Preserve them
769 self.dirstate.copy(copies[f], f) 770 self.dirstate.copy(copies[f], f)
770 if p2 == nullid: 771 if p2 == nullid:
771 for f, s in sorted(self.dirstate.copies().items()): 772 for f, s in sorted(self.dirstate.copies().items()):
772 if f not in pctx and s not in pctx: 773 if f not in pctx and s not in pctx:
773 self.dirstate.copy(None, f) 774 self.dirstate.copy(None, f)
775 self.dirstate.endparentchange()
774 776
775 def filectx(self, path, changeid=None, fileid=None): 777 def filectx(self, path, changeid=None, fileid=None):
776 """changeid can be a changeset revision, node, or tag. 778 """changeid can be a changeset revision, node, or tag.
777 fileid can be a file revision or node.""" 779 fileid can be a file revision or node."""
778 return context.filectx(self, path, changeid, fileid) 780 return context.filectx(self, path, changeid, fileid)