Changeset - 22f79562836c
[Not reviewed]
beta
0 5 0
Marcin Kuzminski - 13 years ago 2012-08-08 22:37:40
marcin@python-works.com
Fixed validators for remote repos
- use proper httppeer repo for mercurial 2.3
- validate git repos for remote auth
- docs updates
5 files changed with 49 insertions and 11 deletions:
0 comments (0 inline, 0 general)
docs/changelog.rst
Show inline comments
 
@@ -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
 
+++++
docs/usage/general.rst
Show inline comments
 
@@ -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.
rhodecode/lib/vcs/backends/git/repository.py
Show inline comments
 
@@ -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):
rhodecode/lib/vcs/backends/hg/repository.py
Show inline comments
 
@@ -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)
rhodecode/model/validators.py
Show inline comments
 
@@ -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 = {
0 comments (0 inline, 0 general)