Changeset - b8c69e4deacd
[Not reviewed]
default
0 6 0
Thomas De Schampheleire - 11 years ago 2015-01-24 22:07:35
thomas.de_schampheleire@alcatel-lucent.com
remotes: add support to clone from Mercurial repositories over ssh

This commit adds support to clone a remote Mercurial repository over ssh.

Interactive password authentication is not implemented, nor is support for
pbulic key authentication with passphrases; the repository should be
accessible using bare ssh key authentication.
For this reason, the ssh options -oBatchMode=yes and -oIdentitiesOnly=yes
are added to the ui.ssh setting of Mercurial.
6 files changed with 17 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/utils.py
Show inline comments
 
@@ -381,6 +381,11 @@ def make_ui(read_from='file', path=None,
 
                                 False)
 
        if clear_session:
 
            meta.Session.remove()
 

	
 
        # prevent interactive questions for ssh password / passphrase
 
        ssh = baseui.config('ui', 'ssh', default='ssh')
 
        baseui.setconfig('ui', 'ssh', '%s -oBatchMode=yes -oIdentitiesOnly=yes' % ssh)
 

	
 
    return baseui
 

	
 

	
kallithea/lib/vcs/backends/hg/repository.py
Show inline comments
 
@@ -31,7 +31,7 @@ from kallithea.lib.vcs.utils.paths impor
 
from kallithea.lib.vcs.utils.hgcompat import (
 
    ui, nullid, match, patch, diffopts, clone, get_contact, pull,
 
    localrepository, RepoLookupError, Abort, RepoError, hex, scmutil, hg_url,
 
    httpbasicauthhandler, httpdigestauthhandler, peer, httppeer
 
    httpbasicauthhandler, httpdigestauthhandler, peer, httppeer, sshpeer
 
)
 

	
 
from .changeset import MercurialChangeset
 
@@ -282,6 +282,12 @@ class MercurialRepository(BaseRepository
 
        if os.path.isdir(url) or url.startswith('file:'):
 
            return True
 

	
 
        if url.startswith('ssh:'):
 
            # in case of invalid uri or authentication issues, sshpeer will
 
            # throw an exception.
 
            sshpeer(repoui or ui.ui(), url).lookup('tip')
 
            return True
 

	
 
        url_prefix = None
 
        if '+' in url[:url.find('://')]:
 
            url_prefix, url = url.split('+', 1)
kallithea/lib/vcs/utils/hgcompat.py
Show inline comments
 
@@ -25,6 +25,7 @@ from mercurial.encoding import tolocal
 
from mercurial.discovery import findcommonoutgoing
 
from mercurial.hg import peer
 
from mercurial.httppeer import httppeer
 
from mercurial.sshpeer import sshpeer
 
from mercurial.util import url as hg_url
 
from mercurial.scmutil import revrange
 
from mercurial.node import nullrev
kallithea/model/validators.py
Show inline comments
 
@@ -444,7 +444,7 @@ def ValidCloneUri():
 
    def url_handler(repo_type, url, ui):
 
        if repo_type == 'hg':
 
            from kallithea.lib.vcs.backends.hg.repository import MercurialRepository
 
            if url.startswith('http'):
 
            if url.startswith('http') or url.startswith('ssh'):
 
                # initially check if it's at least the proper URL
 
                # or does it pass basic auth
 
                MercurialRepository._check_url(url, ui)
 
@@ -473,7 +473,7 @@ def ValidCloneUri():
 
        messages = {
 
            'clone_uri': _(u'invalid clone url'),
 
            'invalid_clone_uri': _(u'Invalid clone url, provide a '
 
                                    'valid clone http(s)/svn+http(s) url')
 
                                    'valid clone http(s)/svn+http(s)/ssh url')
 
        }
 

	
 
        def validate_python(self, value, state):
kallithea/templates/admin/repos/repo_add_base.html
Show inline comments
 
@@ -24,7 +24,7 @@ ${h.form(url('repos'))}
 
            </div>
 
            <div class="input">
 
                ${h.text('clone_uri',class_="small")}
 
                <span class="help-block">${_('Optional http[s] url from which repository should be cloned.')}</span>
 
                <span class="help-block">${_('Optional url from which repository should be cloned.')}</span>
 
            </div>
 
        </div>
 
        <div class="field">
kallithea/templates/admin/repos/repo_edit_settings.html
Show inline comments
 
@@ -34,7 +34,7 @@ ${h.form(url('repo', repo_name=c.repo_in
 
                    ${h.text('clone_uri',class_="medium")}
 
                    ${h.hidden('clone_uri_change', 'NEW')}
 
                   %endif
 
                 <span id="alter_clone_uri_help_block" class="help-block">${_('http[s] url used for doing remote pulls.')}</span>
 
                 <span id="alter_clone_uri_help_block" class="help-block">${_('Url used for doing remote pulls.')}</span>
 
               </div>
 
            </div>
 
            <div class="field">
0 comments (0 inline, 0 general)