Show More
@@ -34,10 +34,10 b' def make_map(config):' | |||||
34 |
|
34 | |||
35 | map.connect('changeset_home', '/{repo_name}/changeset/{revision}', controller='changeset', revision='tip') |
|
35 | map.connect('changeset_home', '/{repo_name}/changeset/{revision}', controller='changeset', revision='tip') | |
36 | map.connect('summary_home', '/{repo_name}/summary', controller='summary') |
|
36 | map.connect('summary_home', '/{repo_name}/summary', controller='summary') | |
37 |
map.connect(' |
|
37 | map.connect('shortlog_home', '/{repo_name}/shortlog/{revision}', controller='shortlog', revision='tip') | |
38 | map.connect('branches_home', '/{repo_name}/branches', controller='branches') |
|
38 | map.connect('branches_home', '/{repo_name}/branches', controller='branches') | |
39 | map.connect('tags_home', '/{repo_name}/tags', controller='tags') |
|
39 | map.connect('tags_home', '/{repo_name}/tags', controller='tags') | |
40 |
map.connect(' |
|
40 | map.connect('changelog_home', '/{repo_name}/changelog/{revision}', controller='changelog', revision='tip') | |
41 | map.connect('files_home', '/{repo_name}/files/{revision}/{f_path:.*}', controller='files', revision='tip', f_path='') |
|
41 | map.connect('files_home', '/{repo_name}/files/{revision}/{f_path:.*}', controller='files', revision='tip', f_path='') | |
42 | map.connect('files_diff_home', '/{repo_name}/diff/{f_path:.*}', controller='files', action='diff', revision='tip', f_path='') |
|
42 | map.connect('files_diff_home', '/{repo_name}/diff/{f_path:.*}', controller='files', action='diff', revision='tip', f_path='') | |
43 |
|
43 |
@@ -1,12 +1,18 b'' | |||||
1 | import logging |
|
1 | import logging | |
2 |
|
2 | from pylons import request, response, session, tmpl_context as c, url, config, \ | ||
3 | from pylons import tmpl_context as c, app_globals as g, session, request, config, url |
|
3 | app_globals as g | |
4 | from pylons.controllers.util import abort, redirect |
|
4 | from pylons.controllers.util import abort, redirect | |
5 |
|
||||
6 | from pylons_app.lib.base import BaseController, render |
|
5 | from pylons_app.lib.base import BaseController, render | |
7 | from pylons_app.lib.utils import get_repo_slug |
|
6 | from pylons_app.lib.utils import get_repo_slug | |
8 | from pylons_app.model.hg_model import HgModel |
|
7 | from pylons_app.model.hg_model import HgModel | |
|
8 | ||||
|
9 | from mercurial.graphmod import revisions as graph_rev, colored, CHANGESET | |||
|
10 | from pylons_app.lib.filters import age as _age, person | |||
|
11 | from simplejson import dumps | |||
|
12 | from mercurial.node import short | |||
9 | from webhelpers.paginate import Page |
|
13 | from webhelpers.paginate import Page | |
|
14 | ||||
|
15 | ||||
10 |
|
16 | |||
11 | log = logging.getLogger(__name__) |
|
17 | log = logging.getLogger(__name__) | |
12 |
|
18 | |||
@@ -16,12 +22,44 b' class ChangelogController(BaseController' | |||||
16 | c.repo_name = get_repo_slug(request) |
|
22 | c.repo_name = get_repo_slug(request) | |
17 |
|
23 | |||
18 | def index(self): |
|
24 | def index(self): | |
|
25 | # Return a rendered template | |||
19 | hg_model = HgModel() |
|
26 | hg_model = HgModel() | |
|
27 | if request.POST.get('size'): | |||
|
28 | c.size = int(request.params.get('size', 20)) | |||
|
29 | else: | |||
|
30 | c.size = int(request.params.get('size', 20)) | |||
|
31 | c.jsdata, c.canvasheight = self.graph(hg_model.get_repo(c.repo_name), c.size) | |||
|
32 | ||||
|
33 | return render('changelog/changelog.html') | |||
|
34 | ||||
|
35 | ||||
|
36 | def graph(self, repo, size): | |||
|
37 | revcount = size | |||
20 | p = int(request.params.get('page', 1)) |
|
38 | p = int(request.params.get('page', 1)) | |
21 | repo = hg_model.get_repo(c.repo_name) |
|
39 | c.pagination = Page(repo.revisions, page=p, item_count=len(repo.revisions), items_per_page=revcount) | |
22 | c.repo_changesets = Page(repo, page=p, items_per_page=20) |
|
40 | if not repo.revisions:return dumps([]), 0 | |
23 | c.shortlog_data = render('shortlog/shortlog_data.html') |
|
41 | ||
24 | if request.params.get('partial'): |
|
42 | max_rev = repo.revisions[-1] | |
25 | return c.shortlog_data |
|
43 | offset = 1 if p == 1 else ((p - 1) * revcount) | |
26 | r = render('shortlog/shortlog.html') |
|
44 | rev_start = repo.revisions[(-1 * offset)] | |
27 | return r |
|
45 | bg_height = 39 | |
|
46 | ||||
|
47 | revcount = min(max_rev, revcount) | |||
|
48 | rev_end = max(0, rev_start - revcount) | |||
|
49 | dag = graph_rev(repo.repo, rev_start, rev_end) | |||
|
50 | tree = list(colored(dag)) | |||
|
51 | canvasheight = (len(tree) + 1) * bg_height - 27 | |||
|
52 | data = [] | |||
|
53 | for (id, type, ctx, vtx, edges) in tree: | |||
|
54 | if type != CHANGESET: | |||
|
55 | continue | |||
|
56 | node = short(ctx.node()) | |||
|
57 | age = _age(ctx.date()) | |||
|
58 | desc = ctx.description() | |||
|
59 | user = person(ctx.user()) | |||
|
60 | branch = ctx.branch() | |||
|
61 | branch = branch, repo.repo.branchtags().get(branch) == ctx.node() | |||
|
62 | data.append((node, vtx, edges, desc, user, age, branch, ctx.tags())) | |||
|
63 | ||||
|
64 | return dumps(data), canvasheight | |||
|
65 |
@@ -18,12 +18,14 b' class FilesController(BaseController):' | |||||
18 | c.repo_name = get_repo_slug(request) |
|
18 | c.repo_name = get_repo_slug(request) | |
19 |
|
19 | |||
20 | def index(self, repo_name, revision, f_path): |
|
20 | def index(self, repo_name, revision, f_path): | |
|
21 | revision = request.POST.get('at_rev', None) or revision | |||
21 | hg_model = HgModel() |
|
22 | hg_model = HgModel() | |
22 | c.repo = repo = hg_model.get_repo(c.repo_name) |
|
23 | c.repo = repo = hg_model.get_repo(c.repo_name) | |
23 | c.cur_rev = revision |
|
|||
24 | c.f_path = f_path |
|
24 | c.f_path = f_path | |
25 | try: |
|
25 | try: | |
26 | c.changeset = repo.get_changeset(repo._get_revision(revision)) |
|
26 | c.changeset = repo.get_changeset(repo._get_revision(revision)) | |
|
27 | c.cur_rev = c.changeset.raw_id | |||
|
28 | c.rev_nr = c.changeset.revision | |||
27 | c.files_list = c.changeset.get_node(f_path) |
|
29 | c.files_list = c.changeset.get_node(f_path) | |
28 | c.file_history = self._get_history(repo, c.files_list, f_path) |
|
30 | c.file_history = self._get_history(repo, c.files_list, f_path) | |
29 | except RepositoryError: |
|
31 | except RepositoryError: |
General Comments 0
You need to be logged in to leave comments.
Login now