changeset 3764:c7970889c5c0 beta

Removed shortlog aka lightweight changelog. Current version of changelog is fast and condensed. There's no sense to keep changelog duplicity.
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 16 Apr 2013 00:44:48 +0200
parents aab189b312fa
children 5a8918aba869
files rhodecode/config/routing.py rhodecode/controllers/changelog.py rhodecode/controllers/shortlog.py rhodecode/controllers/summary.py rhodecode/public/css/contextbar.css rhodecode/public/css/style.css rhodecode/templates/base/base.html rhodecode/templates/changelog/changelog_summary_data.html rhodecode/templates/shortlog/shortlog.html rhodecode/templates/shortlog/shortlog_data.html rhodecode/templates/summary/summary.html rhodecode/tests/functional/test_shortlog.py
diffstat 12 files changed, 140 insertions(+), 288 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/config/routing.py	Mon Apr 15 23:12:09 2013 +0200
+++ b/rhodecode/config/routing.py	Tue Apr 16 00:44:48 2013 +0200
@@ -586,9 +586,6 @@
     rmap.connect('summary_home_summary', '/{repo_name:.*?}/summary',
                 controller='summary', conditions=dict(function=check_repo))
 
-    rmap.connect('shortlog_home', '/{repo_name:.*?}/shortlog',
-                controller='shortlog', conditions=dict(function=check_repo))
-
     rmap.connect('branches_home', '/{repo_name:.*?}/branches',
                 controller='branches', conditions=dict(function=check_repo))
 
@@ -601,6 +598,10 @@
     rmap.connect('changelog_home', '/{repo_name:.*?}/changelog',
                 controller='changelog', conditions=dict(function=check_repo))
 
+    rmap.connect('changelog_summary_home', '/{repo_name:.*?}/changelog_summary',
+                controller='changelog', action='changelog_summary',
+                conditions=dict(function=check_repo))
+
     rmap.connect('changelog_file_home', '/{repo_name:.*?}/changelog/{revision}/{f_path:.*}',
                 controller='changelog', f_path=None,
                 conditions=dict(function=check_repo))
--- a/rhodecode/controllers/changelog.py	Mon Apr 15 23:12:09 2013 +0200
+++ b/rhodecode/controllers/changelog.py	Tue Apr 16 00:44:48 2013 +0200
@@ -39,10 +39,29 @@
 from rhodecode.lib.vcs.exceptions import RepositoryError, ChangesetDoesNotExistError,\
     ChangesetError, NodeDoesNotExistError
 from rhodecode.lib.utils2 import safe_int
+from webob.exc import HTTPNotFound
 
 log = logging.getLogger(__name__)
 
 
+def _load_changelog_summary():
+    p = safe_int(request.GET.get('page'), 1)
+    size = safe_int(request.GET.get('size'), 10)
+
+    def url_generator(**kw):
+        return url('changelog_summary_home',
+                   repo_name=c.rhodecode_db_repo.repo_name, size=size, **kw)
+
+    collection = c.rhodecode_repo
+
+    c.repo_changesets = RepoPage(collection, page=p,
+                                 items_per_page=size,
+                                 url=url_generator)
+    page_revisions = [x.raw_id for x in list(c.repo_changesets)]
+    c.comments = c.rhodecode_db_repo.get_comments(page_revisions)
+    c.statuses = c.rhodecode_db_repo.statuses(page_revisions)
+
+
 class ChangelogController(BaseRepoController):
 
     def __before__(self):
@@ -140,3 +159,14 @@
         if request.environ.get('HTTP_X_PARTIAL_XHR'):
             c.cs = c.rhodecode_repo.get_changeset(cs)
             return render('changelog/changelog_details.html')
+        raise HTTPNotFound()
+
+    @LoginRequired()
+    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
+                                   'repository.admin')
+    def changelog_summary(self, repo_name):
+        if request.environ.get('HTTP_X_PARTIAL_XHR'):
+            _load_changelog_summary()
+
+            return render('changelog/changelog_summary_data.html')
+        raise HTTPNotFound()
--- a/rhodecode/controllers/shortlog.py	Mon Apr 15 23:12:09 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-    rhodecode.controllers.shortlog
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-    Shortlog controller for rhodecode
-
-    :created_on: Apr 18, 2010
-    :author: marcink
-    :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
-    :license: GPLv3, see COPYING for more details.
-"""
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-import logging
-
-from pylons import tmpl_context as c, request, url
-from pylons.i18n.translation import _
-
-from rhodecode.lib import helpers as h
-from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
-from rhodecode.lib.base import BaseRepoController, render
-from rhodecode.lib.helpers import RepoPage
-from pylons.controllers.util import redirect
-from rhodecode.lib.utils2 import safe_int
-from rhodecode.lib.vcs.exceptions import NodeDoesNotExistError, ChangesetError,\
-    RepositoryError
-
-log = logging.getLogger(__name__)
-
-
-class ShortlogController(BaseRepoController):
-
-    def __before__(self):
-        super(ShortlogController, self).__before__()
-
-    def __get_cs_or_redirect(self, rev, repo_name, redirect_after=True):
-        """
-        Safe way to get changeset if error occur it redirects to tip with
-        proper message
-
-        :param rev: revision to fetch
-        :param repo_name: repo name to redirect after
-        """
-
-        try:
-            return c.rhodecode_repo.get_changeset(rev)
-        except RepositoryError, e:
-            h.flash(str(e), category='warning')
-            redirect(h.url('shortlog_home', repo_name=repo_name))
-
-    @LoginRequired()
-    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
-                                   'repository.admin')
-    def index(self, repo_name, revision=None, f_path=None):
-        p = safe_int(request.GET.get('page', 1), 1)
-        size = safe_int(request.GET.get('size', 20), 20)
-        collection = c.rhodecode_repo
-        c.file_history = f_path
-
-        def url_generator(**kw):
-            if f_path:
-                return url('shortlog_file_home', repo_name=repo_name,
-                           revision=revision, f_path=f_path, size=size, **kw)
-            return url('shortlog_home', repo_name=repo_name, size=size, **kw)
-
-        if f_path:
-            log.debug('generating shortlog for path %s' % f_path)
-            # get the history for the file !
-            tip_cs = c.rhodecode_repo.get_changeset()
-            try:
-                collection = tip_cs.get_file_history(f_path)
-            except (NodeDoesNotExistError, ChangesetError):
-                #this node is not present at tip !
-                try:
-                    cs = self.__get_cs_or_redirect(revision, repo_name)
-                    collection = cs.get_file_history(f_path)
-                except RepositoryError, e:
-                    h.flash(str(e), category='warning')
-                    redirect(h.url('shortlog_home', repo_name=repo_name))
-            collection = list(reversed(collection))
-
-        c.repo_changesets = RepoPage(collection, page=p,
-                                     items_per_page=size, url=url_generator)
-        page_revisions = [x.raw_id for x in list(c.repo_changesets)]
-        c.statuses = c.rhodecode_db_repo.statuses(page_revisions)
-
-        if not c.repo_changesets:
-            h.flash(_('There are no changesets yet'), category='warning')
-            return redirect(url('summary_home', repo_name=repo_name))
-
-        c.shortlog_data = render('shortlog/shortlog_data.html')
-        if request.environ.get('HTTP_X_PARTIAL_XHR'):
-            return c.shortlog_data
-        r = render('shortlog/shortlog.html')
-        return r
--- a/rhodecode/controllers/summary.py	Mon Apr 15 23:12:09 2013 +0200
+++ b/rhodecode/controllers/summary.py	Tue Apr 16 00:44:48 2013 +0200
@@ -55,6 +55,7 @@
 from rhodecode.lib.helpers import RepoPage
 from rhodecode.lib.compat import json, OrderedDict
 from rhodecode.lib.vcs.nodes import FileNode
+from rhodecode.controllers.changelog import _load_changelog_summary
 
 log = logging.getLogger(__name__)
 
@@ -136,15 +137,7 @@
                                    'repository.admin')
     def index(self, repo_name):
         c.dbrepo = dbrepo = c.rhodecode_db_repo
-
-        def url_generator(**kw):
-            return url('shortlog_home', repo_name=repo_name, size=10, **kw)
-
-        c.repo_changesets = RepoPage(c.rhodecode_repo, page=1,
-                                     items_per_page=10, url=url_generator)
-        page_revisions = [x.raw_id for x in list(c.repo_changesets)]
-        c.statuses = c.rhodecode_db_repo.statuses(page_revisions)
-
+        _load_changelog_summary()
         if self.rhodecode_user.username == 'default':
             # for default(anonymous) user we don't need to pass credentials
             username = ''
--- a/rhodecode/public/css/contextbar.css	Mon Apr 15 23:12:09 2013 +0200
+++ b/rhodecode/public/css/contextbar.css	Tue Apr 16 00:44:48 2013 +0200
@@ -21,7 +21,6 @@
 #context-bar a.tags { background-image: url("../images/icons/tag_blue.png"); }
 #context-bar a.bookmarks { background-image: url("../images/icons/tag_green.png"); }
 #context-bar a.settings { background-image: url("../images/icons/cog.png"); }
-#context-bar a.shortlog { background-image: url("../images/icons/time.png"); }
 #context-bar a.search { background-image: url("../images/icons/search_16.png"); }
 #context-bar a.admin { background-image: url("../images/icons/cog_edit.png"); }
 
--- a/rhodecode/public/css/style.css	Mon Apr 15 23:12:09 2013 +0200
+++ b/rhodecode/public/css/style.css	Tue Apr 16 00:44:48 2013 +0200
@@ -544,10 +544,6 @@
     background-image: url("../images/icons/search_16.png");
 }
 
-#header #header-inner #quick li ul li a.shortlog, #header #header-inner #quick li ul li a.shortlog:hover {
-    background-image: url("../images/icons/clock_16.png");
-}
-
 #header #header-inner #quick li ul li a.delete, #header #header-inner #quick li ul li a.delete:hover {
     background-image: url("../images/icons/delete.png");
 }
@@ -2761,12 +2757,6 @@
     margin: 0px 2px;
 }
 
-#shortlog_data .branchtag,
-#shortlog_data .booktag,
-#shortlog_data .tagtag {
-    margin: 0px 2px;
-}
-
 .branchtag,
 .tagtag,
 .booktag,
--- a/rhodecode/templates/base/base.html	Mon Apr 15 23:12:09 2013 +0200
+++ b/rhodecode/templates/base/base.html	Tue Apr 16 00:44:48 2013 +0200
@@ -128,7 +128,6 @@
               %if c.rhodecode_db_repo.fork:
                <li>${h.link_to(_('Compare fork'),h.url('compare_url',repo_name=c.rhodecode_db_repo.fork.repo_name,org_ref_type='branch',org_ref='default',other_repo=c.repo_name,other_ref_type='branch',other_ref=request.GET.get('branch') or 'default', merge=1),class_='compare_request')}</li>
               %endif
-              <li>${h.link_to(_('Lightweight changelog'),h.url('shortlog_home',repo_name=c.repo_name),class_='shortlog')}</li>
               <li>${h.link_to(_('Search'),h.url('search_repo',repo_name=c.repo_name),class_='search')}</li>
 
               %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.rhodecode_db_repo.enable_locking:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rhodecode/templates/changelog/changelog_summary_data.html	Tue Apr 16 00:44:48 2013 +0200
@@ -0,0 +1,103 @@
+## -*- coding: utf-8 -*-
+%if c.repo_changesets:
+<table class="table_disp">
+    <tr>
+        <th class="left">${_('Revision')}</th>
+        <th class="left">${_('Commit message')}</th>
+        <th class="left">${_('Age')}</th>
+        <th class="left">${_('Author')}</th>
+        <th class="left">${_('Refs')}</th>
+    </tr>
+%for cnt,cs in enumerate(c.repo_changesets):
+    <tr class="parity${cnt%2}">
+        <td>
+          <div>
+            <div class="changeset-status-container">
+              %if c.statuses.get(cs.raw_id):
+                <div class="changeset-status-ico">
+                %if c.statuses.get(cs.raw_id)[2]:
+                  <a class="tooltip" title="${_('Click to open associated pull request #%s' % c.statuses.get(cs.raw_id)[2])}" href="${h.url('pullrequest_show',repo_name=c.statuses.get(cs.raw_id)[3],pull_request_id=c.statuses.get(cs.raw_id)[2])}">
+                    <img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses.get(cs.raw_id)[0])}" />
+                  </a>
+                %else:
+                  <img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses.get(cs.raw_id)[0])}" />
+                %endif
+                </div>
+              %endif
+            </div>
+            <pre><a href="${h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id)}">${h.show_id(cs)}</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))}
+        </td>
+        <td><span class="tooltip" title="${h.tooltip(h.fmt_date(cs.date))}">
+                      ${h.age(cs.date)}</span>
+        </td>
+        <td title="${cs.author}">${h.person(cs.author)}</td>
+        <td>
+            %if h.is_hg(c.rhodecode_repo):
+                %for book in cs.bookmarks:
+                    <div class="booktag" title="${_('Bookmark %s') % book}">
+                        ${h.link_to(h.shorter(book),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}
+                    </div>
+                %endfor
+            %endif
+            %for tag in cs.tags:
+             <div class="tagtag" title="${_('Tag %s') % tag}">
+                 ${h.link_to(h.shorter(tag),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}
+             </div>
+            %endfor
+            %if cs.branch:
+             <div class="branchtag" title="${_('Branch %s' % cs.branch)}">
+                 ${h.link_to(h.shorter(cs.branch),h.url('changelog_home',repo_name=c.repo_name,branch=cs.branch))}
+             </div>
+            %endif
+        </td>
+    </tr>
+%endfor
+
+</table>
+
+<script type="text/javascript">
+  YUE.onDOMReady(function(){
+    YUE.delegate("shortlog_data","click",function(e, matchedEl, container){
+        ypjax(e.target.href,"shortlog_data",function(){tooltip_activate();});
+        YUE.preventDefault(e);
+    },'.pager_link');
+  });
+</script>
+
+<div class="pagination-wh pagination-left">
+${c.repo_changesets.pager('$link_previous ~2~ $link_next')}
+</div>
+%else:
+
+%if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
+<h4>${_('Add or upload files directly via RhodeCode')}</h4>
+<div style="margin: 20px 30px;">
+  <div id="add_node_id" class="add_node">
+      <a class="ui-btn" href="${h.url('files_add_home',repo_name=c.repo_name,revision=0,f_path='')}">${_('Add new file')}</a>
+  </div>
+</div>
+%endif
+
+
+<h4>${_('Push new repo')}</h4>
+<pre>
+    ${c.rhodecode_repo.alias} clone ${c.clone_repo_url}
+    ${c.rhodecode_repo.alias} add README # add first file
+    ${c.rhodecode_repo.alias} commit -m "Initial" # commit with message
+    ${c.rhodecode_repo.alias} push ${'origin master' if h.is_git(c.rhodecode_repo) else ''} # push changes back
+</pre>
+
+<h4>${_('Existing repository?')}</h4>
+<pre>
+%if h.is_git(c.rhodecode_repo):
+    git remote add origin ${c.clone_repo_url}
+    git push -u origin master
+%else:
+    hg push ${c.clone_repo_url}
+%endif
+</pre>
+%endif
--- a/rhodecode/templates/shortlog/shortlog.html	Mon Apr 15 23:12:09 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-## -*- coding: utf-8 -*-
-<%inherit file="/base/base.html"/>
-
-<%def name="title()">
-    ${_('%s Lightweight Changelog') % c.repo_name} &middot; ${c.rhodecode_name}
-</%def>
-
-
-<%def name="breadcrumbs_links()">
-    %if c.file_history:
-        ${h.link_to(_('Lightweight Changelog'),h.url('shortlog_home',repo_name=c.repo_name))}
-        &raquo;
-        ${c.file_history}
-    %else:
-        ${_('Lightweight Changelog')}
-    %endif
-</%def>
-
-<%def name="page_nav()">
-    ${self.menu('repositories')}
-</%def>
-
-<%def name="main()">
-${self.context_bar('options')}
-<div class="box">
-    <!-- box / title -->
-    <div class="title">
-        ${self.breadcrumbs()}
-    </div>
-    <!-- end box / title -->
-    <div class="table">
-        <div id="shortlog_data">
-            ${c.shortlog_data}
-        </div>
-    </div>
-</div>
-</%def>
--- a/rhodecode/templates/shortlog/shortlog_data.html	Mon Apr 15 23:12:09 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-## -*- coding: utf-8 -*-
-%if c.repo_changesets:
-<table class="table_disp">
-    <tr>
-        <th class="left">${_('Revision')}</th>
-        <th class="left">${_('Commit message')}</th>
-        <th class="left">${_('Age')}</th>
-        <th class="left">${_('Author')}</th>
-        <th class="left">${_('Refs')}</th>
-    </tr>
-%for cnt,cs in enumerate(c.repo_changesets):
-    <tr class="parity${cnt%2}">
-        <td>
-          <div>
-            <div class="changeset-status-container">
-              %if c.statuses.get(cs.raw_id):
-                <div class="changeset-status-ico">
-                %if c.statuses.get(cs.raw_id)[2]:
-                  <a class="tooltip" title="${_('Click to open associated pull request #%s' % c.statuses.get(cs.raw_id)[2])}" href="${h.url('pullrequest_show',repo_name=c.statuses.get(cs.raw_id)[3],pull_request_id=c.statuses.get(cs.raw_id)[2])}">
-                    <img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses.get(cs.raw_id)[0])}" />
-                  </a>
-                %else:
-                  <img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses.get(cs.raw_id)[0])}" />
-                %endif
-                </div>
-              %endif
-            </div>
-            <pre><a href="${h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id)}">${h.show_id(cs)}</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))}
-        </td>
-        <td><span class="tooltip" title="${h.tooltip(h.fmt_date(cs.date))}">
-                      ${h.age(cs.date)}</span>
-        </td>
-        <td title="${cs.author}">${h.person(cs.author)}</td>
-        <td>
-            %if h.is_hg(c.rhodecode_repo):
-                %for book in cs.bookmarks:
-                    <div class="booktag" title="${_('Bookmark %s') % book}">
-                        ${h.link_to(h.shorter(book),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}
-                    </div>
-                %endfor
-            %endif
-            %for tag in cs.tags:
-             <div class="tagtag" title="${_('Tag %s') % tag}">
-                 ${h.link_to(h.shorter(tag),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}
-             </div>
-            %endfor
-            %if cs.branch:
-             <div class="branchtag" title="${_('Branch %s' % cs.branch)}">
-                 ${h.link_to(h.shorter(cs.branch),h.url('changelog_home',repo_name=c.repo_name,branch=cs.branch))}
-             </div>
-            %endif
-        </td>
-    </tr>
-%endfor
-
-</table>
-
-<script type="text/javascript">
-  YUE.onDOMReady(function(){
-    YUE.delegate("shortlog_data","click",function(e, matchedEl, container){
-        ypjax(e.target.href,"shortlog_data",function(){tooltip_activate();});
-        YUE.preventDefault(e);
-    },'.pager_link');
-  });
-</script>
-
-<div class="pagination-wh pagination-left">
-${c.repo_changesets.pager('$link_previous ~2~ $link_next')}
-</div>
-%else:
-
-%if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
-<h4>${_('Add or upload files directly via RhodeCode')}</h4>
-<div style="margin: 20px 30px;">
-  <div id="add_node_id" class="add_node">
-      <a class="ui-btn" href="${h.url('files_add_home',repo_name=c.repo_name,revision=0,f_path='')}">${_('Add new file')}</a>
-  </div>
-</div>
-%endif
-
-
-<h4>${_('Push new repo')}</h4>
-<pre>
-    ${c.rhodecode_repo.alias} clone ${c.clone_repo_url}
-    ${c.rhodecode_repo.alias} add README # add first file
-    ${c.rhodecode_repo.alias} commit -m "Initial" # commit with message
-    ${c.rhodecode_repo.alias} push ${'origin master' if h.is_git(c.rhodecode_repo) else ''} # push changes back
-</pre>
-
-<h4>${_('Existing repository?')}</h4>
-<pre>
-%if h.is_git(c.rhodecode_repo):
-    git remote add origin ${c.clone_repo_url}
-    git push -u origin master
-%else:
-    hg push ${c.clone_repo_url}
-%endif
-</pre>
-%endif
--- a/rhodecode/templates/summary/summary.html	Mon Apr 15 23:12:09 2013 +0200
+++ b/rhodecode/templates/summary/summary.html	Tue Apr 16 00:44:48 2013 +0200
@@ -261,7 +261,7 @@
     </div>
     <div class="table">
         <div id="shortlog_data">
-            <%include file='../shortlog/shortlog_data.html'/>
+            <%include file='../changelog/changelog_summary_data.html'/>
         </div>
     </div>
 </div>
--- a/rhodecode/tests/functional/test_shortlog.py	Mon Apr 15 23:12:09 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-from rhodecode.tests import *
-
-
-class TestShortlogController(TestController):
-
-    def test_index_hg(self):
-        self.log_user()
-        response = self.app.get(url(controller='shortlog', action='index',
-                                    repo_name=HG_REPO))
-        # Test response...
-
-    def test_index_git(self):
-        self.log_user()
-        response = self.app.get(url(controller='shortlog', action='index',
-                                    repo_name=GIT_REPO))
-        # Test response...