From patchwork Fri Sep 5 19:36:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3, of, 3] dirstate: add exception when calling setparent without begin/end From: Durham Goode X-Patchwork-Id: 5704 Message-Id: To: Date: Fri, 5 Sep 2014 12:36:21 -0700 # HG changeset patch # User Durham Goode # Date 1409942264 25200 # Fri Sep 05 11:37:44 2014 -0700 # Node ID cbc8f6a95fd203e455c5acd0cf6f6006663af52f # Parent ca5a5cd5a9840dd3d391a6204f5e3edb8b097b44 dirstate: add exception when calling setparent without begin/end 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 @@ -243,6 +243,10 @@ See localrepo.setparents() """ + if self._parentwriters == 0: + raise util.Abort(_("cannot set dirstate parent without " + + " calling dirstate.begingparentchange")) + self._dirty = self._dirtypl = True oldp2 = self._pl[1] self._pl = p1, p2