# HG changeset patch # User Durham Goode # Date 2014-09-05 18:37:44 # Node ID d259322a394b56cae27b635f50bf2dbbd5cf877c # Parent 2e47e461d2ca40559c93cb5b0fd584330c110610 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. diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -256,6 +256,10 @@ class dirstate(object): 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