Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 32349:81936f6462c1
context: migrate to context manager for changing dirstate parents
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 18 May 2017 17:11:07 -0400 |
parents | 07da778f3b58 |
children | 24245b54aa8a |
comparison
equal
deleted
inserted
replaced
32348:082fc4abdc31 | 32349:81936f6462c1 |
---|---|
1445 workingctx have been committed. For example, it marks | 1445 workingctx have been committed. For example, it marks |
1446 modified and added files as normal in the dirstate. | 1446 modified and added files as normal in the dirstate. |
1447 | 1447 |
1448 """ | 1448 """ |
1449 | 1449 |
1450 self._repo.dirstate.beginparentchange() | 1450 with self._repo.dirstate.parentchange(): |
1451 for f in self.modified() + self.added(): | 1451 for f in self.modified() + self.added(): |
1452 self._repo.dirstate.normal(f) | 1452 self._repo.dirstate.normal(f) |
1453 for f in self.removed(): | 1453 for f in self.removed(): |
1454 self._repo.dirstate.drop(f) | 1454 self._repo.dirstate.drop(f) |
1455 self._repo.dirstate.setparents(node) | 1455 self._repo.dirstate.setparents(node) |
1456 self._repo.dirstate.endparentchange() | |
1457 | 1456 |
1458 # write changes out explicitly, because nesting wlock at | 1457 # write changes out explicitly, because nesting wlock at |
1459 # runtime may prevent 'wlock.release()' in 'repo.commit()' | 1458 # runtime may prevent 'wlock.release()' in 'repo.commit()' |
1460 # from immediately doing so for subsequent changing files | 1459 # from immediately doing so for subsequent changing files |
1461 self._repo.dirstate.write(self._repo.currenttransaction()) | 1460 self._repo.dirstate.write(self._repo.currenttransaction()) |