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

login
register
mail settings
Submitter Augie Fackler
Date May 19, 2017, 9:38 p.m.
Message ID <3a82feb644a3cc6c6b9e.1495229924@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/20737/
State Accepted
Headers show

Comments

Augie Fackler - May 19, 2017, 9:38 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1495141867 14400
#      Thu May 18 17:11:07 2017 -0400
# Node ID 3a82feb644a3cc6c6b9e81a28a155ceb204e0ca5
# Parent  96a232ad4958bad1de7366360fecac987ca51721
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()'