context: migrate to context manager for changing dirstate parents
authorAugie Fackler <augie@google.com>
Thu, 18 May 2017 17:11:07 -0400
changeset 32349 81936f6462c1
parent 32348 082fc4abdc31
child 32350 9742f937c971
context: migrate to context manager for changing dirstate parents
mercurial/context.py
--- 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()'