##// END OF EJS Templates
localrepo: migrate to context manager for changing dirstate parents
Augie Fackler -
r32350:9742f937 default
parent child Browse files
Show More
@@ -850,21 +850,20 b' class localrepository(object):'
850 return self[changeid]
850 return self[changeid]
851
851
852 def setparents(self, p1, p2=nullid):
852 def setparents(self, p1, p2=nullid):
853 self.dirstate.beginparentchange()
853 with self.dirstate.parentchange():
854 copies = self.dirstate.setparents(p1, p2)
854 copies = self.dirstate.setparents(p1, p2)
855 pctx = self[p1]
855 pctx = self[p1]
856 if copies:
856 if copies:
857 # Adjust copy records, the dirstate cannot do it, it
857 # Adjust copy records, the dirstate cannot do it, it
858 # requires access to parents manifests. Preserve them
858 # requires access to parents manifests. Preserve them
859 # only for entries added to first parent.
859 # only for entries added to first parent.
860 for f in copies:
860 for f in copies:
861 if f not in pctx and copies[f] in pctx:
861 if f not in pctx and copies[f] in pctx:
862 self.dirstate.copy(copies[f], f)
862 self.dirstate.copy(copies[f], f)
863 if p2 == nullid:
863 if p2 == nullid:
864 for f, s in sorted(self.dirstate.copies().items()):
864 for f, s in sorted(self.dirstate.copies().items()):
865 if f not in pctx and s not in pctx:
865 if f not in pctx and s not in pctx:
866 self.dirstate.copy(None, f)
866 self.dirstate.copy(None, f)
867 self.dirstate.endparentchange()
868
867
869 def filectx(self, path, changeid=None, fileid=None):
868 def filectx(self, path, changeid=None, fileid=None):
870 """changeid can be a changeset revision, node, or tag.
869 """changeid can be a changeset revision, node, or tag.
General Comments 0
You need to be logged in to leave comments. Login now