Changeset - 948c16bb9476
[Not reviewed]
Merge codereview
0 3 1
Marcin Kuzminski - 13 years ago 2012-05-30 21:19:22
marcin@python-works.com
merge with beta
4 files changed with 279 insertions and 20 deletions:
0 comments (0 inline, 0 general)
docs/installation.rst
Show inline comments
 
@@ -8,51 +8,56 @@ Installation
 
sure, your not missing any system libraries and using right version of 
 
libraries required by RhodeCode. There's also restriction in terms of mercurial
 
clients. Minimal version of hg client known working fine with RhodeCode is
 
**1.6**. If you're using older client, please upgrade.
 

	
 

	
 
Installing RhodeCode from Cheese Shop
 
-------------------------------------
 

	
 
Rhodecode requires python version 2.5 or higher.
 

	
 
The easiest way to install ``rhodecode`` is to run::
 

	
 
    easy_install rhodecode
 

	
 
Or::
 

	
 
    pip install rhodecode
 

	
 
If you prefer to install RhodeCode manually simply grab latest release from
 
http://pypi.python.org/pypi/RhodeCode, decompress the archive and run::
 

	
 
    python setup.py install
 

	
 
Step by step installation example for Windows
 
---------------------------------------------
 

	
 
Step by step installation example
 
---------------------------------
 
:ref:`installation_win`
 

	
 

	
 
Step by step installation example for Linux
 
-------------------------------------------
 

	
 

	
 
For installing RhodeCode i highly recommend using separate virtualenv_. This
 
way many required by RhodeCode libraries will remain sandboxed from your main
 
python and making things less problematic when doing system python updates. 
 

	
 
- Assuming you have installed virtualenv_ create a new virtual environment 
 
  using virtualenv command:: 
 

	
 
    virtualenv --no-site-packages /var/www/rhodecode-venv
 

	
 

	
 
.. note:: Using ``--no-site-packages`` when generating your
 
   virtualenv is **very important**. This flag provides the necessary
 
   isolation for running the set of packages required by
 
   RhodeCode.  If you do not specify ``--no-site-packages``,
 
   it's possible that RhodeCode will not install properly into
 
   the virtualenv, or, even if it does, may not run properly,
 
   depending on the packages you've already got installed into your
 
   Python's "main" site-packages dir.
 

	
 

	
 
- this will install new virtualenv_ into `/var/www/rhodecode-venv`. 
 
- Activate the virtualenv_ by running::
docs/installation_win.rst
Show inline comments
 
new file 100644
 
.. _installation_win:
 

	
 

	
 
Step by step Installation for Windows
 
=====================================
 

	
 

	
 
RhodeCode step-by-step install Guide for Windows  
 

	
 
Target OS: Windows XP SP3 English (Clean installation) 
 
+ All Windows Updates until 24-may-2012 
 

	
 
Step1 - Install Visual Studio 2008 Express
 
------------------------------------------
 

	
 
 
 
Optional: You can also install MingW, but VS2008 installation is easier 
 

	
 
Download "Visual C++ 2008 Express Edition with SP1" from: 
 
http://www.microsoft.com/visualstudio/en-us/products/2008-editions/express 
 
(if not found or relocated, google for "visual studio 2008 express" for 
 
updated link) 
 

	
 
You can also download full ISO file for offline installation, just 
 
choose "All - Offline Install ISO image file" in the previous page and 
 
choose "Visual C++ 2008 Express" when installing. 
 

	
 

	
 
.. note::
 

	
 
  Silverlight Runtime and SQL Server 2008 Express Edition are not 
 
  required, you can uncheck them 
 

	
 

	
 
Step2 - Install Python
 
----------------------
 

	
 
Install Python 2.x.y (x >= 5) x86 version (32bit). DO NOT USE A 3.x version.
 
Download Python 2.x.y from: 
 
http://www.python.org/download/ 
 

	
 
Choose "Windows Installer" (32bit version) not "Windows X86-64 
 
Installer". While writing this guide, the latest version was v2.7.3. 
 
Remember the specific major and minor version installed, because it will 
 
be needed in the next step. In this case, it is "2.7". 
 

	
 

	
 
Step3 - Install Win32py extensions
 
----------------------------------
 
 
 
Download pywin32 from: 
 
http://sourceforge.net/projects/pywin32/files/ 
 

	
 
- Click on "pywin32" folder 
 
- Click on the first folder (in this case, Build 217, maybe newer when you try) 
 
- Choose the file ending with ".win32-py2.x.exe" -> x being the minor 
 
  version of Python you installed (in this case, 7) 
 
  When writing this guide, the file was: 
 
  http://sourceforge.net/projects/pywin32/files/pywin32/Build%20217/pywin32-217.win32-py2.7.exe/download 
 

	
 

	
 
Step4 - Python BIN
 
------------------
 

	
 
Add Python BIN folder to the path 
 

	
 
You have to add the Python folder to the path, you can do it manually 
 
(editing "PATH" environment variable) or using Windows Support Tools 
 
that came preinstalled in Vista/7 and can be installed in Windows XP. 
 

	
 
- Using support tools on WINDOWS XP: 
 
  If you use Windows XP you can install them using Windows XP CD and 
 
  navigating to \SUPPORT\TOOLS. There, execute Setup.EXE (not MSI). 
 
  Afterwards, open a CMD and type::
 
 
 
    SETX PATH "%PATH%;[your-python-path]" -M 
 

	
 
  Close CMD (the path variable will be updated then) 
 

	
 
- Using support tools on WINDOWS Vista/7: 
 

	
 
  Open a CMD and type::
 

	
 
    SETX PATH "%PATH%;[your-python-path]" /M 
 

	
 
  Please substitute [your-python-path] with your Python installation path. 
 
  Typically: C:\\Python27 
 

	
 

	
 
Step5 - RhodeCode folder structure
 
----------------------------------
 

	
 
Create a RhodeCode folder structure 
 

	
 
This is only a example to install RhodeCode, you can of course change 
 
it. However, this guide will follow the proposed structure, so please 
 
later adapt the paths if you change them. My recommendation is to use 
 
folders with NO SPACES. But you can try if you are brave... 
 

	
 
Create the following folder structure::
 

	
 
  C:\RhodeCode 
 
  C:\RhodeCode\Bin 
 
  C:\RhodeCode\Env 
 
  C:\RhodeCode\Repos 
 

	
 

	
 
Step6 - Install virtualenv
 
---------------------------
 

	
 
Install Virtual Env for Python 
 

	
 
Navigate to: http://www.virtualenv.org/en/latest/index.html#installation 
 
Right click on "virtualenv.py" file and choose "Save link as...". 
 
Download to C:\\RhodeCode (or whatever you want) 
 
(the file is located at 
 
https://raw.github.com/pypa/virtualenv/master/virtualenv.py) 
 

	
 
Create a virtual Python environment in C:\\RhodeCode\\Env (or similar). To 
 
do so, open a CMD (Python Path should be included in Step3), navigate 
 
where you downloaded "virtualenv.py", and write:: 
 

	
 
 python virtualenv.py C:\RhodeCode\Env 
 

	
 
(--no-site-packages is now the default behaviour of virtualenv, no need 
 
to include it) 
 

	
 

	
 
Step7 - Install RhodeCode
 
-------------------------
 

	
 
Finally, install RhodeCode 
 

	
 
Close previously opened command prompt/s, and open a Visual Studio 2008 
 
Command Prompt (**IMPORTANT!!**). To do so, go to Start Menu, and then open 
 
"Microsoft Visual C++ 2008 Express Edition" -> "Visual Studio Tools" -> 
 
"Visual Studio 2008 Command Prompt" 
 

	
 
In that CMD (loaded with VS2008 PATHs) type::
 
 
 
  cd C:\RhodeCode\Env\Scripts (or similar) 
 
  activate 
 

	
 
The prompt will change into "(Env) C:\\RhodeCode\\Env\\Scripts" or similar 
 
(depending of your folder structure). Then type:: 
 

	
 
 pip install rhodecode 
 

	
 
(long step, please wait until fully complete) 
 

	
 
Some warnings will appear, don't worry as they are normal.
 

	
 

	
 
Step8 - Configuring RhodeCode
 
-----------------------------
 

	
 

	
 
steps taken from http://packages.python.org/RhodeCode/setup.html 
 

	
 
You have to use the same Visual Studio 2008 command prompt as Step7, so 
 
if you closed it reopen it following the same commands (including the 
 
"activate" one). When ready, just type::
 
 
 
  cd C:\RhodeCode\Bin 
 
  paster make-config RhodeCode production.ini 
 

	
 
Then, you must edit production.ini to fit your needs (ip address, ip 
 
port, mail settings, database, whatever). I recommend using NotePad++ 
 
(free) or similar text editor, as it handles well the EndOfLine 
 
character differences between Unix and Windows 
 
(http://notepad-plus-plus.org/) 
 

	
 
For the sake of simplicity lets run it with the default settings. After 
 
your edits (if any), in the previous Command Prompt, type:: 
 
 
 
 paster setup-rhodecode production.ini 
 

	
 
(this time a NEW database will be installed, you must follow a different 
 
step to later UPGRADE to a newer RhodeCode version) 
 

	
 
The script will ask you for confirmation about creating a NEW database, 
 
answer yes (y) 
 
The script will ask you for repository path, answer C:\\RhodeCode\\Repos 
 
(or similar) 
 
The script will ask you for admin username and password, answer "admin" 
 
+ "123456" (or whatever you want) 
 
The script will ask you for admin mail, answer "admin@xxxx.com" (or 
 
whatever you want) 
 

	
 
If you make some mistake and the script does not end, don't worry, start 
 
it again. 
 

	
 

	
 
Step9 - Running RhodeCode
 
-------------------------
 

	
 

	
 
In the previous command prompt, being in the C:\\RhodeCode\\Bin folder, 
 
just type::
 
 
 
 paster serve production.ini 
 

	
 
Open yout web server, and go to http://127.0.0.1:5000 
 

	
 
It works!! :-) 
 

	
 
Remark: 
 
If it does not work first time, just Ctrl-C the CMD process and start it 
 
again. Don't forget the "http://" in Internet Explorer 
 

	
 

	
 

	
 
What this Guide does not cover:
 

	
 
- Installing Celery 
 
- Running RhodeCode as Windows Service. You can investigate here:
 
 
 
  - http://pypi.python.org/pypi/wsgisvc 
 
  - http://ryrobes.com/python/running-python-scripts-as-a-windows-service/     
 
  - http://wiki.pylonshq.com/display/pylonscookbook/How+to+run+Pylons+as+a+Windows+service 
 

	
 
- Using Apache. You can investigate here:
 

	
 
  - https://groups.google.com/group/rhodecode/msg/c433074e813ffdc4 
 

	
 

	
 
Upgrading
 
=========
 
 
 
Stop running RhodeCode 
 
Open a CommandPrompt like in Step7 (VS2008 path + activate) and type::
 
 
 
 easy_install -U rhodecode 
 
 cd \RhodeCode\Bin 
 

	
 
{ backup your production.ini file now} :: 
 

	
 
 paster make-config RhodeCode production.ini 
 

	
 
(check changes and update your production.ini accordingly) ::
 
 
 
 paster upgrade-db production.ini (update database)
 

	
 
Full steps in http://packages.python.org/RhodeCode/upgrade.html 
 
\ No newline at end of file
docs/setup.rst
Show inline comments
 
@@ -13,48 +13,53 @@ following command to do this::
 
 
 
    paster make-config RhodeCode production.ini
 

	
 
- This will create the file `production.ini` in the current directory. This
 
  configuration file contains the various settings for RhodeCode, e.g proxy 
 
  port, email settings, usage of static files, cache, celery settings and 
 
  logging.
 

	
 

	
 
Next, you need to create the databases used by RhodeCode. I recommend that you
 
use postgresql or sqlite (default). If you choose a database other than the
 
default ensure you properly adjust the db url in your production.ini
 
configuration file to use this other database. RhodeCode currently supports
 
postgresql, sqlite and mysql databases. Create the database by running
 
the following command::
 

	
 
    paster setup-rhodecode production.ini
 

	
 
This will prompt you for a "root" path. This "root" path is the location where
 
RhodeCode will store all of its repositories on the current machine. After
 
entering this "root" path ``setup-rhodecode`` will also prompt you for a username 
 
and password for the initial admin account which ``setup-rhodecode`` sets 
 
up for you.
 

	
 
setup process can be fully automated, example for lazy::
 

	
 
    paster setup-rhodecode production.ini --user=marcink --password=secret --email=marcin@rhodecode.org --repos=/home/marcink/my_repos
 
    
 

	
 
- The ``setup-rhodecode`` command will create all of the needed tables and an 
 
  admin account. When choosing a root path you can either use a new empty 
 
  location, or a location which already contains existing repositories. If you
 
  choose a location which contains existing repositories RhodeCode will simply 
 
  add all of the repositories at the chosen location to it's database. 
 
  (Note: make sure you specify the correct path to the root).
 
- Note: the given path for mercurial_ repositories **must** be write accessible
 
  for the application. It's very important since the RhodeCode web interface 
 
  will work without write access, but when trying to do a push it will 
 
  eventually fail with permission denied errors unless it has write access.
 

	
 
You are now ready to use RhodeCode, to run it simply execute::
 
 
 
    paster serve production.ini
 
 
 
- This command runs the RhodeCode server. The web app should be available at the 
 
  127.0.0.1:5000. This ip and port is configurable via the production.ini 
 
  file created in previous step
 
- Use the admin account you created above when running ``setup-rhodecode`` 
 
  to login to the web app.
 
- The default permissions on each repository is read, and the owner is admin. 
 
  Remember to update these if needed.
 
- In the admin panel you can toggle ldap, anonymous, permissions settings. As
 
  well as edit more advanced options on users and repositories
rhodecode/lib/diffs.py
Show inline comments
 
@@ -265,156 +265,161 @@ class DiffProcessor(object):
 
        """
 
        start = 0
 
        limit = min(len(line['line']), len(next_['line']))
 
        while start < limit and line['line'][start] == next_['line'][start]:
 
            start += 1
 
        end = -1
 
        limit -= start
 
        while -end <= limit and line['line'][end] == next_['line'][end]:
 
            end -= 1
 
        end += 1
 
        if start or end:
 
            def do(l):
 
                last = end + len(l['line'])
 
                if l['action'] == 'add':
 
                    tag = 'ins'
 
                else:
 
                    tag = 'del'
 
                l['line'] = '%s<%s>%s</%s>%s' % (
 
                    l['line'][:start],
 
                    tag,
 
                    l['line'][start:last],
 
                    tag,
 
                    l['line'][last:]
 
                )
 

	
 
            do(line)
 
            do(next_)
 

	
 
    def _parse_udiff(self):
 
        """
 
        Parse the diff an return data for the template.
 
        """
 
        lineiter = self.lines
 
        files = []
 
        try:
 
            line = lineiter.next()
 
            # skip first context
 
            skipfirst = True
 

	
 
            while 1:
 
                # continue until we found the old file
 
                if not line.startswith('--- '):
 
                    line = lineiter.next()
 
                    continue
 

	
 
                chunks = []
 
                stats = [0, 0]
 
                operation, filename, old_rev, new_rev = \
 
                    self._extract_rev(line, lineiter.next())
 
                files.append({
 
                    'filename':         filename,
 
                    'old_revision':     old_rev,
 
                    'new_revision':     new_rev,
 
                    'chunks':           chunks,
 
                    'operation':        operation,
 
                    'stats':            stats,
 
                })
 

	
 
                line = lineiter.next()
 
                while line:
 

	
 
                    match = self._chunk_re.match(line)
 
                    if not match:
 
                        break
 

	
 
                    lines = []
 
                    chunks.append(lines)
 

	
 
                    old_line, old_end, new_line, new_end = \
 
                        [int(x or 1) for x in match.groups()[:-1]]
 
                    old_line -= 1
 
                    new_line -= 1
 
                    context = len(match.groups()) == 5
 
                    gr = match.groups()
 
                    context = len(gr) == 5
 
                    old_end += old_line
 
                    new_end += new_line
 

	
 
                    if context:
 
                        if not skipfirst:
 
                        # skip context only if it's first line
 
                        if int(gr[0]) > 1:
 
                            lines.append({
 
                                'old_lineno': '...',
 
                                'new_lineno': '...',
 
                                'action':     'context',
 
                                'line':       line,
 
                            })
 
                        else:
 
                            skipfirst = False
 

	
 
                    line = lineiter.next()
 
                    while old_line < old_end or new_line < new_end:
 
                        if line:
 
                            command, line = line[0], line[1:]
 
                        else:
 
                            command = ' '
 
                        affects_old = affects_new = False
 

	
 
                        # ignore those if we don't expect them
 
                        if command in '#@':
 
                            continue
 
                        elif command == '+':
 
                            affects_new = True
 
                            action = 'add'
 
                            stats[0] += 1
 
                        elif command == '-':
 
                            affects_old = True
 
                            action = 'del'
 
                            stats[1] += 1
 
                        else:
 
                            affects_old = affects_new = True
 
                            action = 'unmod'
 

	
 
                        old_line += affects_old
 
                        new_line += affects_new
 
                        lines.append({
 
                            'old_lineno':   affects_old and old_line or '',
 
                            'new_lineno':   affects_new and new_line or '',
 
                            'action':       action,
 
                            'line':         line
 
                        })
 
                        if line.find('No newline at end of file') != -1:
 
                            lines.append({
 
                                'old_lineno':   '...',
 
                                'new_lineno':   '...',
 
                                'action':       'context',
 
                                'line':         line
 
                            })
 

	
 
                        else:
 
                            old_line += affects_old
 
                            new_line += affects_new
 
                            lines.append({
 
                                'old_lineno':   affects_old and old_line or '',
 
                                'new_lineno':   affects_new and new_line or '',
 
                                'action':       action,
 
                                'line':         line
 
                            })
 

	
 
                        line = lineiter.next()
 
        except StopIteration:
 
            pass
 

	
 
        # highlight inline changes
 
        for diff_data in files:
 
            for chunk in diff_data['chunks']:
 
                lineiter = iter(chunk)
 
                try:
 
                    while 1:
 
                        line = lineiter.next()
 
                        if line['action'] != 'unmod':
 
                            nextline = lineiter.next()
 
                            if nextline['action'] == 'unmod' or \
 
                            if nextline['action'] in ['unmod', 'context'] or \
 
                               nextline['action'] == line['action']:
 
                                continue
 
                            self.differ(line, nextline)
 
                except StopIteration:
 
                    pass
 
        return files
 

	
 
    def prepare(self):
 
        """
 
        Prepare the passed udiff for HTML rendering. It'l return a list
 
        of dicts
 
        """
 
        return self._parse_udiff()
 

	
 
    def _safe_id(self, idstring):
 
        """Make a string safe for including in an id attribute.
 

	
 
        The HTML spec says that id attributes 'must begin with
 
        a letter ([A-Za-z]) and may be followed by any number
 
        of letters, digits ([0-9]), hyphens ("-"), underscores
 
        ("_"), colons (":"), and periods (".")'. These regexps
 
        are slightly over-zealous, in that they remove colons
 
        and periods unnecessarily.
 

	
0 comments (0 inline, 0 general)