16
16
# You should have received a copy of the GNU General Public License
17
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
18
# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
26
import json as simplejson
23
from breezy import osutils, urlutils
28
24
from paste.httpexceptions import HTTPServerError
30
from loggerhead import util
31
from loggerhead.controllers import TemplatedBranchView
27
from ..controllers import TemplatedBranchView
34
30
class ChangeLogUI(TemplatedBranchView):
36
template_path = 'loggerhead.templates.changelog'
32
template_name = 'changelog'
38
34
def get_values(self, path, kwargs, headers):
39
35
history = self._history
40
36
revid = self.get_revid()
41
filter_file_id = kwargs.get('filter_file_id', None)
37
filter_path = kwargs.get('filter_path', path)
42
38
query = kwargs.get('q', None)
43
39
start_revid = history.fix_revid(kwargs.get('start_revid', None))
44
40
orig_start_revid = start_revid
45
pagesize = 20#int(config.get('pagesize', '20'))
41
pagesize = 20 #int(config.get('pagesize', '20'))
46
42
search_failed = False
48
if filter_file_id is None and path is not None:
49
filter_file_id = history.get_file_id(revid, path)
52
45
revid, start_revid, revid_list = history.get_view(
53
revid, start_revid, filter_file_id, query)
46
revid, start_revid, filter_path, query,
47
extra_rev_count=pagesize+1)
54
48
util.set_context(kwargs)
56
50
if (query is not None) and (len(revid_list) == 0):
70
64
for i, c in enumerate(changes):
72
data[str(i)] = urllib.quote(urllib.quote(c.revid, safe=''))
66
data[str(i)] = urlutils.quote(urlutils.quote_from_bytes(c.revid, safe=''))
74
68
self.log.exception('Exception fetching changes')
75
69
raise HTTPServerError('Could not fetch changes')
77
71
navigation = util.Container(
78
72
pagesize=pagesize, revid=revid, start_revid=start_revid,
79
revid_list=revid_list, filter_file_id=filter_file_id,
73
revid_list=revid_list, filter_path=filter_path,
80
74
scan_url='/changes', branch=self._branch, feed=True, history=history)
81
75
if query is not None:
82
76
navigation.query = query
99
93
'branch': self._branch,
100
94
'changes': changes,
101
95
'show_tag_col': show_tag_col,
102
'data': simplejson.dumps(data),
96
'data': json.dumps(data),
104
98
'history': history,
106
100
'navigation': navigation,
107
'filter_file_id': filter_file_id,
101
'filter_path': filter_path,
108
102
'start_revid': start_revid,
109
103
'viewing_from': (orig_start_revid is not None) and
110
104
(orig_start_revid != history.last_revid),