changeset 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 082fc4abdc31
children 9742f937c971
files mercurial/context.py
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Thu May 18 17:11:01 2017 -0400
+++ b/mercurial/context.py	Thu May 18 17:11:07 2017 -0400
@@ -1447,13 +1447,12 @@
 
         """
 
-        self._repo.dirstate.beginparentchange()
-        for f in self.modified() + self.added():
-            self._repo.dirstate.normal(f)
-        for f in self.removed():
-            self._repo.dirstate.drop(f)
-        self._repo.dirstate.setparents(node)
-        self._repo.dirstate.endparentchange()
+        with self._repo.dirstate.parentchange():
+            for f in self.modified() + self.added():
+                self._repo.dirstate.normal(f)
+            for f in self.removed():
+                self._repo.dirstate.drop(f)
+            self._repo.dirstate.setparents(node)
 
         # write changes out explicitly, because nesting wlock at
         # runtime may prevent 'wlock.release()' in 'repo.commit()'