mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
98d9269874
Summary: Create a fork of the Mercurial code that we can use to build server rpms. The hg servers will continue to exist for a few more months while we move the darkstorm and ediscovery use cases off them. In the mean time, we want to start making breaking changes to the client, so let's create a stable copy of the hg code to produce rpms for the hg servers. The fork is based off c7770c78d, the latest hg release. This copies the files as is, then adds some minor tweaks to get it to build: - Disables some lint checks that appear to be bypassed by path - sed replace eden/scm with eden/hg-server - Removed a dependency on scm/telemetry from the edenfs-client tests since scm/telemetry pulls in the original eden/scm/lib/configparser which conflicts with the hg-server conflict parser. allow-large-files Reviewed By: quark-zju Differential Revision: D27632557 fbshipit-source-id: b2f442f4ec000ea08e4d62de068750832198e1f4
76 lines
1.9 KiB
Python
76 lines
1.9 KiB
Python
# Test that certain objects conform to well-defined interfaces.
|
|
|
|
from __future__ import absolute_import, print_function
|
|
|
|
from edenscm.mercurial import bundlerepo, httppeer, localrepo, sshpeer, ui as uimod
|
|
from hghave import require
|
|
|
|
|
|
def checkobject(o):
|
|
"""Verify a constructed object conforms to interface rules.
|
|
|
|
An object must have __abstractmethods__ defined.
|
|
|
|
All "public" attributes of the object (attributes not prefixed with
|
|
an underscore) must be in __abstractmethods__ or appear on a base class
|
|
with __abstractmethods__.
|
|
"""
|
|
name = o.__class__.__name__
|
|
|
|
allowed = set()
|
|
for cls in o.__class__.__mro__:
|
|
if not getattr(cls, "__abstractmethods__", set()):
|
|
continue
|
|
|
|
allowed |= cls.__abstractmethods__
|
|
allowed |= {a for a in dir(cls) if not a.startswith("_")}
|
|
|
|
if not allowed:
|
|
print("%s does not have abstract methods" % name)
|
|
return
|
|
|
|
public = {a for a in dir(o) if not a.startswith("_")}
|
|
|
|
for attr in sorted(public - allowed):
|
|
print("public attributes not in abstract interface: %s.%s" % (name, attr))
|
|
|
|
|
|
# Facilitates testing localpeer.
|
|
class dummyrepo(object):
|
|
def __init__(self):
|
|
self.ui = uimod.ui()
|
|
|
|
def filtered(self, name):
|
|
pass
|
|
|
|
def _restrictcapabilities(self, caps):
|
|
pass
|
|
|
|
|
|
# Facilitates testing sshpeer without requiring an SSH server.
|
|
class testingsshpeer(sshpeer.sshpeer):
|
|
def _validaterepo(self, *args, **kwargs):
|
|
pass
|
|
|
|
|
|
class badpeer(httppeer.httppeer):
|
|
def __init__(self):
|
|
super(badpeer, self).__init__(uimod.ui(), "http://localhost")
|
|
self.badattribute = True
|
|
|
|
def badmethod(self):
|
|
pass
|
|
|
|
|
|
def main():
|
|
ui = uimod.ui()
|
|
|
|
checkobject(badpeer())
|
|
checkobject(httppeer.httppeer(ui, "http://localhost"))
|
|
checkobject(localrepo.localpeer(dummyrepo()))
|
|
checkobject(testingsshpeer(ui, "ssh://localhost/foo"))
|
|
checkobject(bundlerepo.bundlepeer(dummyrepo()))
|
|
|
|
|
|
main()
|