##// END OF EJS Templates
mercurial: replace ancestor to pure python version for hg 4.1 compatability problems....
mercurial: replace ancestor to pure python version for hg 4.1 compatability problems. this was moved now to debugcommands, but we don't need to run it via commands as the code is very simple.

File last commit:

r149:771d647d default
r163:41539c12 default
Show More
base.py
82 lines | 2.6 KiB | text/x-python | PythonLexer
initial commit
r0 # RhodeCode VCSServer provides access to different vcs backends via network.
license: updated copyright year to 2017
r149 # Copyright (C) 2014-2017 RodeCode GmbH
initial commit
r0 #
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import logging
remote-clone: obfuscate also given query string paramas that RhodeCode uses. Fixes #4668
r106 import urlparse
initial commit
r0
log = logging.getLogger(__name__)
class RepoFactory(object):
"""
Utility to create instances of repository
It provides internal caching of the `repo` object based on
the :term:`call context`.
"""
def __init__(self, repo_cache):
self._cache = repo_cache
def _create_config(self, path, config):
config = {}
return config
def _create_repo(self, wire, create):
raise NotImplementedError()
def repo(self, wire, create=False):
"""
Get a repository instance for the given path.
Uses internally the low level beaker API since the decorators introduce
significant overhead.
"""
def create_new_repo():
return self._create_repo(wire, create)
return self._repo(wire, create_new_repo)
def _repo(self, wire, createfunc):
context = wire.get('context', None)
cache = wire.get('cache', True)
if context and cache:
cache_key = (context, wire['path'])
log.debug(
'FETCH %s@%s repo object from cache. Context: %s',
self.__class__.__name__, wire['path'], context)
return self._cache.get(key=cache_key, createfunc=createfunc)
else:
log.debug(
'INIT %s@%s repo object based on wire %s. Context: %s',
self.__class__.__name__, wire['path'], wire, context)
return createfunc()
remote-clone: obfuscate also given query string paramas that RhodeCode uses. Fixes #4668
r106
def obfuscate_qs(query_string):
parse_qs: improved parsing of query string for obfuscation.
r107 if query_string is None:
return None
remote-clone: obfuscate also given query string paramas that RhodeCode uses. Fixes #4668
r106 parsed = []
parse_qs: improved parsing of query string for obfuscation.
r107 for k, v in urlparse.parse_qsl(query_string, keep_blank_values=True):
remote-clone: obfuscate also given query string paramas that RhodeCode uses. Fixes #4668
r106 if k in ['auth_token', 'api_key']:
v = "*****"
parsed.append((k, v))
parse_qs: improved parsing of query string for obfuscation.
r107 return '&'.join('{}{}'.format(
k, '={}'.format(v) if v else '') for k, v in parsed)