Changeset - e67b2ef07a8e
[Not reviewed]
beta
0 7 0
Marcin Kuzminski - 13 years ago 2013-02-17 22:58:09
marcin@python-works.com
git executable is now configurable via .ini files
7 files changed with 47 insertions and 24 deletions:
0 comments (0 inline, 0 general)
development.ini
Show inline comments
 
@@ -40,12 +40,14 @@ pdebug = false
 
#use_threadpool = true
 

	
 
#use = egg:Paste#http
 

	
 
#WAITRESS
 
threads = 5
 
#100GB
 
max_request_body_size = 107374182400
 
use = egg:waitress#main
 

	
 
host = 0.0.0.0
 
port = 5000
 

	
 
[filter:proxy-prefix]
 
@@ -72,12 +74,15 @@ force_https = false
 
use_htsts = false
 
commit_parse_limit = 25
 
# number of items displayed in lightweight dashboard before paginating
 
dashboard_items = 100
 
use_gravatar = true
 

	
 
# path to git executable
 
git_path = git
 

	
 
## RSS feed options
 

	
 
rss_cut_off_limit = 256000
 
rss_items_per_page = 10
 
rss_include_diff = false
 

	
production.ini
Show inline comments
 
@@ -40,12 +40,14 @@ pdebug = false
 
#use_threadpool = true
 

	
 
#use = egg:Paste#http
 

	
 
#WAITRESS
 
threads = 5
 
#100GB
 
max_request_body_size = 107374182400
 
use = egg:waitress#main
 

	
 
host = 127.0.0.1
 
port = 8001
 

	
 
[filter:proxy-prefix]
 
@@ -72,12 +74,15 @@ force_https = false
 
use_htsts = false
 
commit_parse_limit = 50
 
# number of items displayed in lightweight dashboard before paginating
 
dashboard_items = 100
 
use_gravatar = true
 

	
 
# path to git executable
 
git_path = git
 

	
 
## RSS feed options
 

	
 
rss_cut_off_limit = 256000
 
rss_items_per_page = 10
 
rss_include_diff = false
 

	
rhodecode/config/deployment.ini_tmpl
Show inline comments
 
@@ -40,12 +40,14 @@ pdebug = false
 
#use_threadpool = true
 

	
 
#use = egg:Paste#http
 

	
 
#WAITRESS
 
threads = 5
 
#100GB
 
max_request_body_size = 107374182400
 
use = egg:waitress#main
 

	
 
host = 127.0.0.1
 
port = 5000
 

	
 
[filter:proxy-prefix]
 
@@ -72,12 +74,15 @@ force_https = false
 
use_htsts = false
 
commit_parse_limit = 50
 
# number of items displayed in lightweight dashboard before paginating
 
dashboard_items = 100
 
use_gravatar = true
 

	
 
# path to git executable
 
git_path = git
 

	
 
## RSS feed options
 

	
 
rss_cut_off_limit = 256000
 
rss_items_per_page = 10
 
rss_include_diff = false
 

	
rhodecode/lib/middleware/pygrack.py
Show inline comments
 
@@ -3,12 +3,13 @@ import socket
 
import logging
 
import subprocess
 
import traceback
 

	
 
from webob import Request, Response, exc
 

	
 
import rhodecode
 
from rhodecode.lib import subprocessio
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class FileWrapper(object):
 
@@ -79,16 +80,17 @@ class GitRepository(object):
 
        # The code in Git client not only does NOT need '\n', but actually
 
        # blows up if you sprinkle "flush" (0000) as "0001\n".
 
        # It reads binary, per number of bytes specified.
 
        # if you do add '\n' as part of data, count it.
 
        server_advert = '# service=%s' % git_command
 
        packet_len = str(hex(len(server_advert) + 4)[2:].rjust(4, '0')).lower()
 
        _git_path = rhodecode.CONFIG.get('git_path', 'git')
 
        try:
 
            out = subprocessio.SubprocessIOChunker(
 
                r'git %s --stateless-rpc --advertise-refs "%s"' % (
 
                                git_command[4:], self.content_path),
 
                r'%s %s --stateless-rpc --advertise-refs "%s"' % (
 
                            _git_path, git_command[4:], self.content_path),
 
                starting_values=[
 
                    packet_len + server_advert + '0000'
 
                ]
 
            )
 
        except EnvironmentError, e:
 
            log.error(traceback.format_exc())
 
@@ -139,14 +141,15 @@ class GitRepository(object):
 
            log.error(traceback.format_exc())
 
            raise exc.HTTPExpectationFailed()
 

	
 
        if git_command in [u'git-receive-pack']:
 
            # updating refs manually after each push.
 
            # Needed for pre-1.7.0.4 git clients using regular HTTP mode.
 
            cmd = (u'git --git-dir "%s" '
 
                    'update-server-info' % self.content_path)
 
            _git_path = rhodecode.CONFIG.get('git_path', 'git')
 
            cmd = (u'%s --git-dir "%s" '
 
                    'update-server-info' % (_git_path, self.content_path))
 
            log.debug('handling cmd %s' % cmd)
 
            subprocess.call(cmd, shell=True)
 

	
 
        resp = Response()
 
        resp.content_type = 'application/x-%s-result' % git_command.encode('utf8')
 
        resp.charset = None
rhodecode/lib/utils.py
Show inline comments
 
@@ -741,19 +741,18 @@ class BasePasterCommand(Command):
 

	
 
def check_git_version():
 
    """
 
    Checks what version of git is installed in system, and issues a warning
 
    if it's too old for RhodeCode to properly work.
 
    """
 
    import subprocess
 
    from rhodecode import BACKENDS
 
    from rhodecode.lib.vcs.backends.git.repository import GitRepository
 
    from distutils.version import StrictVersion
 
    from rhodecode import BACKENDS
 

	
 
    p = subprocess.Popen('git --version', shell=True,
 
                        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 
    stdout, stderr = p.communicate()
 
    stdout, stderr = GitRepository._run_git_command('--version')
 

	
 
    ver = (stdout.split(' ')[-1] or '').strip() or '0.0.0'
 
    if len(ver.split('.')) > 3:
 
        #StrictVersion needs to be only 3 element type
 
        ver = '.'.join(ver.split('.')[:3])
 
    try:
 
        _ver = StrictVersion(ver)
rhodecode/lib/vcs/backends/git/changeset.py
Show inline comments
 
import re
 
from itertools import chain
 
from dulwich import objects
 
from subprocess import Popen, PIPE
 
import rhodecode
 
from rhodecode.lib.vcs.conf import settings
 
from rhodecode.lib.vcs.exceptions import RepositoryError
 
from rhodecode.lib.vcs.exceptions import ChangesetError
 
from rhodecode.lib.vcs.exceptions import NodeDoesNotExistError
 
from rhodecode.lib.vcs.exceptions import VCSError
 
from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
 
@@ -359,14 +360,15 @@ class GitChangeset(BaseChangeset):
 
            raise VCSError("Prefix cannot be empty")
 

	
 
        if kind == 'zip':
 
            frmt = 'zip'
 
        else:
 
            frmt = 'tar'
 
        cmd = 'git archive --format=%s --prefix=%s/ %s' % (frmt, prefix,
 
            self.raw_id)
 
        _git_path = rhodecode.CONFIG.get('git_path', 'git')
 
        cmd = '%s archive --format=%s --prefix=%s/ %s' % (_git_path, 
 
                                                frmt, prefix, self.raw_id)
 
        if kind == 'tgz':
 
            cmd += ' | gzip -9'
 
        elif kind == 'tbz2':
 
            cmd += ' | bzip2 -9'
 

	
 
        if stream is None:
rhodecode/lib/vcs/backends/git/repository.py
Show inline comments
 
@@ -17,13 +17,14 @@ import logging
 
import traceback
 
import urllib
 
import urllib2
 
from dulwich.repo import Repo, NotGitRepository
 
from dulwich.objects import Tag
 
from string import Template
 
from subprocess import Popen, PIPE
 

	
 
import rhodecode
 
from rhodecode.lib.vcs.backends.base import BaseRepository
 
from rhodecode.lib.vcs.exceptions import BranchDoesNotExistError
 
from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
 
from rhodecode.lib.vcs.exceptions import EmptyRepositoryError
 
from rhodecode.lib.vcs.exceptions import RepositoryError
 
from rhodecode.lib.vcs.exceptions import TagAlreadyExistError
 
@@ -88,23 +89,20 @@ class GitRepository(BaseRepository):
 
        """
 
        Returns list of revisions' ids, in ascending order.  Being lazy
 
        attribute allows external tools to inject shas from cache.
 
        """
 
        return self._get_all_revisions()
 

	
 
    def run_git_command(self, cmd):
 
    @classmethod
 
    def _run_git_command(cls, cmd, **opts):
 
        """
 
        Runs given ``cmd`` as git command and returns tuple
 
        (returncode, stdout, stderr).
 

	
 
        .. note::
 
           This method exists only until log/blame functionality is implemented
 
           at Dulwich (see https://bugs.launchpad.net/bugs/645142). Parsing
 
           os command's output is road to hell...
 
        (stdout, stderr).
 

	
 
        :param cmd: git command to be executed
 
        :param opts: env options to pass into Subprocess command
 
        """
 

	
 
        _copts = ['-c', 'core.quotepath=false', ]
 
        _str_cmd = False
 
        if isinstance(cmd, basestring):
 
            cmd = [cmd]
 
@@ -113,30 +111,36 @@ class GitRepository(BaseRepository):
 
        gitenv = os.environ
 
        # need to clean fix GIT_DIR !
 
        if 'GIT_DIR' in gitenv:
 
            del gitenv['GIT_DIR']
 
        gitenv['GIT_CONFIG_NOGLOBAL'] = '1'
 

	
 
        cmd = ['git'] + _copts + cmd
 
        _git_path = rhodecode.CONFIG.get('git_path', 'git')
 
        cmd = [_git_path] + _copts + cmd
 
        if _str_cmd:
 
            cmd = ' '.join(cmd)
 
        try:
 
            opts = dict(
 
            _opts = dict(
 
                env=gitenv,
 
                shell=False,
 
            )
 
            if os.path.isdir(self.path):
 
                opts['cwd'] = self.path
 
            p = subprocessio.SubprocessIOChunker(cmd, **opts)
 
            _opts.update(opts)
 
            p = subprocessio.SubprocessIOChunker(cmd, **_opts)
 
        except (EnvironmentError, OSError), err:
 
            log.error(traceback.format_exc())
 
            raise RepositoryError("Couldn't run git command (%s).\n"
 
                                  "Original error was:%s" % (cmd, err))
 

	
 
        return ''.join(p.output), ''.join(p.error)
 

	
 
    def run_git_command(self, cmd):
 
        opts = {}
 
        if os.path.isdir(self.path):
 
            opts['cwd'] = self.path
 
        return self._run_git_command(cmd, **opts)
 

	
 
    @classmethod
 
    def _check_url(cls, url):
 
        """
 
        Functon will check given url and try to verify if it's a valid
 
        link. Sometimes it may happened that mercurial will issue basic
 
        auth request that can cause whole API to hang when used from python
0 comments (0 inline, 0 general)