comparison mercurial/context.py @ 42322:fdd4d668ceb5

context: move contents of committablectx.markcommitted() to workingctx Same reasoning as previous commits: this function updates the dirstate. By not updating the dirstate here, we also fix the close-head test. Differential Revision: https://phab.mercurial-scm.org/D6365
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 10 May 2019 21:55:59 -0700
parents 4fbfc893e6b9
children df2f22befdc8
comparison
equal deleted inserted replaced
42321:c51b103220c7 42322:fdd4d668ceb5
1224 workingctx have been committed. For example, it marks 1224 workingctx have been committed. For example, it marks
1225 modified and added files as normal in the dirstate. 1225 modified and added files as normal in the dirstate.
1226 1226
1227 """ 1227 """
1228 1228
1229 with self._repo.dirstate.parentchange():
1230 for f in self.modified() + self.added():
1231 self._repo.dirstate.normal(f)
1232 for f in self.removed():
1233 self._repo.dirstate.drop(f)
1234 self._repo.dirstate.setparents(node)
1235
1236 # write changes out explicitly, because nesting wlock at
1237 # runtime may prevent 'wlock.release()' in 'repo.commit()'
1238 # from immediately doing so for subsequent changing files
1239 self._repo.dirstate.write(self._repo.currenttransaction())
1240
1241 def dirty(self, missing=False, merge=True, branch=True): 1229 def dirty(self, missing=False, merge=True, branch=True):
1242 return False 1230 return False
1243 1231
1244 class workingctx(committablectx): 1232 class workingctx(committablectx):
1245 """A workingctx object makes access to data related to 1233 """A workingctx object makes access to data related to
1655 match = self._repo.narrowmatch(match) 1643 match = self._repo.narrowmatch(match)
1656 ds = self._repo.dirstate 1644 ds = self._repo.dirstate
1657 return sorted(f for f in ds.matches(match) if ds[f] != 'r') 1645 return sorted(f for f in ds.matches(match) if ds[f] != 'r')
1658 1646
1659 def markcommitted(self, node): 1647 def markcommitted(self, node):
1660 super(workingctx, self).markcommitted(node) 1648 with self._repo.dirstate.parentchange():
1649 for f in self.modified() + self.added():
1650 self._repo.dirstate.normal(f)
1651 for f in self.removed():
1652 self._repo.dirstate.drop(f)
1653 self._repo.dirstate.setparents(node)
1654
1655 # write changes out explicitly, because nesting wlock at
1656 # runtime may prevent 'wlock.release()' in 'repo.commit()'
1657 # from immediately doing so for subsequent changing files
1658 self._repo.dirstate.write(self._repo.currenttransaction())
1661 1659
1662 sparse.aftercommit(self._repo, node) 1660 sparse.aftercommit(self._repo, node)
1663 1661
1664 class committablefilectx(basefilectx): 1662 class committablefilectx(basefilectx):
1665 """A committablefilectx provides common functionality for a file context 1663 """A committablefilectx provides common functionality for a file context