Changeset - 62a1d4155f6b
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2011-03-13 01:22:29
marcin@python-works.com
let action always return pull command for better security on pull restricted repos
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/middleware/simplehg.py
Show inline comments
 
@@ -220,49 +220,49 @@ class SimpleHg(object):
 

	
 
        return repo_name
 

	
 
    def __get_user(self, username):
 
        return UserModel().get_by_username(username, cache=True)
 

	
 
    def __get_action(self, environ):
 
        """Maps mercurial request commands into a clone,pull or push command.
 
        This should always return a valid command string
 
        
 
        :param environ:
 
        """
 
        mapping = {'changegroup': 'pull',
 
                   'changegroupsubset': 'pull',
 
                   'stream_out': 'pull',
 
                   'listkeys': 'pull',
 
                   'unbundle': 'push',
 
                   'pushkey': 'push', }
 
        for qry in environ['QUERY_STRING'].split('&'):
 
            if qry.startswith('cmd'):
 
                cmd = qry.split('=')[-1]
 
                if mapping.has_key(cmd):
 
                    return mapping[cmd]
 
                else:
 
                    return cmd
 
                    return 'pull'
 

	
 
    def __invalidate_cache(self, repo_name):
 
        """we know that some change was made to repositories and we should
 
        invalidate the cache to see the changes right away but only for
 
        push requests"""
 
        invalidate_cache('get_repo_cached_%s' % repo_name)
 

	
 

	
 
    def __load_web_settings(self, hgserve, extras={}):
 
        #set the global ui for hgserve instance passed
 
        hgserve.repo.ui = self.baseui
 

	
 
        hgrc = os.path.join(self.repo_path, '.hg', 'hgrc')
 

	
 
        #inject some additional parameters that will be available in ui
 
        #for hooks
 
        for k, v in extras.items():
 
            hgserve.repo.ui.setconfig('rhodecode_extras', k, v)
 

	
 
        repoui = make_ui('file', hgrc, False)
 

	
 
        if repoui:
 
            #overwrite our ui instance with the section from hgrc file
 
            for section in ui_sections:
0 comments (0 inline, 0 general)