comparison pylons_app/controllers/changelog.py @ 252:3782a6d698af

licensing updates, code cleanups
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 04 Jun 2010 13:08:29 +0200
parents a83a1799480c
children 5e59f29edf66
comparison
equal deleted inserted replaced
251:127dba22e53b 252:3782a6d698af
1 from mercurial.graphmod import revisions as graph_rev, colored, CHANGESET 1 #!/usr/bin/env python
2 from mercurial.node import short 2 # encoding: utf-8
3 # changelog controller for pylons
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
9 # of the License or (at your opinion) any later version of the license.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20 """
21 Created on April 21, 2010
22 changelog controller for pylons
23 @author: marcink
24 """
3 from pylons import request, session, tmpl_context as c 25 from pylons import request, session, tmpl_context as c
4 from pylons_app.lib.auth import LoginRequired 26 from pylons_app.lib.auth import LoginRequired
5 from pylons_app.lib.base import BaseController, render 27 from pylons_app.lib.base import BaseController, render
6 from pylons_app.lib.filters import age as _age, person
7 from pylons_app.model.hg_model import _full_changelog_cached 28 from pylons_app.model.hg_model import _full_changelog_cached
8 from simplejson import dumps
9 from webhelpers.paginate import Page 29 from webhelpers.paginate import Page
10 import logging 30 import logging
11 log = logging.getLogger(__name__) 31 log = logging.getLogger(__name__)
12 32
13 class ChangelogController(BaseController): 33 class ChangelogController(BaseController):
41 61
42 return render('changelog/changelog.html') 62 return render('changelog/changelog.html')
43 63
44 64
45 def _graph(self, repo, size, p): 65 def _graph(self, repo, size, p):
46 revcount = size 66 pass
47 if not repo.revisions:return dumps([]), 0 67 # revcount = size
48 68 # if not repo.revisions:return dumps([]), 0
49 max_rev = repo.revisions[-1] 69 #
50 offset = 1 if p == 1 else ((p - 1) * revcount) 70 # max_rev = repo.revisions[-1]
51 rev_start = repo.revisions[(-1 * offset)] 71 # offset = 1 if p == 1 else ((p - 1) * revcount)
52 c.bg_height = 120 72 # rev_start = repo.revisions[(-1 * offset)]
53 73 # c.bg_height = 120
54 revcount = min(max_rev, revcount) 74 #
55 rev_end = max(0, rev_start - revcount) 75 # revcount = min(max_rev, revcount)
56 dag = graph_rev(repo.repo, rev_start, rev_end) 76 # rev_end = max(0, rev_start - revcount)
57 77 # dag = graph_rev(repo.repo, rev_start, rev_end)
58 c.dag = tree = list(colored(dag)) 78 #
59 canvasheight = (len(tree) + 1) * c.bg_height - 27 79 # c.dag = tree = list(colored(dag))
60 data = [] 80 # canvasheight = (len(tree) + 1) * c.bg_height - 27
61 for (id, type, ctx, vtx, edges) in tree: 81 # data = []
62 if type != CHANGESET: 82 # for (id, type, ctx, vtx, edges) in tree:
63 continue 83 # if type != CHANGESET:
64 node = short(ctx.node()) 84 # continue
65 age = _age(ctx.date()) 85 # node = short(ctx.node())
66 desc = ctx.description() 86 # age = _age(ctx.date())
67 user = person(ctx.user()) 87 # desc = ctx.description()
68 branch = ctx.branch() 88 # user = person(ctx.user())
69 branch = branch, repo.repo.branchtags().get(branch) == ctx.node() 89 # branch = ctx.branch()
70 data.append((node, vtx, edges, desc, user, age, branch, ctx.tags())) 90 # branch = branch, repo.repo.branchtags().get(branch) == ctx.node()
71 91 # data.append((node, vtx, edges, desc, user, age, branch, ctx.tags()))
72 c.jsdata = dumps(data) 92 #
73 c.canvasheight = canvasheight 93 # c.jsdata = dumps(data)
94 # c.canvasheight = canvasheight
74 95