diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -329,6 +329,26 @@ short_id = lambda x: x[:12] hide_credentials = lambda x: ''.join(credentials_filter(x)) +def is_git(repository): + if hasattr(repository, 'alias'): + _type = repository.alias + elif hasattr(repository, 'repo_type'): + _type = repository.repo_type + else: + _type = repository + return _type == 'git' + + +def is_hg(repository): + if hasattr(repository, 'alias'): + _type = repository.alias + elif hasattr(repository, 'repo_type'): + _type = repository.repo_type + else: + _type = repository + return _type == 'hg' + + def email_or_none(author): _email = email(author) if _email != '': @@ -366,6 +386,7 @@ def person(author): # Still nothing? Just pass back the author name then return _author + def bool2icon(value): """Returns True/False values represented as small html image of true/false icons @@ -487,6 +508,7 @@ def action_parser(user_log, feed=False): return [literal(action), action_params_func] + def action_parser_icon(user_log): action = user_log.action action_params = None @@ -522,6 +544,7 @@ def action_parser_icon(user_log): from rhodecode.lib.auth import HasPermissionAny, HasPermissionAll, \ HasRepoPermissionAny, HasRepoPermissionAll + #============================================================================== # GRAVATAR URL #============================================================================== @@ -652,7 +675,6 @@ def changed_tooltip(nodes): return ': ' + _('No Files') - def repo_link(groups_and_repos): """ Makes a breadcrumbs link to repo within a group @@ -674,6 +696,7 @@ def repo_link(groups_and_repos): return literal(' » '.join(map(make_link, groups)) + \ " » " + repo_name) + def fancy_file_stats(stats): """ Displays a fancy two colored bar for number of added/deleted @@ -701,13 +724,12 @@ def fancy_file_stats(stats): a_v = a if a > 0 else '' d_v = d if d > 0 else '' - def cgen(l_type): - mapping = {'tr':'top-right-rounded-corner', - 'tl':'top-left-rounded-corner', - 'br':'bottom-right-rounded-corner', - 'bl':'bottom-left-rounded-corner'} - map_getter = lambda x:mapping[x] + mapping = {'tr': 'top-right-rounded-corner', + 'tl': 'top-left-rounded-corner', + 'br': 'bottom-right-rounded-corner', + 'bl': 'bottom-left-rounded-corner'} + map_getter = lambda x: mapping[x] if l_type == 'a' and d_v: #case when added and deleted are present @@ -722,12 +744,12 @@ def fancy_file_stats(stats): if l_type == 'd' and not a_v: return ' '.join(map(map_getter, ['tr', 'br', 'tl', 'bl'])) - - - d_a = '
%s
' % (cgen('a'), - a_p, a_v) - d_d = '
%s
' % (cgen('d'), - d_p, d_v) + d_a = '
%s
' % ( + cgen('a'),a_p, a_v + ) + d_d = '
%s
' % ( + cgen('d'),d_p, d_v + ) return literal('
%s%s
' % (width, d_a, d_d)) @@ -743,6 +765,7 @@ def urlify_text(text_): return literal(url_pat.sub(url_func, text_)) + def urlify_changesets(text_, repository): import re URL_PAT = re.compile(r'([0-9a-fA-F]{12,})') @@ -768,6 +791,7 @@ def urlify_changesets(text_, repository) return newtext + def urlify_commit(text_, repository=None, link_=None): import re import traceback diff --git a/rhodecode/templates/_data_table/_dt_elements.html b/rhodecode/templates/_data_table/_dt_elements.html --- a/rhodecode/templates/_data_table/_dt_elements.html +++ b/rhodecode/templates/_data_table/_dt_elements.html @@ -43,9 +43,9 @@ <%def name="repo_name(name,rtype,private,fork_of)">
##TYPE OF REPO - %if rtype =='hg': + %if h.is_hg(rtype): ${_('Mercurial repository')} - %elif rtype =='git': + %elif h.is_git(rtype): ${_('Git repository')} %endif diff --git a/rhodecode/templates/changelog/changelog.html b/rhodecode/templates/changelog/changelog.html --- a/rhodecode/templates/changelog/changelog.html +++ b/rhodecode/templates/changelog/changelog.html @@ -91,7 +91,7 @@ %if len(cs.parents)>1: ${_('merge')} %endif - %if cs.branch: + %if h.is_hg(c.rhodecode_repo) and cs.branch: ${h.link_to(cs.branch,h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))} %endif diff --git a/rhodecode/templates/journal/journal.html b/rhodecode/templates/journal/journal.html --- a/rhodecode/templates/journal/journal.html +++ b/rhodecode/templates/journal/journal.html @@ -113,9 +113,9 @@
- %if entry.follows_repository.repo_type == 'hg': + %if h.is_hg(entry.follows_repository): ${_('Mercurial repository')} - %elif entry.follows_repository.repo_type == 'git': + %elif h.is_git(entry.follows_repository): ${_('Git repository')} %endif diff --git a/rhodecode/templates/shortlog/shortlog_data.html b/rhodecode/templates/shortlog/shortlog_data.html --- a/rhodecode/templates/shortlog/shortlog_data.html +++ b/rhodecode/templates/shortlog/shortlog_data.html @@ -15,7 +15,9 @@
r${cs.revision}:${h.short_id(cs.raw_id)}
- ${h.urlify_commit(h.truncate(cs.message,50),c.repo_name,h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))} + ${h.link_to(h.truncate(cs.message,50), + h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id), + title=cs.message)} ${h.age(cs.date)} @@ -23,7 +25,11 @@ ${h.person(cs.author)} - ${cs.branch} + + %if h.is_hg(c.rhodecode_repo): + ${cs.branch} + %endif + diff --git a/rhodecode/templates/summary/summary.html b/rhodecode/templates/summary/summary.html --- a/rhodecode/templates/summary/summary.html +++ b/rhodecode/templates/summary/summary.html @@ -59,10 +59,10 @@ %endif %endif: ##REPO TYPE - %if c.dbrepo.repo_type =='hg': + %if h.is_hg(c.dbrepo): ${_('Mercurial repository')} %endif - %if c.dbrepo.repo_type =='git': + %if h.is_git(c.dbrepo): ${_('Git repository')} %endif