1
by Robey Pointer
initial checkin |
1 |
#
|
356.3.1
by Martin Albisetti
Bumped the minimun bzr version to 1.13, and removed some compatibility, as well as random header cleanups |
2 |
# Copyright (C) 2008, 2009 Canonical Ltd.
|
1
by Robey Pointer
initial checkin |
3 |
# Copyright (C) 2006 Robey Pointer <robey@lag.net>
|
23
by Robey Pointer
lots of little changes: |
4 |
# Copyright (C) 2006 Goffredo Baroncelli <kreijack@inwind.it>
|
1
by Robey Pointer
initial checkin |
5 |
#
|
6 |
# This program is free software; you can redistribute it and/or modify
|
|
7 |
# it under the terms of the GNU General Public License as published by
|
|
8 |
# the Free Software Foundation; either version 2 of the License, or
|
|
9 |
# (at your option) any later version.
|
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19 |
#
|
|
20 |
||
302
by Michael Hudson
it seems that double url-encoding the revid we put in the +revlog url is |
21 |
import urllib |
297.1.2
by Michael Hudson
somewhat works now |
22 |
|
429.1.1
by Jelmer Vernooij
Drop support for json as simplejson alternative. |
23 |
import simplejson |
306
by Matt Nordhoff
Use Python 2.6's json module if simplejson is unavailable |
24 |
|
159.2.6
by Michael Hudson
less cherry |
25 |
from paste.httpexceptions import HTTPServerError |
1
by Robey Pointer
initial checkin |
26 |
|
27 |
from loggerhead import util |
|
159.2.44
by Michael Hudson
factor out some template boilerplate |
28 |
from loggerhead.controllers import TemplatedBranchView |
29 |
||
30 |
||
31 |
class ChangeLogUI(TemplatedBranchView): |
|
32 |
||
33 |
template_path = 'loggerhead.templates.changelog' |
|
34 |
||
249.1.1
by Robert Collins
Faster search logic - less double checking etc etc, seems to work. |
35 |
def get_values(self, path, kwargs, headers): |
36 |
history = self._history |
|
37 |
revid = self.get_revid() |
|
219.2.1
by Martin Albisetti
* Refactor everything to use revid and path as an argument |
38 |
filter_file_id = kwargs.get('filter_file_id', None) |
39 |
query = kwargs.get('q', None) |
|
219.2.14
by Martin Albisetti
s/h/history/ |
40 |
start_revid = history.fix_revid(kwargs.get('start_revid', None)) |
159.2.44
by Michael Hudson
factor out some template boilerplate |
41 |
orig_start_revid = start_revid |
42 |
pagesize = 20#int(config.get('pagesize', '20')) |
|
43 |
search_failed = False |
|
44 |
||
219.2.1
by Martin Albisetti
* Refactor everything to use revid and path as an argument |
45 |
if filter_file_id is None and path is not None: |
219.2.14
by Martin Albisetti
s/h/history/ |
46 |
filter_file_id = history.get_file_id(revid, path) |
219.2.1
by Martin Albisetti
* Refactor everything to use revid and path as an argument |
47 |
|
8
by Robey Pointer
figured out what the merge points logic was about, and yes it was important, and yes i was using it in a totally wrong way before, and yes i had incompetently tried to roll my own equivalent without fully understanding it. so switch to merge points. |
48 |
try: |
219.2.14
by Martin Albisetti
s/h/history/ |
49 |
revid, start_revid, revid_list = history.get_view( |
411.4.1
by John Arbash Meinel
Only load enough history to show what we need. |
50 |
revid, start_revid, filter_file_id, query, |
51 |
extra_rev_count=pagesize+1) |
|
219.2.1
by Martin Albisetti
* Refactor everything to use revid and path as an argument |
52 |
util.set_context(kwargs) |
159.2.44
by Michael Hudson
factor out some template boilerplate |
53 |
|
54 |
if (query is not None) and (len(revid_list) == 0): |
|
55 |
search_failed = True |
|
56 |
||
57 |
if len(revid_list) == 0: |
|
58 |
scan_list = revid_list |
|
41
by Robey Pointer
initial search ui (revid, date, and very slow text search) |
59 |
else: |
159.2.44
by Michael Hudson
factor out some template boilerplate |
60 |
if revid in revid_list: # XXX is this always true? |
61 |
i = revid_list.index(revid) |
|
128.1.19
by Michael Hudson
simplifications |
62 |
else: |
159.2.44
by Michael Hudson
factor out some template boilerplate |
63 |
i = None |
64 |
scan_list = revid_list[i:] |
|
65 |
change_list = scan_list[:pagesize] |
|
219.2.14
by Martin Albisetti
s/h/history/ |
66 |
changes = list(history.get_changes(change_list)) |
297.1.2
by Michael Hudson
somewhat works now |
67 |
data = {} |
68 |
for i, c in enumerate(changes): |
|
69 |
c.index = i |
|
302
by Michael Hudson
it seems that double url-encoding the revid we put in the +revlog url is |
70 |
data[str(i)] = urllib.quote(urllib.quote(c.revid, safe='')) |
159.2.44
by Michael Hudson
factor out some template boilerplate |
71 |
except: |
72 |
self.log.exception('Exception fetching changes') |
|
73 |
raise HTTPServerError('Could not fetch changes') |
|
74 |
||
75 |
navigation = util.Container( |
|
76 |
pagesize=pagesize, revid=revid, start_revid=start_revid, |
|
77 |
revid_list=revid_list, filter_file_id=filter_file_id, |
|
219.2.14
by Martin Albisetti
s/h/history/ |
78 |
scan_url='/changes', branch=self._branch, feed=True, history=history) |
159.2.44
by Michael Hudson
factor out some template boilerplate |
79 |
if query is not None: |
80 |
navigation.query = query |
|
81 |
util.fill_in_navigation(navigation) |
|
82 |
||
201.2.10
by Russ Brown
Simplified the shared breadcrumb code and templates, and added to other views |
83 |
# Directory Breadcrumbs
|
84 |
directory_breadcrumbs = ( |
|
85 |
util.directory_breadcrumbs( |
|
86 |
self._branch.friendly_name, |
|
87 |
self._branch.is_root, |
|
88 |
'changes')) |
|
89 |
||
366.1.3
by Michael Hudson
don't show tags column if there are no tags to show |
90 |
show_tag_col = False |
91 |
for change in changes: |
|
92 |
if change.tags is not None: |
|
93 |
show_tag_col = True |
|
94 |
break
|
|
95 |
||
159.2.44
by Michael Hudson
factor out some template boilerplate |
96 |
return { |
97 |
'branch': self._branch, |
|
98 |
'changes': changes, |
|
366.1.3
by Michael Hudson
don't show tags column if there are no tags to show |
99 |
'show_tag_col': show_tag_col, |
297.1.2
by Michael Hudson
somewhat works now |
100 |
'data': simplejson.dumps(data), |
159.2.44
by Michael Hudson
factor out some template boilerplate |
101 |
'util': util, |
219.2.14
by Martin Albisetti
s/h/history/ |
102 |
'history': history, |
159.2.44
by Michael Hudson
factor out some template boilerplate |
103 |
'revid': revid, |
104 |
'navigation': navigation, |
|
105 |
'filter_file_id': filter_file_id, |
|
106 |
'start_revid': start_revid, |
|
329.2.1
by Matt Nordhoff
Strip trailing whitespace |
107 |
'viewing_from': (orig_start_revid is not None) and |
219.2.14
by Martin Albisetti
s/h/history/ |
108 |
(orig_start_revid != history.last_revid), |
159.2.44
by Michael Hudson
factor out some template boilerplate |
109 |
'query': query, |
110 |
'search_failed': search_failed, |
|
111 |
'url': self._branch.context_url, |
|
201.2.10
by Russ Brown
Simplified the shared breadcrumb code and templates, and added to other views |
112 |
'directory_breadcrumbs': directory_breadcrumbs, |
159.2.44
by Michael Hudson
factor out some template boilerplate |
113 |
}
|