Mercurial > public > mercurial-scm > hg
comparison mercurial/context.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 | 436d106de670 |
children | 85c4cd73996b |
comparison
equal
deleted
inserted
replaced
44051:436d106de670 | 44052:b74270da5eee |
---|---|
1526 self._repo, unfi.changelog.rev(n), n, maybe_filtered=False | 1526 self._repo, unfi.changelog.rev(n), n, maybe_filtered=False |
1527 ) | 1527 ) |
1528 for n in p | 1528 for n in p |
1529 ] | 1529 ] |
1530 | 1530 |
1531 def setparents(self, p1node, p2node=nullid): | |
1532 dirstate = self._repo.dirstate | |
1533 with dirstate.parentchange(): | |
1534 copies = dirstate.setparents(p1node, p2node) | |
1535 pctx = self._repo[p1node] | |
1536 if copies: | |
1537 # Adjust copy records, the dirstate cannot do it, it | |
1538 # requires access to parents manifests. Preserve them | |
1539 # only for entries added to first parent. | |
1540 for f in copies: | |
1541 if f not in pctx and copies[f] in pctx: | |
1542 dirstate.copy(copies[f], f) | |
1543 if p2node == nullid: | |
1544 for f, s in sorted(dirstate.copies().items()): | |
1545 if f not in pctx and s not in pctx: | |
1546 dirstate.copy(None, f) | |
1547 | |
1531 def _fileinfo(self, path): | 1548 def _fileinfo(self, path): |
1532 # populate __dict__['_manifest'] as workingctx has no _manifestdelta | 1549 # populate __dict__['_manifest'] as workingctx has no _manifestdelta |
1533 self._manifest | 1550 self._manifest |
1534 return super(workingctx, self)._fileinfo(path) | 1551 return super(workingctx, self)._fileinfo(path) |
1535 | 1552 |