Changeset - c3236d7febad
[Not reviewed]
default
0 3 0
Marcin Kuzminski - 15 years ago 2010-09-03 09:55:48
marcin@python-works.com
fixed, empty cs bug.
Implemented as webhlepers function
3 files changed with 19 insertions and 8 deletions:
0 comments (0 inline, 0 general)
pylons_app/lib/helpers.py
Show inline comments
 
@@ -277,24 +277,39 @@ def pygmentize_annotation(filenode, **kw
 
    return literal(annotate_highlight(filenode, url_func, **kwargs))
 
      
 
def repo_name_slug(value):
 
    """
 
    Return slug of name of repository
 
    """
 
    slug = urlify(value)
 
    for c in """=[]\;'"<>,/~!@#$%^&*()+{}|:""":
 
        slug = slug.replace(c, '-')
 
    slug = recursive_replace(slug, '-')
 
    return slug
 

	
 
def get_changeset_safe(repo, rev):
 
    from vcs.backends.base import BaseRepository
 
    from vcs.exceptions import RepositoryError
 
    if not isinstance(repo, BaseRepository):
 
        raise Exception('You must pass an Repository '
 
                        'object as first argument got %s', type(repo))
 
        
 
    try:
 
        cs = repo.get_changeset(rev)
 
    except RepositoryError:
 
        from pylons_app.lib.utils import EmptyChangeset
 
        cs = EmptyChangeset()
 
    return cs
 

	
 

	
 
flash = _Flash()
 

	
 

	
 
#===============================================================================
 
# MERCURIAL FILTERS available via h.
 
#===============================================================================
 
from mercurial import util
 
from mercurial.templatefilters import age as _age, person as _person
 

	
 
age = lambda  x:_age(x)
 
capitalize = lambda x: x.capitalize()
 
date = lambda x: util.datestr(x)
 
@@ -342,13 +357,13 @@ def safe_unicode(str):
 
    unicode with errors replace, if this failes we return unicode with 
 
    string_escape decoding """
 
    
 
    try:
 
        u_str = unicode(str)
 
    except UnicodeDecodeError:
 
        try:
 
            u_str = unicode(str, 'utf-8', 'replace')
 
        except UnicodeDecodeError:
 
            #incase we have a decode error just represent as byte string
 
            u_str = unicode(str(str).encode('string_escape'))
 
        
 
    return u_str
 
\ No newline at end of file
 
    return u_str
pylons_app/model/hg_model.py
Show inline comments
 
@@ -20,25 +20,25 @@
 
"""
 
Created on April 9, 2010
 
Model for hg app
 
@author: marcink
 
"""
 
from beaker.cache import cache_region
 
from mercurial import ui
 
from mercurial.hgweb.hgwebdir_mod import findrepos
 
from pylons.i18n.translation import _
 
from pylons_app.lib.auth import HasRepoPermissionAny
 
from pylons_app.model import meta
 
from pylons_app.model.db import Repository, User
 
from sqlalchemy.orm import joinedload
 
from pylons_app.lib import helpers as h
 
from vcs.exceptions import RepositoryError, VCSError
 
import logging
 
import os
 
import sys
 
log = logging.getLogger(__name__)
 

	
 
try:
 
    from vcs.backends.hg import MercurialRepository
 
except ImportError:
 
    sys.stderr.write('You have to import vcs module')
 
    raise Exception('Unable to import vcs')
 

	
 
@@ -142,29 +142,25 @@ class HgModel(object):
 
            except OSError:
 
                continue
 
        meta.Session.remove()
 
        return repos_list
 
        
 
    def get_repos(self):
 
        for name, repo in _get_repos_cached().items():
 
            if repo._get_hidden():
 
                #skip hidden web repository
 
                continue
 
            
 
            last_change = repo.last_change
 
            try:
 
                tip = repo.get_changeset('tip')
 
            except RepositoryError:
 
                from pylons_app.lib.utils import EmptyChangeset
 
                tip = EmptyChangeset()
 
            tip = h.get_changeset_safe(repo, 'tip')
 
                
 
            tmp_d = {}
 
            tmp_d['name'] = repo.name
 
            tmp_d['name_sort'] = tmp_d['name'].lower()
 
            tmp_d['description'] = repo.description
 
            tmp_d['description_sort'] = tmp_d['description']
 
            tmp_d['last_change'] = last_change
 
            tmp_d['last_change_sort'] = last_change[1] - last_change[0]
 
            tmp_d['tip'] = tip.raw_id
 
            tmp_d['tip_sort'] = tip.revision 
 
            tmp_d['rev'] = tip.revision
 
            tmp_d['contact'] = repo.contact
pylons_app/templates/admin/users/user_edit_my_account.html
Show inline comments
 
@@ -89,23 +89,23 @@
 
	    <table>
 
	     <tbody>
 
	     %for repo in c.user_repos:
 
	        <tr>
 
	            <td>
 
	             %if repo.dbrepo.private:
 
	                <img class="icon" alt="${_('private')}" src="/images/icons/lock.png"/>
 
	             %else:
 
	                <img class="icon" alt="${_('public')}" src="/images/icons/lock_open.png"/>
 
	             %endif
 
	                                             
 
	            ${h.link_to(repo.name, h.url('summary_home',repo_name=repo.name))}</td> 
 
	            <td>${_('revision')}: ${repo.revisions[-1]}</td>
 
	            <td>${_('revision')}: ${h.get_changeset_safe(repo,'tip').revision}</td>
 
	            <td>${_('last changed')}: ${h.age(repo.last_change)}</td>
 
	            <td><img class="icon" alt="${_('private')}" src="/images/icons/application_form_edit.png"/> ${h.link_to(_('edit'),h.url('edit_repo',repo_name=repo.name))}</td>
 
	        </tr>
 
	     %endfor
 
	     </tbody>
 
	     </table>
 
    </div>
 
    
 
</div>
 
</%def>  
 
\ No newline at end of file
0 comments (0 inline, 0 general)