dirstate: add exception when calling setparent without begin/end (API)
authorDurham Goode <durham@fb.com>
Fri, 05 Sep 2014 11:37:44 -0700
changeset 22407 d259322a394b
parent 22406 2e47e461d2ca
child 22408 dc97e04c12ad
dirstate: add exception when calling setparent without begin/end (API) Adds an exception when calling dirstate.setparent without having first called dirstate.beginparentchange. This will prevent people from writing code that modifies the dirstate parent without considering the transactionality of their change. This will break third party extensions that call setparents.
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Fri Sep 05 15:36:56 2014 -0700
+++ b/mercurial/dirstate.py	Fri Sep 05 11:37:44 2014 -0700
@@ -256,6 +256,10 @@
 
         See localrepo.setparents()
         """
+        if self._parentwriters == 0:
+            raise ValueError("cannot set dirstate parent without " +
+                " calling dirstate.begingparentchange")
+
         self._dirty = self._dirtypl = True
         oldp2 = self._pl[1]
         self._pl = p1, p2