comparison mercurial/localrepo.py @ 44052:b74270da5eee

workingctx: move setparents() logic from localrepo to mirror overlayworkingctx It would be nice to later be able to call `wctx.setparents()` whether `wctx` is a `workingctx` or an `overlayworkingctx`. Differential Revision: https://phab.mercurial-scm.org/D7823
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 10 Jan 2020 13:24:25 -0800
parents b958419b6c53
children a61287a95dc3
comparison
equal deleted inserted replaced
44051:436d106de670 44052:b74270da5eee
1884 1884
1885 def wjoin(self, f, *insidef): 1885 def wjoin(self, f, *insidef):
1886 return self.vfs.reljoin(self.root, f, *insidef) 1886 return self.vfs.reljoin(self.root, f, *insidef)
1887 1887
1888 def setparents(self, p1, p2=nullid): 1888 def setparents(self, p1, p2=nullid):
1889 with self.dirstate.parentchange(): 1889 self[None].setparents(p1, p2)
1890 copies = self.dirstate.setparents(p1, p2)
1891 pctx = self[p1]
1892 if copies:
1893 # Adjust copy records, the dirstate cannot do it, it
1894 # requires access to parents manifests. Preserve them
1895 # only for entries added to first parent.
1896 for f in copies:
1897 if f not in pctx and copies[f] in pctx:
1898 self.dirstate.copy(copies[f], f)
1899 if p2 == nullid:
1900 for f, s in sorted(self.dirstate.copies().items()):
1901 if f not in pctx and s not in pctx:
1902 self.dirstate.copy(None, f)
1903 1890
1904 def filectx(self, path, changeid=None, fileid=None, changectx=None): 1891 def filectx(self, path, changeid=None, fileid=None, changectx=None):
1905 """changeid must be a changeset revision, if specified. 1892 """changeid must be a changeset revision, if specified.
1906 fileid can be a file revision or node.""" 1893 fileid can be a file revision or node."""
1907 return context.filectx( 1894 return context.filectx(