mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +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
112 lines
4.1 KiB
Python
112 lines
4.1 KiB
Python
from __future__ import absolute_import
|
|
|
|
import shutil
|
|
import sys
|
|
import tempfile
|
|
|
|
from edenscm.mercurial import commands, hg, ui
|
|
from hghave import require
|
|
|
|
|
|
try:
|
|
from edenscm.hgext.hggit.git_handler import GitHandler
|
|
except ImportError:
|
|
print("skipped: missing feature: dulwich")
|
|
sys.exit(80)
|
|
|
|
|
|
class TestUrlParsing(object):
|
|
def setUp(self):
|
|
# create a test repo location.
|
|
self.tmpdir = tempfile.mkdtemp("hg-git_url-test")
|
|
commands.init(ui.ui(), self.tmpdir)
|
|
repo = hg.repository(ui.ui(), self.tmpdir)
|
|
self.handler = GitHandler(repo, ui.ui())
|
|
|
|
def tearDown(self):
|
|
# remove the temp repo
|
|
shutil.rmtree(self.tmpdir)
|
|
|
|
def assertEqual(self, l, r):
|
|
print("%% expect %r" % (r,))
|
|
print(l)
|
|
assert l == r
|
|
|
|
def test_ssh_github_style_slash(self):
|
|
url = "git+ssh://git@github.com/webjam/webjam.git"
|
|
client, path = self.handler.get_transport_and_path(url)
|
|
self.assertEqual(path, "/webjam/webjam.git")
|
|
self.assertEqual(client.host, "git@github.com")
|
|
|
|
def test_ssh_github_style_colon_number_starting_username(self):
|
|
url = "git+ssh://git@github.com:42qu/vps.git"
|
|
client, path = self.handler.get_transport_and_path(url)
|
|
self.assertEqual(path, "42qu/vps.git")
|
|
self.assertEqual(client.host, "git@github.com")
|
|
|
|
def test_ssh_github_style_colon(self):
|
|
url = "git+ssh://git@github.com:webjam/webjam.git"
|
|
client, path = self.handler.get_transport_and_path(url)
|
|
self.assertEqual(path, "webjam/webjam.git")
|
|
self.assertEqual(client.host, "git@github.com")
|
|
|
|
def test_ssh_heroku_style(self):
|
|
url = "git+ssh://git@heroku.com:webjam.git"
|
|
client, path = self.handler.get_transport_and_path(url)
|
|
self.assertEqual(path, "webjam.git")
|
|
self.assertEqual(client.host, "git@heroku.com")
|
|
# also test that it works even if heroku isn't in the name
|
|
url = "git+ssh://git@compatible.com:webjam.git"
|
|
client, path = self.handler.get_transport_and_path(url)
|
|
self.assertEqual(path, "webjam.git")
|
|
self.assertEqual(client.host, "git@compatible.com")
|
|
|
|
def test_ssh_heroku_style_with_trailing_slash(self):
|
|
# some versions of mercurial add a trailing slash even if
|
|
# the user didn't supply one.
|
|
url = "git+ssh://git@heroku.com:webjam.git/"
|
|
client, path = self.handler.get_transport_and_path(url)
|
|
self.assertEqual(path, "webjam.git")
|
|
self.assertEqual(client.host, "git@heroku.com")
|
|
|
|
def test_heroku_style_with_port(self):
|
|
url = "git+ssh://git@heroku.com:999:webjam.git"
|
|
client, path = self.handler.get_transport_and_path(url)
|
|
self.assertEqual(path, "webjam.git")
|
|
self.assertEqual(client.host, "git@heroku.com")
|
|
self.assertEqual(client.port, "999")
|
|
|
|
def test_gitdaemon_style(self):
|
|
url = "git://github.com/webjam/webjam.git"
|
|
client, path = self.handler.get_transport_and_path(url)
|
|
self.assertEqual(path, "/webjam/webjam.git")
|
|
try:
|
|
self.assertEqual(client._host, "github.com")
|
|
except AttributeError:
|
|
self.assertEqual(client.host, "github.com")
|
|
|
|
def test_ssh_github_style_slash_with_port(self):
|
|
url = "git+ssh://git@github.com:10022/webjam/webjam.git"
|
|
client, path = self.handler.get_transport_and_path(url)
|
|
self.assertEqual(path, "/webjam/webjam.git")
|
|
self.assertEqual(client.host, "git@github.com")
|
|
self.assertEqual(client.port, "10022")
|
|
|
|
def test_gitdaemon_style_with_port(self):
|
|
url = "git://github.com:19418/webjam/webjam.git"
|
|
client, path = self.handler.get_transport_and_path(url)
|
|
self.assertEqual(path, "/webjam/webjam.git")
|
|
try:
|
|
self.assertEqual(client._host, "github.com")
|
|
except AttributeError:
|
|
self.assertEqual(client.host, "github.com")
|
|
self.assertEqual(client._port, "19418")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
tc = TestUrlParsing()
|
|
for test in sorted([t for t in dir(tc) if t.startswith("test_")]):
|
|
tc.setUp()
|
|
getattr(tc, test)()
|
|
tc.tearDown()
|