Port the "diff link" support over to the query.cgi script.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@878 8cb11bc2-c004-0410-86c3-e597b4017df7remotes/tags/1.0.0-rc1
parent
d8cc63ee4e
commit
7ad43eaa74
19
lib/query.py
19
lib/query.py
|
@ -278,6 +278,16 @@ def form_to_cvsdb_query(form_data):
|
|||
|
||||
return query
|
||||
|
||||
def prev_rev(rev):
|
||||
'''Returns a string representing the previous revision of the argument.'''
|
||||
r = string.split(rev, '.')
|
||||
# decrement final revision component
|
||||
r[-1] = str(int(r[-1]) - 1)
|
||||
# prune if we pass the beginning of the branch
|
||||
if len(r) > 2 and r[-1] == '0':
|
||||
r = r[:-2]
|
||||
return string.join(r, '.')
|
||||
|
||||
def build_commit(server, desc, files, cvsroots, viewcvs_link):
|
||||
ob = _item(num_files=len(files), files=[])
|
||||
|
||||
|
@ -313,8 +323,15 @@ def build_commit(server, desc, files, cvsroots, viewcvs_link):
|
|||
flink = '[%s] <a href="%s/%s?root=%s">%s</a>' % (
|
||||
cvsroot_name, viewcvs_link, urllib.quote(file),
|
||||
cvsroot_name, file)
|
||||
if commit.GetType() == commit.CHANGE:
|
||||
dlink = '%s/%s?root=%s&view=diff&r1=%s&r2=%s' % (
|
||||
viewcvs_link, urllib.quote(file), cvsroot_name,
|
||||
prev_rev(commit.GetRevision()), commit.GetRevision())
|
||||
else:
|
||||
dlink = None
|
||||
else:
|
||||
flink = file_full_path
|
||||
dlink = None
|
||||
|
||||
ob.files.append(_item(date=ctime,
|
||||
author=commit.GetAuthor(),
|
||||
|
@ -323,6 +340,8 @@ def build_commit(server, desc, files, cvsroots, viewcvs_link):
|
|||
branch=commit.GetBranch(),
|
||||
plus=int(commit.GetPlusCount()),
|
||||
minus=int(commit.GetMinusCount()),
|
||||
type=commit.GetTypeString(),
|
||||
difflink=dlink,
|
||||
))
|
||||
|
||||
return ob
|
||||
|
|
|
@ -184,7 +184,15 @@
|
|||
<td align=left valign=top>
|
||||
[if-any commits.files.branch][commits.files.branch][else] [end]
|
||||
</td>
|
||||
<td align=left valign=top>[commits.files.plus]/[commits.files.minus]</td>
|
||||
<td align=left valign=top>
|
||||
[is commits.files.type "Add"]<ins>[end]
|
||||
[is commits.files.type "Change"]<a href="[commits.files.difflink]">[end]
|
||||
[is commits.files.type "Remove"]<del>[end]
|
||||
[commits.files.plus]/[commits.files.minus]
|
||||
[is commits.files.type "Add"]</ins>[end]
|
||||
[is commits.files.type "Change"]</a>[end]
|
||||
[is commits.files.type "Remove"]</del>[end]
|
||||
</td>
|
||||
<td align=left valign=top>
|
||||
[if-any commits.files.date][commits.files.date][else] [end]
|
||||
</td>
|
||||
|
|
Loading…
Reference in New Issue