Patchwork [4,of,7] context: migrate to context manager for changing dirstate parents

login
register
mail settings
Submitter Augie Fackler
Date May 18, 2017, 10:19 p.m.
Message ID <6b988519e85f29c9c273.1495145989@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/20696/
State Superseded
Headers show

Comments

Augie Fackler - May 18, 2017, 10:19 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1495141867 14400
#      Thu May 18 17:11:07 2017 -0400
# Node ID 6b988519e85f29c9c273f30c742ca0877aa824a1
# Parent  045240d198722437267f7d2dadb1c1dbfae971ee
context: migrate to context manager for changing dirstate parents

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1447,13 +1447,12 @@  class committablectx(basectx):
 
         """
 
-        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()'