changeset 1959:7a7ffe24b82c beta

optimized speed for browsing git changesets
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 28 Jan 2012 00:00:51 +0200
parents 7e4b3d3a9c5c
children 3daa7093fbbb
files rhodecode/lib/helpers.py rhodecode/templates/_data_table/_dt_elements.html rhodecode/templates/changelog/changelog.html rhodecode/templates/journal/journal.html rhodecode/templates/shortlog/shortlog_data.html rhodecode/templates/summary/summary.html
diffstat 6 files changed, 52 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/helpers.py	Fri Jan 27 05:33:06 2012 +0200
+++ b/rhodecode/lib/helpers.py	Sat Jan 28 00:00:51 2012 +0200
@@ -329,6 +329,26 @@
 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 @@
     # 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 @@
 
     return [literal(action), action_params_func]
 
+
 def action_parser_icon(user_log):
     action = user_log.action
     action_params = None
@@ -522,6 +544,7 @@
 from rhodecode.lib.auth import HasPermissionAny, HasPermissionAll, \
 HasRepoPermissionAny, HasRepoPermissionAll
 
+
 #==============================================================================
 # GRAVATAR URL
 #==============================================================================
@@ -652,7 +675,6 @@
         return ': ' + _('No Files')
 
 
-
 def repo_link(groups_and_repos):
     """
     Makes a breadcrumbs link to repo within a group
@@ -674,6 +696,7 @@
         return literal(' &raquo; '.join(map(make_link, groups)) + \
                        " &raquo; " + repo_name)
 
+
 def fancy_file_stats(stats):
     """
     Displays a fancy two colored bar for number of added/deleted
@@ -701,13 +724,12 @@
     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 @@
         if l_type == 'd' and not a_v:
             return ' '.join(map(map_getter, ['tr', 'br', 'tl', 'bl']))
 
-
-
-    d_a = '<div class="added %s" style="width:%s%%">%s</div>' % (cgen('a'),
-                                                                 a_p, a_v)
-    d_d = '<div class="deleted %s" style="width:%s%%">%s</div>' % (cgen('d'),
-                                                                   d_p, d_v)
+    d_a = '<div class="added %s" style="width:%s%%">%s</div>' % (
+        cgen('a'),a_p, a_v
+    )
+    d_d = '<div class="deleted %s" style="width:%s%%">%s</div>' % (
+        cgen('d'),d_p, d_v
+    )
     return literal('<div style="width:%spx">%s%s</div>' % (width, d_a, d_d))
 
 
@@ -743,6 +765,7 @@
 
     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 @@
 
     return newtext
 
+
 def urlify_commit(text_, repository=None, link_=None):
     import re
     import traceback
--- a/rhodecode/templates/_data_table/_dt_elements.html	Fri Jan 27 05:33:06 2012 +0200
+++ b/rhodecode/templates/_data_table/_dt_elements.html	Sat Jan 28 00:00:51 2012 +0200
@@ -43,9 +43,9 @@
 <%def name="repo_name(name,rtype,private,fork_of)">
   <div style="white-space: nowrap">
    ##TYPE OF REPO
-   %if rtype =='hg':
+   %if h.is_hg(rtype):
      <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
-   %elif rtype =='git':
+   %elif h.is_git(rtype):
      <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/>
    %endif
 
--- a/rhodecode/templates/changelog/changelog.html	Fri Jan 27 05:33:06 2012 +0200
+++ b/rhodecode/templates/changelog/changelog.html	Sat Jan 28 00:00:51 2012 +0200
@@ -91,7 +91,7 @@
 									%if len(cs.parents)>1:
 									<span class="merge">${_('merge')}</span>
 									%endif
-									%if cs.branch:
+									%if h.is_hg(c.rhodecode_repo) and cs.branch:
 									<span class="branchtag" title="${'%s %s' % (_('branch'),cs.branch)}">
 									   ${h.link_to(cs.branch,h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span>
 									%endif
--- a/rhodecode/templates/journal/journal.html	Fri Jan 27 05:33:06 2012 +0200
+++ b/rhodecode/templates/journal/journal.html	Sat Jan 28 00:00:51 2012 +0200
@@ -113,9 +113,9 @@
                         </span>
                         </div>
 
-                         %if entry.follows_repository.repo_type == 'hg':
+                         %if h.is_hg(entry.follows_repository):
                            <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
-                         %elif entry.follows_repository.repo_type == 'git':
+                         %elif h.is_git(entry.follows_repository):
                            <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/>
                          %endif
 
--- a/rhodecode/templates/shortlog/shortlog_data.html	Fri Jan 27 05:33:06 2012 +0200
+++ b/rhodecode/templates/shortlog/shortlog_data.html	Sat Jan 28 00:00:51 2012 +0200
@@ -15,7 +15,9 @@
             <div><pre><a href="${h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id)}">r${cs.revision}:${h.short_id(cs.raw_id)}</a></pre></div>
         </td>
         <td>
-        ${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)}
         </td>
         <td><span class="tooltip" title="${cs.date}">
                       ${h.age(cs.date)}</span>
@@ -23,7 +25,11 @@
 		<td title="${cs.author}">${h.person(cs.author)}</td>
 		<td>
 			<span class="logtags">
-				<span class="branchtag">${cs.branch}</span>
+				<span class="branchtag">
+                %if h.is_hg(c.rhodecode_repo):
+                    ${cs.branch}
+                %endif
+                </span>
 			</span>
 		</td>
 		<td>
--- a/rhodecode/templates/summary/summary.html	Fri Jan 27 05:33:06 2012 +0200
+++ b/rhodecode/templates/summary/summary.html	Sat Jan 28 00:00:51 2012 +0200
@@ -59,10 +59,10 @@
                       %endif
                   %endif:
                  ##REPO TYPE
-		         %if c.dbrepo.repo_type =='hg':
+		         %if h.is_hg(c.dbrepo):
 		           <img style="margin-bottom:2px" class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
 		         %endif
-		         %if c.dbrepo.repo_type =='git':
+		         %if h.is_git(c.dbrepo):
 		           <img style="margin-bottom:2px" class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/>
 		         %endif