17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
import json as simplejson
23
26
from paste.httpexceptions import HTTPServerError
45
47
filter_file_id = kwargs.get('filter_file_id', None)
46
48
start_revid = h.fix_revid(kwargs.get('start_revid', None))
47
49
query = kwargs.get('q', None)
50
remember = h.fix_revid(kwargs.get('remember', None))
48
51
compare_revid = h.fix_revid(kwargs.get('compare_revid', None))
50
# TODO: This try/except looks to date before real exception handling
51
# and should be removed
53
54
revid, start_revid, revid_list = h.get_view(revid,
58
59
self.log.exception('Exception fetching changes')
59
60
raise HTTPServerError('Could not fetch changes')
60
# XXX: Some concern about namespace collisions. These are only stored
61
# here so they can be expanded into the template later. Should probably
62
# be stored in a specific dict/etc.
63
self.revid_list = revid_list
64
self.compare_revid = compare_revid
66
kwargs['start_revid'] = start_revid
62
navigation = util.Container(
63
revid_list=revid_list, revid=revid, start_revid=start_revid,
64
filter_file_id=filter_file_id, pagesize=1,
65
scan_url='/revision', branch=self._branch, feed=True, history=h)
67
navigation.query = query
68
util.fill_in_navigation(navigation)
68
70
change = h.get_changes([revid])[0]
73
75
file_changes = h.file_changes_for_revision_ids(
74
76
compare_revid, change.revid)
76
h.add_branch_nicks(change)
78
if '.' in change.revno:
79
# Walk "up" though the merge-sorted graph until we find a
80
# revision with merge depth 0: this is the revision that merged
81
# this one to mainline.
82
ri = self._history._rev_info
83
i = self._history._rev_indices[change.revid]
84
while ri[i][0][2] > 0:
86
merged_in = ri[i][0][3]
93
'file_changes': file_changes,
94
'merged_in': merged_in,
97
def add_template_values(self, values):
98
super(RevisionUI, self).add_template_values(values)
99
remember = self._history.fix_revid(self.kwargs.get('remember', None))
100
query = self.kwargs.get('q', None)
101
filter_file_id = self.kwargs.get('filter_file_id', None)
102
start_revid = self.kwargs['start_revid']
103
navigation = util.Container(
104
revid_list=self.revid_list, revid=values['revid'],
105
start_revid=start_revid,
106
filter_file_id=filter_file_id, pagesize=1,
107
scan_url='/revision', branch=self._branch, feed=True,
108
history=self._history)
109
if query is not None:
110
navigation.query = query
111
util.fill_in_navigation(navigation)
113
78
if path in ('', '/'):
117
file_changes = values['file_changes']
121
items = [x for x in file_changes.text_changes if x.filename == path]
124
diff_chunks = diff_chunks_for_file(
125
self._history._branch.repository, item.file_id,
126
item.old_revision, item.new_revision)
84
item = [x for x in file_changes.text_changes if x.filename == path][0]
85
diff_chunks = diff_chunks_for_file(
86
self._history._branch.repository, item.file_id,
87
item.old_revision, item.new_revision)
130
89
diff_chunks = None
131
90
for i, item in enumerate(file_changes.text_changes):
134
93
dq(item.new_revision), dq(item.old_revision), dq(item.file_id))
135
94
path_to_id[item.filename] = 'diff-' + str(i)
96
h.add_branch_nicks(change)
137
98
# Directory Breadcrumbs
138
99
directory_breadcrumbs = (
139
100
util.directory_breadcrumbs(
140
101
self._branch.friendly_name,
141
102
self._branch.is_root,
143
can_export = self._branch.export_tarballs
146
'history': self._history,
106
'branch': self._branch,
109
'file_changes': file_changes,
110
'diff_chunks': diff_chunks,
147
111
'link_data': simplejson.dumps(link_data),
112
'specific_path': path,
148
113
'json_specific_path': simplejson.dumps(path),
149
114
'path_to_id': simplejson.dumps(path_to_id),
150
'directory_breadcrumbs': directory_breadcrumbs,
115
'start_revid': start_revid,
116
'filter_file_id': filter_file_id,
151
119
'navigation': navigation,
152
121
'remember': remember,
153
'compare_revid': self.compare_revid,
154
'filter_file_id': filter_file_id,
155
'diff_chunks': diff_chunks,
157
'can_export': can_export,
158
'specific_path': path,
159
'start_revid': start_revid,
122
'compare_revid': compare_revid,
123
'url': self._branch.context_url,
124
'directory_breadcrumbs': directory_breadcrumbs,