195
200
'age': util.timespan(now - commit_time) + ' ago',
196
201
'short_comment': short_comment,
197
202
'comment': rev.message,
203
'comment_clean': util.html_clean(rev.message),
198
204
'parents': [util.Container(p) for p in parents],
205
'changes': self.diff_revisions(revid, left_parent, get_diffs=False),
200
207
return util.Container(entry)
227
234
yield ('>', None, None)
229
def diff_revisions(self, revid, otherrevid):
236
def diff_revisions(self, revid, otherrevid, get_diffs=True):
231
238
Return a nested data structure containing the changes between two
269
278
tree_file = bzrlib.textfile.text_file(tree.get_file(fid))
270
279
return tree_file.readlines()
273
# to avoid using <pre>, we need to turn spaces into nbsp, and kid
274
# doesn't notice u'\xa0', so we have to do it by hand, and escape
275
# html also. oh well.
277
return s.replace(' ', ' ')
279
281
def process_diff(diff):
282
284
for line in diff.splitlines():
284
# i think this happens because bazaar gets too aggressive about removing trailing whitespace
286
287
if line.startswith('+++ ') or line.startswith('--- '):
288
289
if line.startswith('@@ '):
296
297
new_lineno = lines[1]
297
298
elif line.startswith(' '):
298
299
chunk.diff.append(util.Container(old_lineno=old_lineno, new_lineno=new_lineno,
299
type='context', line=fix_line(line[2:])))
300
type='context', line=util.html_clean(line[2:])))
302
303
elif line.startswith('+ '):
303
304
chunk.diff.append(util.Container(old_lineno=None, new_lineno=new_lineno,
304
type='insert', line=fix_line(line[2:])))
305
type='insert', line=util.html_clean(line[2:])))
306
307
elif line.startswith('- '):
307
308
chunk.diff.append(util.Container(old_lineno=old_lineno, new_lineno=None,
308
type='delete', line=fix_line(line[2:])))
309
type='delete', line=util.html_clean(line[2:])))
311
elif line.startswith(' '):
312
# why does this happen?
313
chunk.diff.append(util.Container(old_lineno=old_lineno, new_lineno=new_lineno,
314
type='context', line=util.html_clean(line[1:])))
317
elif line.startswith('+'):
318
# why does this happen?
319
chunk.diff.append(util.Container(old_lineno=None, new_lineno=new_lineno,
320
type='insert', line=util.html_clean(line[1:])))
322
elif line.startswith('-'):
323
# why does this happen?
324
chunk.diff.append(util.Container(old_lineno=old_lineno, new_lineno=None,
325
type='delete', line=util.html_clean(line[1:])))
311
chunk.diff.append(util.Container(type='unknown', line=fix_line(repr(line))))
328
chunk.diff.append(util.Container(old_lineno=None, new_lineno=None,
329
type='unknown', line=util.html_clean(repr(line))))
330
if chunk is not None:
314
334
def handle_modify(old_path, new_path, fid, kind):
336
modified.append(util.Container(filename=rich_filename(new_path, kind)))
315
338
old_lines = tree_lines(old_tree, fid)
316
339
new_lines = tree_lines(new_tree, fid)
317
340
buffer = StringIO()