Mercurial > evolve
view debian/copyright @ 6364:e8d85d51c7b2 stable
topic: monkey-patch ctx.branch() correctly in override_context_branch
There's a `for p in ctx.parents()` loop in this block of code, and it's used to
monkey-patch .branch() method for both parents of ctx. It assigns each parent
of ctx to variable `p` (implicitly) and p.branch method to variable `pbranch`
(explicitly).
This worked fine when there's only one p1, but when there were 2 parents, this
code was broken, and our tests didn't catch this because the use of
override_context_branch context manager is quite limited.
The problem is that the newly created function uses `p` and `pbranch`, and the
closures for the new p1.branch() and p2.branch() didn't get created until the
for-loop finished, and the values `p` and `pbranch` could change before that.
In other words, the new .branch method of p1 was effectively identical to p2's
because the values that were available to it were from the second cycle of the
for-loop, when it the loop was at p2.
Now we pass the values to a function that creates the new .branch methods, and
since these values are provided to overridebranch() as arguments, they get
enclosed when the function returns.
This was seen (and tested) during topic namespaces-related work, when
override_context_branch usage was expanded to include some local operations.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Thu, 15 Dec 2022 17:07:25 +0400 |
parents | 9571d40061c8 |
children | 8f52da3cefd0 |
line wrap: on
line source
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: evolve Source: https://www.mercurial-scm.org/repo/evolve/ Files: * Copyright: 2011—2022 Pierre-Yves David <pierre-yves.david@octobus.net> Anton Shestakov <av6@dwimlabs.net> and others License: GPL-2+ Files: debian/* Copyright: 2011-2022 Anton Shestakov <av6@dwimlabs.net> Pierre-Yves David <pierre-yves.david@octobus.net> Faheem Mitha <faheem@faheem.info> Julien Cristau <julien.cristau@logilab.fr> Georges Racinet <georges.racinet@octobus.net> Denis Laxalde <denis@laxalde.org> Kim Alvefur <zash@zash.se> Martin von Zweigbergk <martinvonz@google.com> Laurent Charignon <lcharignon@fb.com> Philippe Pepiot <philippe.pepiot@logilab.fr> Logilab SA <contact@logilab.fr> License: GPL-2+ License: GPL-2+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. . On Debian systems, the complete text of the GNU General Public License version 2 can be found in ‘/usr/share/common-licenses/GPL-2’. This software may be used and distributed according to the terms of the GNU General Public License version 2 or any later version. On Debian systems, the complete text of the GNU General Public License version 2 can be found in `/usr/share/common-licenses/GPL-2'.