Changeset - 36102488d634
[Not reviewed]
default
0 2 0
Marcin Kuzminski - 16 years ago 2010-05-09 14:13:20
marcin@python-works.com
Added empty changeset to use in newly created repository, and used this inside a hg model in repos list
2 files changed with 22 insertions and 5 deletions:
0 comments (0 inline, 0 general)
pylons_app/lib/utils.py
Show inline comments
 
@@ -87,8 +87,20 @@ def make_ui(path='hgwebdir.config', chec
 
    for section in sections:
 
        for k, v in cfg.items(section):
 
            baseui.setconfig(section, k, v)
 
    
 
    return baseui
 

	
 
from vcs.backends.base import BaseChangeset
 
from vcs.utils.lazy import LazyProperty
 
class EmptyChangeset(BaseChangeset):
 
    
 
    revision = -1
 

	
 
    @LazyProperty
 
    def raw_id(self):
 
        """
 
        Returns raw string identifing this changeset, useful for web
 
        representation.
 
        """
 
        return '0' * 12
 

	
pylons_app/model/hg_model.py
Show inline comments
 
#!/usr/bin/env python
 
# encoding: utf-8
 
#
 
# Copyright (c) 2010 marcink.  All rights reserved.
 
#
 
from vcs.exceptions import RepositoryError
 
'''
 
Created on Apr 9, 2010
 

	
 
@author: marcink
 
'''
 
import os
 
@@ -34,24 +35,28 @@ class HgModel(object):
 
            
 
            if mercurial_repo._get_hidden():
 
                #skip hidden web repository
 
                continue
 
            
 
            last_change = mercurial_repo.last_change
 
            tip_rev = mercurial_repo._get_revision('tip')
 
            tip = mercurial_repo.get_changeset(tip_rev)
 
            try:
 
                tip = mercurial_repo.get_changeset('tip')
 
            except RepositoryError:
 
                from pylons_app.lib.utils import EmptyChangeset
 
                tip = EmptyChangeset()
 
                
 
            tmp_d = {}
 
            tmp_d['name'] = mercurial_repo.name
 
            tmp_d['name_sort'] = tmp_d['name']
 
            tmp_d['description'] = mercurial_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._short
 
            tmp_d['tip_sort'] = tip_rev
 
            tmp_d['rev'] = tip_rev
 
            tmp_d['tip'] = tip.raw_id
 
            tmp_d['tip_sort'] = tip.revision 
 
            tmp_d['rev'] = tip.revision
 
            tmp_d['contact'] = mercurial_repo.contact
 
            tmp_d['contact_sort'] = tmp_d['contact']
 
            tmp_d['repo_archives'] = list(mercurial_repo._get_archives())
 
            
 
            yield tmp_d
 

	
0 comments (0 inline, 0 general)