def git_hash(repo, rev): hggitpath=None hggitname=None for hggitname in ['hggit', 'git']: hggitpath=repo.ui.config('extensions', hggitname) if hggitpath is not None: break if hggitpath is None: vim_throw('nohggitc') import sys sys.path.insert(0, hggitpath) try: try: if hggitname=='hggit': from hggit.git_handler import GitHandler elif hggitname=='git': from git.git_handler import GitHandler except ImportError: vim_throw('nohggit') git=GitHandler(repo, repo.ui) cs=g_cs(repo, rev) r=git.map_git_get(cs.hex()) if r is None: vim_throw('nogitrev', cs.hex(), repo.path) return {'git_hex': r} finally: sys.path.pop(0)
def git_hash(repo, rev): hggitpath = None hggitname = None for hggitname in ['hggit', 'git']: hggitpath = repo.ui.config('extensions', hggitname) if hggitpath is not None: break if hggitpath is None: vim_throw('nohggitc') import sys sys.path.insert(0, hggitpath) try: try: if hggitname == 'hggit': from hggit.git_handler import GitHandler elif hggitname == 'git': from git.git_handler import GitHandler except ImportError: vim_throw('nohggit') git = GitHandler(repo, repo.ui) cs = g_cs(repo, rev) r = git.map_git_get(cs.hex()) if r is None: vim_throw('nogitrev', cs.hex(), repo.path) return {'git_hex': r} finally: sys.path.pop(0)
def setUp(self): # create a test repo location. self.tmpdir = tempfile.mkdtemp('hg-git_url-test') self.tmpdir = util.to_bytes(self.tmpdir) commands.init(ui.ui(), self.tmpdir) repo = hg.repository(ui.ui(), self.tmpdir) self.handler = GitHandler(repo, ui.ui())
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 assertEquals(self, l, r): print '%% expect %r' % (r, ) print l assert l == r def test_ssh_github_style_slash(self): url = "git+ssh://[email protected]/webjam/webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, '/webjam/webjam.git') self.assertEquals(client.host, '*****@*****.**') def test_ssh_github_style_colon(self): url = "git+ssh://[email protected]:webjam/webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, 'webjam/webjam.git') self.assertEquals(client.host, '*****@*****.**') def test_ssh_heroku_style(self): url = "git+ssh://[email protected]:webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, 'webjam.git') self.assertEquals(client.host, '*****@*****.**') def test_gitdaemon_style(self): url = "git://github.com/webjam/webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, '/webjam/webjam.git') try: self.assertEquals(client._host, 'github.com') except AttributeError: self.assertEquals(client.host, 'github.com')
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())
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 assertEquals(self, l, r): print '%% expect %r' % (r, ) print l assert l == r def test_ssh_github_style_slash(self): url = "git+ssh://[email protected]/webjam/webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, '/webjam/webjam.git') self.assertEquals(client.host, '*****@*****.**') def test_ssh_github_style_colon_number_starting_username(self): url = "git+ssh://[email protected]:42qu/vps.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, '42qu/vps.git') self.assertEquals(client.host, '*****@*****.**') def test_ssh_github_style_colon(self): url = "git+ssh://[email protected]:webjam/webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, 'webjam/webjam.git') self.assertEquals(client.host, '*****@*****.**') def test_ssh_heroku_style(self): url = "git+ssh://[email protected]:webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, 'webjam.git') self.assertEquals(client.host, '*****@*****.**') # also test that it works even if heroku isn't in the name url = "git+ssh://[email protected]:webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, 'webjam.git') self.assertEquals(client.host, '*****@*****.**') 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://[email protected]:webjam.git/" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, 'webjam.git') self.assertEquals(client.host, '*****@*****.**') def test_heroku_style_with_port(self): url = "git+ssh://[email protected]:999:webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, 'webjam.git') self.assertEquals(client.host, '*****@*****.**') self.assertEquals(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.assertEquals(path, '/webjam/webjam.git') try: self.assertEquals(client._host, 'github.com') except AttributeError: self.assertEquals(client.host, 'github.com') def test_ssh_github_style_slash_with_port(self): url = "git+ssh://[email protected]:10022/webjam/webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, '/webjam/webjam.git') self.assertEquals(client.host, '*****@*****.**') self.assertEquals(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.assertEquals(path, '/webjam/webjam.git') try: self.assertEquals(client._host, 'github.com') except AttributeError: self.assertEquals(client.host, 'github.com') self.assertEquals(client._port, '19418')
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 assertEquals(self, l, r): print '%% expect %r' % (r, ) print l assert l == r def test_ssh_github_style_slash(self): url = "git+ssh://[email protected]/webjam/webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, '/webjam/webjam.git') self.assertEquals(client.host, '*****@*****.**') def test_ssh_github_style_colon(self): url = "git+ssh://[email protected]:webjam/webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, 'webjam/webjam.git') self.assertEquals(client.host, '*****@*****.**') def test_ssh_heroku_style(self): url = "git+ssh://[email protected]:webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, 'webjam.git') self.assertEquals(client.host, '*****@*****.**') # also test that it works even if heroku isn't in the name url = "git+ssh://[email protected]:webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, 'webjam.git') self.assertEquals(client.host, '*****@*****.**') 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://[email protected]:webjam.git/" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, 'webjam.git') self.assertEquals(client.host, '*****@*****.**') def test_heroku_style_with_port(self): url = "git+ssh://[email protected]:999:webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, 'webjam.git') self.assertEquals(client.host, '*****@*****.**') self.assertEquals(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.assertEquals(path, '/webjam/webjam.git') try: self.assertEquals(client._host, 'github.com') except AttributeError: self.assertEquals(client.host, 'github.com') def test_ssh_github_style_slash_with_port(self): url = "git+ssh://[email protected]:10022/webjam/webjam.git" client, path = self.handler.get_transport_and_path(url) self.assertEquals(path, '/webjam/webjam.git') self.assertEquals(client.host, '*****@*****.**') self.assertEquals(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.assertEquals(path, '/webjam/webjam.git') try: self.assertEquals(client._host, 'github.com') except AttributeError: self.assertEquals(client.host, 'github.com') self.assertEquals(client._port, '19418')