37
36
return urllib.quote(urllib.quote(p, safe=''))
39
39
class RevisionUI(TemplatedBranchView):
41
41
template_path = 'loggerhead.templates.revision'
43
def _parse_diffs(self, old_tree, new_tree, delta, specific_path):
45
Return a list of processed diffs, in the format::
54
type: str('context', 'delete', or 'insert'),
61
fid = new_tree.path2id(specific_path)
62
kind = new_tree.kind(fid)
63
chunks=diff_chunks_for_file(fid, old_tree, new_tree)
64
return [util.Container(
65
filename=rich_filename(specific_path, kind), file_id=fid,
71
for old_path, new_path, fid, \
72
kind, text_modified, meta_modified in delta.renamed:
74
process.append((new_path, fid, kind))
75
for path, fid, kind, text_modified, meta_modified in delta.modified:
76
process.append((path, fid, kind))
77
for path, fid, kind in delta.added:
79
process.append((path, fid, kind))
80
for path, fid, kind in delta.removed:
82
process.append((path, fid, kind))
86
for new_path, fid, kind in process:
87
out.append(util.Container(
88
filename=rich_filename(new_path, kind), file_id=fid,
93
def get_changes_with_diff(self, change, compare_revid, specific_path):
95
if compare_revid is None:
97
compare_revid = change.parents[0].revid
99
compare_revid = 'null:'
101
rev_tree1 = h._branch.repository.revision_tree(compare_revid)
102
rev_tree2 = h._branch.repository.revision_tree(change.revid)
103
delta = rev_tree2.changes_from(rev_tree1)
105
changes = h.parse_delta(delta)
107
return changes, self._parse_diffs(
108
rev_tree1, rev_tree2, delta, specific_path)
110
43
def get_values(self, path, kwargs, headers):
112
45
revid = self.get_revid()
135
68
util.fill_in_navigation(navigation)
137
70
change = h.get_changes([revid])[0]
72
if compare_revid is None:
74
cr = change.parents[0].revid
138
80
if path in ('', '/'):
140
change.changes, diffs = self.get_changes_with_diff(change, compare_revid, path)
83
old_tree = h._branch.repository.revision_tree(cr)
84
new_tree = h._branch.repository.revision_tree(change.revid)
85
file_changes = h.file_changes_from_revision_trees(
143
if compare_revid is None:
145
cr = change.parents[0].revid
91
diff_chunks = diff_chunks_for_file(
92
new_tree.path2id(path), old_tree, new_tree)
150
for i, item in enumerate(diffs):
152
link_data['diff-' + str(i)] = '%s/%s/%s' % (
153
dq(revid), dq(cr), dq(item.file_id))
154
path_to_id[item.filename] = 'diff-' + str(i)
155
# add parent & merge-point branch-nick info, in case it's useful
156
h.get_branch_nicks([change])
95
for i, item in enumerate(file_changes.text_changes):
97
link_data['diff-' + str(i)] = '%s/%s/%s' % (
98
dq(revid), dq(cr), dq(item.file_id))
99
path_to_id[item.filename] = 'diff-' + str(i)
101
h.add_branch_nicks(change)
158
103
# Directory Breadcrumbs
159
104
directory_breadcrumbs = (