diff --git a/docs/changelog.rst b/docs/changelog.rst --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -36,7 +36,8 @@ news - Implemented landing revisions. Each repository will get landing_rev attribute that defines 'default' revision/branch for generating readme files - Implemented #509, RhodeCode enforces SSL for push/pulling if requested. - +- Import remote svn repositories to mercurial using hgsubversion + fixes +++++ diff --git a/docs/usage/general.rst b/docs/usage/general.rst --- a/docs/usage/general.rst +++ b/docs/usage/general.rst @@ -82,4 +82,27 @@ Trending source files Trending source files are calculated based on pre defined dict of known types and extensions. If You miss some extension or Would like to scan some custom files it's possible to add new types in `LANGUAGES_EXTENSIONS_MAP` dict -located in `/rhodecode/lib/celerylib/tasks.py` \ No newline at end of file +located in `/rhodecode/lib/celerylib/tasks.py` + + +Cloning remote repositories +--------------------------- + +RhodeCode has an ability to clone remote repos from given remote locations. +Currently it support following options: + +- hg -> hg clone +- svn -> hg clone +- git -> git clone + + +.. note:: + + - *`svn -> hg` cloning requires `hgsubversion` library to be installed.* + +If you need to clone repositories that are protected via basic auth, you +might pass the url with stored credentials inside eg. +`http://user:passw@remote.server/repo, RhodeCode will try to login and clone +using given credentials. Please take a note that they will be stored as +plaintext inside the database. RhodeCode will remove auth info when showing the +clone url in summary page. diff --git a/rhodecode/lib/vcs/backends/git/repository.py b/rhodecode/lib/vcs/backends/git/repository.py --- a/rhodecode/lib/vcs/backends/git/repository.py +++ b/rhodecode/lib/vcs/backends/git/repository.py @@ -176,7 +176,7 @@ class GitRepository(BaseRepository): return resp.code == 200 except Exception, e: # means it cannot be cloned - raise urllib2.URLError(e) + raise urllib2.URLError("[%s] %s" % (url, e)) def _get_repo(self, create, src_url=None, update_after_clone=False, bare=False): diff --git a/rhodecode/lib/vcs/backends/hg/repository.py b/rhodecode/lib/vcs/backends/hg/repository.py --- a/rhodecode/lib/vcs/backends/hg/repository.py +++ b/rhodecode/lib/vcs/backends/hg/repository.py @@ -300,7 +300,7 @@ class MercurialRepository(BaseRepository return resp.code == 200 except Exception, e: # means it cannot be cloned - raise urllib2.URLError(e) + raise urllib2.URLError("[%s] %s" % (url, e)) def _get_repo(self, create, src_url=None, update_after_clone=False): """ @@ -312,6 +312,7 @@ class MercurialRepository(BaseRepository location at given clone_point. Additionally it'll make update to working copy accordingly to ``update_after_clone`` flag """ + try: if src_url: url = str(self._get_url(src_url)) @@ -325,6 +326,7 @@ class MercurialRepository(BaseRepository # raise Abort("Got HTTP 404 error") except Exception: raise + # Don't try to create if we've already cloned repo create = False return localrepository(self.baseui, self.path, create=create) diff --git a/rhodecode/model/validators.py b/rhodecode/model/validators.py --- a/rhodecode/model/validators.py +++ b/rhodecode/model/validators.py @@ -372,17 +372,29 @@ def ValidCloneUri(): def url_handler(repo_type, url, ui=None): if repo_type == 'hg': - from mercurial.httprepo import httprepository, httpsrepository - if url.startswith('https'): - httpsrepository(make_ui('db'), url).capabilities - elif url.startswith('http'): - httprepository(make_ui('db'), url).capabilities + from rhodecode.lib.vcs.backends.hg.repository import MercurialRepository + from mercurial.httppeer import httppeer + if url.startswith('http'): + ## initially check if it's at least the proper URL + ## or does it pass basic auth + MercurialRepository._check_url(url) + httppeer(make_ui('db'), url)._capabilities() elif url.startswith('svn+http'): from hgsubversion.svnrepo import svnremoterepo svnremoterepo(make_ui('db'), url).capabilities + elif url.startswith('git+http'): + raise NotImplementedError() + elif repo_type == 'git': - #TODO: write a git url validator - pass + from rhodecode.lib.vcs.backends.git.repository import GitRepository + if url.startswith('http'): + ## initially check if it's at least the proper URL + ## or does it pass basic auth + GitRepository._check_url(url) + elif url.startswith('svn+http'): + raise NotImplementedError() + elif url.startswith('hg+http'): + raise NotImplementedError() class _validator(formencode.validators.FancyValidator): messages = {