changeset 2706:22f79562836c beta

Fixed validators for remote repos - use proper httppeer repo for mercurial 2.3 - validate git repos for remote auth - docs updates
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 08 Aug 2012 22:37:40 +0200
parents bf177b4981c3
children aa89767753a9
files docs/changelog.rst docs/usage/general.rst rhodecode/lib/vcs/backends/git/repository.py rhodecode/lib/vcs/backends/hg/repository.py rhodecode/model/validators.py
diffstat 5 files changed, 49 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/docs/changelog.rst	Wed Aug 08 22:35:05 2012 +0200
+++ b/docs/changelog.rst	Wed Aug 08 22:37:40 2012 +0200
@@ -36,7 +36,8 @@
 - 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
 +++++
--- a/docs/usage/general.rst	Wed Aug 08 22:35:05 2012 +0200
+++ b/docs/usage/general.rst	Wed Aug 08 22:37:40 2012 +0200
@@ -82,4 +82,27 @@
 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.
--- a/rhodecode/lib/vcs/backends/git/repository.py	Wed Aug 08 22:35:05 2012 +0200
+++ b/rhodecode/lib/vcs/backends/git/repository.py	Wed Aug 08 22:37:40 2012 +0200
@@ -176,7 +176,7 @@
             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):
--- a/rhodecode/lib/vcs/backends/hg/repository.py	Wed Aug 08 22:35:05 2012 +0200
+++ b/rhodecode/lib/vcs/backends/hg/repository.py	Wed Aug 08 22:37:40 2012 +0200
@@ -300,7 +300,7 @@
             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 @@
         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 @@
 #                    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)
--- a/rhodecode/model/validators.py	Wed Aug 08 22:35:05 2012 +0200
+++ b/rhodecode/model/validators.py	Wed Aug 08 22:37:40 2012 +0200
@@ -372,17 +372,29 @@
 
     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 = {