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.
--- 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