Commits

Marcin Kuzminski committed ce51ef2 Merge

merged default with demo

Comments (0)

Files changed (6)

 Features
 --------
 
-- Has it's own middleware to handle mercurial_ protocol request. Each request can 
-  be logged and authenticated. Runs on threads unlikely to hgweb You can make
-  multiple pulls/pushes simultaneous
+- Has it's own middleware to handle mercurial_ protocol request. Each request 
+  can be logged and authenticated. Runs on threads unlikely to hgweb You can 
+  make multiple pulls/pushes simultaneous. Supports http/https
 - Full permissions and authentication per project private/read/write/admin. 
   One account for web interface and mercurial_ push/pull/clone.
 - Mako templates let's you customize look and feel of application.
 --------
 
 - code review (probably based on hg-review)
-- git_ support (when vcs_ can handle it - it's almost there !)
+- full git_ support, with push/pull server
 - commit based build in wiki system
-- clone points and cloning from remote repositories into rhodecode (git_ and mercurial_)
+- clone points and cloning from remote repositories into rhodecode 
+  (git_ and mercurial_)
 - some cache optimizations
 - other cools stuff that i can figure out (or You can help me figure out)
 
 Features
 --------
 
-- Has it's own middleware to handle mercurial_ protocol request. Each request can 
-  be logged and authenticated. Runs on threads unlikely to hgweb You can make
-  multiple pulls/pushes simultaneous
+- Has it's own middleware to handle mercurial_ protocol request. Each request 
+  can be logged and authenticated. Runs on threads unlikely to hgweb You can 
+  make multiple pulls/pushes simultaneous. Supports http/https
 - Full permissions and authentication per project private/read/write/admin. 
   One account for web interface and mercurial_ push/pull/clone.
 - Mako templates let's you customize look and feel of application.
 --------
 
 - code review (probably based on hg-review)
-- git_ support (when vcs_ can handle it - it's almost there !)
+- full git_ support, with push/pull server
 - commit based build in wiki system
-- clone points and cloning from remote repositories into rhodecode (git_ and mercurial_)
+- clone points and cloning from remote repositories into rhodecode 
+  (git_ and mercurial_)
 - some cache optimizations
 - other cools stuff that i can figure out (or You can help me figure out)
 

rhodecode/config/routing.py

 
     #MAIN PAGE
     map.connect('hg_home', '/', controller='hg', action='index')
-
+    map.connect('bugtracker', "http://bitbucket.org/marcinkuzminski/rhodecode/issues", _static=True)
+    map.connect('gpl_license', "http://www.gnu.org/licenses/gpl.html", _static=True)
     #ADMIN REPOSITORY REST ROUTES
     with map.submapper(path_prefix='/_admin', controller='admin/repos') as m:
         m.connect("repos", "/repos",

rhodecode/lib/middleware/simplegit.py

 #!/usr/bin/env python
 # encoding: utf-8
-# middleware to handle mercurial api calls
+# middleware to handle git api calls
 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
 #
 # This program is free software; you can redistribute it and/or
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
+from dulwich import server as dulserver
+
+class SimpleGitUploadPackHandler(dulserver.UploadPackHandler):
+
+    def handle(self):
+        write = lambda x: self.proto.write_sideband(1, x)
+
+        graph_walker = dulserver.ProtocolGraphWalker(self, self.repo.object_store,
+            self.repo.get_peeled)
+        objects_iter = self.repo.fetch_objects(
+          graph_walker.determine_wants, graph_walker, self.progress,
+          get_tagged=self.get_tagged)
+
+        # Do they want any objects?
+        if len(objects_iter) == 0:
+            return
+
+        self.progress("counting objects: %d, done.\n" % len(objects_iter))
+        dulserver.write_pack_data(dulserver.ProtocolFile(None, write), objects_iter,
+                        len(objects_iter))
+        messages = []
+        messages.append('thank you for using rhodecode')
+
+        for msg in messages:
+            self.progress(msg + "\n")
+        # we are done
+        self.proto.write("0000")
+
+dulserver.DEFAULT_HANDLERS = {
+  'git-upload-pack': SimpleGitUploadPackHandler,
+  'git-receive-pack': dulserver.ReceivePackHandler,
+}
+
 from dulwich.repo import Repo
-from dulwich.server import DictBackend
 from dulwich.web import HTTPGitApplication
-from itertools import chain
 from paste.auth.basic import AuthBasicAuthenticator
 from paste.httpheaders import REMOTE_USER, AUTH_TYPE
 from rhodecode.lib.auth import authfunc, HasPermissionAnyMiddleware, \
 Created on 2010-04-28
 
 @author: marcink
-SimpleHG middleware for handling mercurial protocol request (push/clone etc.)
+SimpleGit middleware for handling git protocol request (push/clone etc.)
 It's implemented with basic auth function
 """
 
 
 
-
 log = logging.getLogger(__name__)
 
 class SimpleGit(object):
     def __init__(self, application, config):
         self.application = application
         self.config = config
-        #authenticate this mercurial request using 
+        #authenticate this git request using 
         self.authenticate = AuthBasicAuthenticator('', authfunc)
 
     def __call__(self, environ, start_response):
             return self.application(environ, start_response)
 
         #===================================================================
-        # AUTHENTICATE THIS MERCURIAL REQUEST
+        # AUTHENTICATE THIS GIT REQUEST
         #===================================================================
         username = REMOTE_USER(environ)
         if not username:
             messages = []
             messages.append('thank you for using rhodecode')
             return app(environ, start_response)
-            #TODO: check other alternatives for msg wrapping
-            #return self.msg_wrapper(app, environ, start_response, messages)
         else:
             return app(environ, start_response)
 
 
-    def msg_wrapper(self, app, environ, start_response, messages=[]):
-        """
-        Wrapper for custom messages that come out of mercurial respond messages
-        is a list of messages that the user will see at the end of response 
-        from merurial protocol actions that involves remote answers
-        :param app:
-        :param environ:
-        :param start_response:
-        """
-        def custom_messages(msg_list):
-            for msg in msg_list:
-                yield msg + '\n'
-        org_response = app(environ, start_response)
-        return chain(org_response, custom_messages(messages))
-
-
     def __make_app(self):
-        backend = DictBackend({'/' + self.repo_name: Repo(self.repo_path)})
+        backend = dulserver.DictBackend({'/' + self.repo_name: Repo(self.repo_path)})
         gitserve = HTTPGitApplication(backend)
 
         return gitserve
         service = environ['QUERY_STRING'].split('=')
         if len(service) > 1:
             service_cmd = service[1]
-            mapping = {'git-receive-pack': 'pull',
-                       'git-upload-pack': 'push',
+            mapping = {'git-receive-pack': 'push',
+                       'git-upload-pack': 'pull',
                        }
 
-            return mapping.get(service_cmd, service_cmd)
+            return mapping.get(service_cmd, service_cmd if service_cmd else 'other')
+        else:
+            return 'other'
 
     def __log_user_action(self, user, action, repo, ipaddr):
         action_logger(user, action, repo, ipaddr)

rhodecode/public/css/style.css

 color:#FFF;
 font-weight:700;
 }
+#footer div#footer-inner .footer-link {
+float:left;
+padding-left:10px;
+}
+#footer div#footer-inner .footer-link a {
+color:#FFF; 
+}
 
 #login div.title {
 width:420px;

rhodecode/templates/base/base.html

 	<!-- footer -->
 	<div id="footer">
 	   <div id="footer-inner" class="title bottom-left-rounded-corner bottom-right-rounded-corner">
-	    <p>RhodeCode ${c.rhodecode_version} &copy; 2010 by Marcin Kuzminski</p>
+	       <div>
+	           <p class="footer-link">${h.link_to(_('Submit a bug'),h.url('bugtracker'))}</p>
+		       <p class="footer-link">${h.link_to(_('GPL license'),h.url('gpl_license'))}</p>
+		       <p>RhodeCode ${c.rhodecode_version} &copy; 2010 by Marcin Kuzminski</p>
+	       </div>
 	   </div>
         <script type="text/javascript">${h.tooltip.activate()}</script>
 	</div>