Yuya Nishihara <yuya@tcha.org> [Mon, 14 Aug 2017 15:50:40 +0900] rev 33811
py3: change encoding.localstr to a subclass of bytes, not str
Yuya Nishihara <yuya@tcha.org> [Sun, 13 Aug 2017 11:10:35 +0900] rev 33810
bundle2: relax the condition to update transaction.hookargs
This is just a micro optimization. If hookargs is empty, nothing should be
necessary.
Yuya Nishihara <yuya@tcha.org> [Sun, 13 Aug 2017 11:05:56 +0900] rev 33809
bundle2: raise ProgrammingError for invalid call of addhookargs()
It should be hard error. Also fixed the error message as s/hooks/hookargs/.
Alex Gaynor <agaynor@mozilla.com> [Fri, 14 Jul 2017 19:27:28 +0000] rev 33808
merge: removed sorting in casefolding detection, for a slight performance win
It was not required for the correctness of the algorithm.
Differential Revision: https://phab.mercurial-scm.org/D30
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 10 Aug 2017 21:00:30 -0700] rev 33807
tests: verify that peer instances only expose interface members
Our abstract interfaces are more useful if we guarantee that
implementations conform to certain rules. Namely, we want to ensure
that objects implementing interfaces don't expose new public
attributes that aren't part of the interface. That way, as long as
consumers don't access "internal" attributes (those beginning with
"_") then (in theory) objects implementing interfaces can be swapped
out and everything will "just work."
We add a test that enforces our "no public attributes not part
of the abstract interface" rule.
We /could/ implement "interface compliance detection" at run-time.
However, that is littered with problems.
The obvious solutions are custom __new__ and __init__ methods.
These rely on derived types actually calling the parent's
implementation, which is no sure bet. Furthermore, __new__ and
__init__ will likely be called before instance-specific attributes
are assigned. In other words, they won't detect public attributes
set on self.__dict__. This means public attribute detection won't
be robust.
We could work around lack of robust self.__dict__ public attribute
detection by having our interfaces implement a custom __getattribute__,
__getattr__, and/or __setattr__. However, this incurs an undesirable
run-time penalty. And, subclasses could override our custom
method, bypassing the check.
The most robust solution is a non-runtime test. So that's what this
commit implements. We have a generic function for validating that an
object only has public attributes defined by abstract classes. Then,
we instantiate some peers and verify a newly constructed object
plays by the rules.
Differential Revision: https://phab.mercurial-scm.org/D339
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 10 Aug 2017 20:58:28 -0700] rev 33806
wireproto: use new peer interface
The wirepeer class provides concrete implementations of peer interface
methods for calling wire protocol commands. It makes sense for this
class to inherit from the peer abstract base class. So we change
that.
Since httppeer and sshpeer have already been converted to the new
interface, peerrepository is no longer adding any value. So it has
been removed. httppeer and sshpeer have been updated to reflect the
loss of peerrepository and the inheritance of the abstract base
class in wirepeer.
The code changes in wirepeer are reordering of methods to group
by interface.
Some Python code in tests was updated to reflect changed APIs.
.. api::
peer.peerrepository has been removed. Use repository.peer abstract
base class to represent a peer repository.
Differential Revision: https://phab.mercurial-scm.org/D338
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 06 Aug 2017 18:00:19 -0700] rev 33805
httppeer: use peer interface
This is similar to what we did to sshpeer. Quirks and all.
Differential Revision: https://phab.mercurial-scm.org/D337