def get_transport_and_path(self, uri): # pass hg's ui.ssh config to dulwich if not issubclass(client.get_ssh_vendor, _ssh.SSHVendor): client.get_ssh_vendor = _ssh.generate_ssh_vendor(self.ui) for handler, transport in (("git://", client.TCPGitClient), ("git@", client.SSHGitClient), ("git+ssh://", client.SSHGitClient)): if uri.startswith(handler): # We need to split around : or /, whatever comes first hostpath = uri[len(handler):] if (hostpath.find(':') > 0 and hostpath.find('/') > 0): # we have both, whatever is first wins. if hostpath.find(':') < hostpath.find('/'): hostpath_seper = ':' else: hostpath_seper = '/' elif hostpath.find(':') > 0: hostpath_seper = ':' else: hostpath_seper = '/' host, path = hostpath.split(hostpath_seper, 1) if hostpath_seper == '/': transportpath = '/' + path else: transportpath = path return transport(host, thin_packs=False), transportpath # if its not git or git+ssh, try a local url.. return client.SubprocessGitClient(thin_packs=False), uri
def get_transport_and_path(self, uri): # pass hg's ui.ssh config to dulwich if not issubclass(client.get_ssh_vendor, _ssh.SSHVendor): client.get_ssh_vendor = _ssh.generate_ssh_vendor(self.ui) git_match = RE_GIT_URI.match(uri) if git_match: res = git_match.groupdict() transport = client.SSHGitClient if 'ssh' in res['scheme'] else client.TCPGitClient host, port, sepr, path = res['host'], res['port'], res['sepr'], res['path'] if sepr == '/': path = '/' + path # strip trailing slash for heroku-style URLs # ssh+git://[email protected]:project.git/ if sepr == ':' and path.endswith('.git/'): path = path.rstrip('/') if port: client.port = port return transport(host, thin_packs=False, port=port), path httpclient = getattr(client, 'HttpGitClient', None) if uri.startswith('git+http://') or uri.startswith('git+https://'): uri = uri[4:] if uri.startswith('http://') or uri.startswith('https://'): if not httpclient: raise RepoError('git via HTTP requires dulwich 0.8.1 or later') else: return client.HttpGitClient(uri, thin_packs=False), uri # if its not git or git+ssh, try a local url.. return client.SubprocessGitClient(thin_packs=False), uri
def get_transport_and_path(self, uri): # pass hg's ui.ssh config to dulwich if not issubclass(client.get_ssh_vendor, _ssh.SSHVendor): client.get_ssh_vendor = _ssh.generate_ssh_vendor(self.ui) for handler, transport in (("git://", client.TCPGitClient), ("git@", client.SSHGitClient), ("git+ssh://", client.SSHGitClient)): if uri.startswith(handler): # We need to split around : or /, whatever comes first hostpath = uri[len(handler):] if (hostpath.find(':') > 0 and hostpath.find('/') > 0): # we have both, whatever is first wins. if hostpath.find(':') < hostpath.find('/'): hostpath_seper = ':' else: hostpath_seper = '/' elif hostpath.find(':') > 0: hostpath_seper = ':' else: hostpath_seper = '/' port = None host, path = hostpath.split(hostpath_seper, 1) if hostpath_seper == '/': transportpath = '/' + path else: # port number should be recognized m = re.match('^(?P<port>\d+)?(?P<path>.*)$', path) if m.group('port'): client.port = m.group('port') port = client.port transportpath = m.group('path') else: transportpath = path return transport(host, thin_packs=False, port=port), transportpath httpclient = getattr(client, 'HttpGitClient', None) if uri.startswith('git+http://') or uri.startswith('git+https://'): uri = uri[4:] if uri.startswith('http://') or uri.startswith('https://'): if not httpclient: raise RepoError('git via HTTP requires dulwich 0.8.1 or later') else: return client.HttpGitClient(uri, thin_packs=False), uri # if its not git or git+ssh, try a local url.. return client.SubprocessGitClient(thin_packs=False), uri
def get_transport_and_path(self, uri): # pass hg's ui.ssh config to dulwich if not issubclass(client.get_ssh_vendor, _ssh.SSHVendor): client.get_ssh_vendor = _ssh.generate_ssh_vendor(self.ui) # Test for git:// and git+ssh:// URI. # Support several URL forms, including separating the # host and path with either a / or : (sepr) git_pattern = re.compile( r'^(?P<scheme>git([+]ssh)?://)(?P<host>.*?)(:(?P<port>\d+))?' r'(?P<sepr>[:/])(?P<path>.*)$') git_match = git_pattern.match(uri) if git_match: res = git_match.groupdict() transport = client.SSHGitClient if 'ssh' in res[ 'scheme'] else client.TCPGitClient host, port, sepr, path = res['host'], res['port'], res[ 'sepr'], res['path'] if sepr == '/': path = '/' + path # strip trailing slash for heroku-style URLs # ssh+git://[email protected]:project.git/ if sepr == ':' and path.endswith('.git/'): path = path.rstrip('/') if port: client.port = port return transport(host, thin_packs=False, port=port), path httpclient = getattr(client, 'HttpGitClient', None) if uri.startswith('git+http://') or uri.startswith('git+https://'): uri = uri[4:] if uri.startswith('http://') or uri.startswith('https://'): if not httpclient: raise RepoError('git via HTTP requires dulwich 0.8.1 or later') else: return client.HttpGitClient(uri, thin_packs=False), uri # if its not git or git+ssh, try a local url.. return client.SubprocessGitClient(thin_packs=False), uri
def get_transport_and_path(self, uri): # pass hg's ui.ssh config to dulwich if not issubclass(client.get_ssh_vendor, _ssh.SSHVendor): client.get_ssh_vendor = _ssh.generate_ssh_vendor(self.ui) for handler, transport in ( ("git://", client.TCPGitClient), ("git@", client.SSHGitClient), ("git+ssh://", client.SSHGitClient), ): if uri.startswith(handler): # We need to split around : or /, whatever comes first hostpath = uri[len(handler) :] if hostpath.find(":") > 0 and hostpath.find("/") > 0: # we have both, whatever is first wins. if hostpath.find(":") < hostpath.find("/"): hostpath_seper = ":" else: hostpath_seper = "/" elif hostpath.find(":") > 0: hostpath_seper = ":" else: hostpath_seper = "/" port = None host, path = hostpath.split(hostpath_seper, 1) if hostpath_seper == "/": transportpath = "/" + path else: # port number should be recognized m = re.match("^(?P<port>\d+)?(?P<path>.*)$", path) if m.group("port"): client.port = m.group("port") port = client.port transportpath = m.group("path") else: transportpath = path return transport(host, thin_packs=False, port=port), transportpath # if its not git or git+ssh, try a local url.. return client.SubprocessGitClient(thin_packs=False), uri