More work on the cool new revision view.
* viewcvs/lib/vclib/svn/__init__.py (LogEntry.__init__): Remove 'other_paths' parameter and support. (ChangedPathEntry): Remove. (ChangedPath, get_revision_info): New. (log_helper): Don't do changed-path or action stuffs. Update call to LogEntry(). (get_logs): Update call to LogEntry(). * viewcvs/lib/viewcvs.py (view_log_svn): Remove support for 'other_paths' support. (view_revision): Move svn-specific stuff to new view_revision_svn() (view_revision_svn): New. * viewcvs/templates/revision.ezt Make this template actually do something useful. * viewcvs/templates/log.ezt * viewcvs/templates/log_table.ezt Remove display of "other_paths" from Subversion logs. Make revision numbers into links to the revision view. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@740 8cb11bc2-c004-0410-86c3-e597b4017df7remotes/tags/1.0.0-rc1
parent
1e0d4e3cff
commit
9d5d4170f9
|
@ -23,7 +23,7 @@ import os.path
|
|||
import string
|
||||
|
||||
# Subversion swig libs
|
||||
from svn import fs, repos, core
|
||||
from svn import fs, repos, core, delta
|
||||
|
||||
# Subversion filesystem paths are '/'-delimited, regardless of OS.
|
||||
def fs_path_join(base, relative):
|
||||
|
@ -54,12 +54,11 @@ def date_from_rev(svnrepos, rev):
|
|||
datestr = fs.revision_prop(svnrepos.fs_ptr, rev,
|
||||
core.SVN_PROP_REVISION_DATE, svnrepos.pool)
|
||||
return _datestr_to_date(datestr, svnrepos.pool)
|
||||
|
||||
|
||||
|
||||
class LogEntry:
|
||||
"Hold state for each revision's log entry."
|
||||
def __init__(self, rev, date, author, msg, filename, other_paths,
|
||||
copy_path, copy_rev):
|
||||
def __init__(self, rev, date, author, msg, filename, copy_path, copy_rev):
|
||||
self.rev = rev
|
||||
self.date = date
|
||||
self.author = author
|
||||
|
@ -67,16 +66,10 @@ class LogEntry:
|
|||
self.changed = 0
|
||||
self.log = msg
|
||||
self.filename = filename
|
||||
self.other_paths = other_paths
|
||||
self.copy_path = copy_path
|
||||
self.copy_rev = copy_rev
|
||||
|
||||
class ChangedPathEntry:
|
||||
def __init__(self, filename, action):
|
||||
self.filename = filename
|
||||
self.action = action
|
||||
|
||||
|
||||
class NodeHistory:
|
||||
def __init__(self):
|
||||
self.histories = {}
|
||||
|
@ -111,33 +104,65 @@ def _unparse_action(change_kind):
|
|||
return None
|
||||
|
||||
|
||||
class ChangedPath:
|
||||
def __init__(self, filename, pathtype, prop_mods, text_mods,
|
||||
base_path, base_rev, action):
|
||||
self.filename = filename
|
||||
self.pathtype = pathtype
|
||||
self.prop_mods = prop_mods
|
||||
self.text_mods = text_mods
|
||||
self.base_path = base_path
|
||||
self.base_rev = base_rev
|
||||
self.action = action
|
||||
|
||||
|
||||
def get_revision_info(svnrepos):
|
||||
# Get the revision property info
|
||||
date, author, msg = _fs_rev_props(svnrepos.fs_ptr, svnrepos.rev,
|
||||
svnrepos.pool)
|
||||
date = _datestr_to_date(date, svnrepos.pool)
|
||||
|
||||
# Now, get the changes for the revision
|
||||
editor = repos.RevisionChangeCollector(svnrepos.fs_ptr, svnrepos.rev)
|
||||
e_ptr, e_baton = delta.make_editor(editor, svnrepos.pool)
|
||||
repos.svn_repos_replay(svnrepos.fsroot, e_ptr, e_baton, svnrepos.pool)
|
||||
|
||||
# get all the changes and sort by path
|
||||
changelist = editor.changes.items()
|
||||
changelist.sort()
|
||||
changes = []
|
||||
for path, change in changelist:
|
||||
if not change.path:
|
||||
action = 'deleted'
|
||||
elif change.added:
|
||||
if change.base_path and change.base_rev:
|
||||
action = 'copied'
|
||||
else:
|
||||
action = 'added'
|
||||
else:
|
||||
action = 'modified'
|
||||
if change.item_kind == core.svn_node_dir:
|
||||
pathtype = vclib.DIR
|
||||
elif change.item_kind == core.svn_node_file:
|
||||
pathtype = vclib.FILE
|
||||
else:
|
||||
pathtype = None
|
||||
changes.append(ChangedPath(path, pathtype, change.prop_changes,
|
||||
change.text_changed, change.base_path,
|
||||
change.base_rev, action))
|
||||
return date, author, msg, changes
|
||||
|
||||
|
||||
def log_helper(svnrepos, rev, path, pool):
|
||||
rev_root = fs.revision_root(svnrepos.fs_ptr, rev, pool)
|
||||
other_paths = []
|
||||
changed_paths = fs.paths_changed(rev_root, pool)
|
||||
|
||||
copyfrom_rev = copyfrom_path = None
|
||||
# Was this path@rev the target of a copy?
|
||||
copyfrom_rev, copyfrom_path = fs.copied_from(rev_root, path, pool)
|
||||
|
||||
# Optionally skip revisions in which this path didn't change.
|
||||
change = changed_paths.get(path)
|
||||
if change:
|
||||
|
||||
# Was this thing the target of a copy?
|
||||
if (change.change_kind == fs.path_change_add) or \
|
||||
(change.change_kind == fs.path_change_replace):
|
||||
copyfrom_rev, copyfrom_path = fs.copied_from(rev_root, path, pool)
|
||||
|
||||
# Now, make ChangedPathEntry objects for all the other paths
|
||||
for other_path in changed_paths.keys():
|
||||
if other_path != path:
|
||||
change = changed_paths.get(other_path)
|
||||
other_paths.append(ChangedPathEntry(_trim_path(other_path),
|
||||
_unparse_action(change.change_kind)))
|
||||
|
||||
# Finally, assemble our LogEntry.
|
||||
# Assemble our LogEntry
|
||||
datestr, author, msg = _fs_rev_props(svnrepos.fs_ptr, rev, pool)
|
||||
date = _datestr_to_date(datestr, pool)
|
||||
entry = LogEntry(rev, date, author, msg, _trim_path(path), other_paths,
|
||||
entry = LogEntry(rev, date, author, msg, _trim_path(path),
|
||||
copyfrom_path and _trim_path(copyfrom_path),
|
||||
copyfrom_rev)
|
||||
if fs.is_file(rev_root, path, pool):
|
||||
|
@ -195,7 +220,7 @@ def get_logs(svnrepos, full_name, files):
|
|||
rev = get_last_history_rev(svnrepos, path, subpool)
|
||||
datestr, author, msg = _fs_rev_props(svnrepos.fs_ptr, rev, subpool)
|
||||
date = _datestr_to_date(datestr, subpool)
|
||||
new_entry = LogEntry(rev, date, author, msg, file, [], None, None)
|
||||
new_entry = LogEntry(rev, date, author, msg, file, None, None)
|
||||
if fs.is_file(svnrepos.fsroot, path, subpool):
|
||||
new_entry.size = fs.file_length(svnrepos.fsroot, path, subpool)
|
||||
fileinfo[file] = new_entry
|
||||
|
|
|
@ -1872,10 +1872,6 @@ def view_log_svn(request, data, logsort):
|
|||
where=entry.copy_path,
|
||||
pathtype=vclib.FILE, params={})
|
||||
|
||||
for path in entry.other_paths:
|
||||
path.href = request.get_url(view_func=view_log, where=path.filename,
|
||||
pathtype=vclib.FILE, params={})
|
||||
|
||||
entry.tags = [ ]
|
||||
entry.branches = [ ]
|
||||
entry.branch_point = None
|
||||
|
@ -2763,6 +2759,60 @@ def download_tarball(request):
|
|||
|
||||
def view_revision(request):
|
||||
data = common_template_data(request)
|
||||
data.update({
|
||||
'roottype' : request.roottype,
|
||||
})
|
||||
|
||||
if request.roottype == "cvs":
|
||||
raise ViewcvsException("Revision view not supported for CVS repositories "
|
||||
"at this time.", "400 Bad Request")
|
||||
else:
|
||||
view_revision_svn(request, data)
|
||||
|
||||
def view_revision_svn(request, data):
|
||||
query_dict = request.query_dict
|
||||
date, author, msg, changes = vclib.svn.get_revision_info(request.repos)
|
||||
date_str = make_time_string(date)
|
||||
rev_str = str(request.repos.rev)
|
||||
|
||||
# add the hrefs, types, and prev info
|
||||
for change in changes:
|
||||
if change.pathtype is vclib.FILE:
|
||||
change.type = 'file'
|
||||
change.view_href = request.get_url(view_func=view_markup,
|
||||
where=change.filename,
|
||||
pathtype=change.pathtype,
|
||||
params={'rev' : rev_str})
|
||||
change.diff_href = request.get_url(view_func=view_diff,
|
||||
where=change.filename,
|
||||
pathtype=change.pathtype,
|
||||
params={})
|
||||
elif change.pathtype is vclib.DIR:
|
||||
change.type = 'dir'
|
||||
change.view_href = request.get_url(view_func=view_directory,
|
||||
where=change.filename,
|
||||
pathtype=change.pathtype,
|
||||
params={'rev' : rev_str})
|
||||
change.diff_href = None
|
||||
else:
|
||||
change.view_href = change.diff_href = change.type = None
|
||||
|
||||
if (change.action == "added" and change.base_rev and change.base_path) \
|
||||
or (change.action == "modified"):
|
||||
change.prev_path = change.base_path
|
||||
change.prev_rev = change.base_rev
|
||||
else:
|
||||
change.prev_path = change.prev_rev = None
|
||||
|
||||
data.update({
|
||||
'rev' : rev_str,
|
||||
'author' : author,
|
||||
'date_str' : date_str,
|
||||
'log' : htmlify(msg),
|
||||
'ago' : html_time(request, date, 1),
|
||||
'changes' : changes,
|
||||
})
|
||||
|
||||
request.server.header()
|
||||
generate_page(request, cfg.templates.revision, data)
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
[for entries.branch_names]<a name="[entries.branch_names]"></a>
|
||||
[end]
|
||||
|
||||
Revision <b>[entries.rev]</b> -
|
||||
Revision [is roottype "svn"]<a href="[entries.revision_href]"><b>[entries.rev]</b></a>[else]<b>[entries.rev]</b>[end] -
|
||||
[if-any is_text]
|
||||
<a href="[entries.href]"
|
||||
[if-any is_text]
|
||||
|
@ -135,9 +135,6 @@
|
|||
[if-any entries.copy_path]
|
||||
<br>Copied from: <a href="[entries.copy_href]#rev[entries.copy_rev]">[entries.copy_path]</a> revision [entries.copy_rev]
|
||||
[end]
|
||||
|
||||
[for entries.other_paths][if-index entries.other_paths first]<br>Other changed files:[else],[end]
|
||||
[is entries.other_paths.action "deleted"][entries.other_paths.filename][else]<a href="[entries.other_paths.href]#rev[entries.rev]">[entries.other_paths.filename]</a>[end] ([entries.other_paths.action])[end]
|
||||
[end]
|
||||
|
||||
[is entries.state "dead"]
|
||||
|
|
|
@ -49,7 +49,7 @@ href="[docroot]/help_logtable.html">ViewCVS and CVS Help</a></b></h3></td>
|
|||
|
||||
[# Revision column]
|
||||
<td rowspan=2>
|
||||
<b>[entries.rev]</b>
|
||||
[is roottype "svn"]<a href="[entries.revision_href]"><b>[entries.rev]</b></a>[else]<b>[entries.rev]</b>[end]
|
||||
<a name="rev[entries.rev]"></a>
|
||||
</td>
|
||||
|
||||
|
@ -187,12 +187,6 @@ href="[docroot]/help_logtable.html">ViewCVS and CVS Help</a></b></h3></td>
|
|||
[if-any entries.copy_path]
|
||||
<b>Copied from: </b><a href="[entries.copy_href]#rev[entries.copy_rev]">[entries.copy_path]</a> revision [entries.copy_rev]<br>
|
||||
[end]
|
||||
|
||||
[if-any entries.other_paths]
|
||||
[for entries.other_paths][if-index entries.other_paths first]<b>Other changed files:</b>[else],[end]
|
||||
[is entries.other_paths.action "deleted"][entries.other_paths.filename][else]<a href="[entries.other_paths.href]#rev[entries.rev]">[entries.other_paths.filename]</a>[end] ([entries.other_paths.action])[end]
|
||||
<br>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
<b>Log: </b><i><pre>[entries.html_log]</pre></i>
|
||||
|
|
|
@ -4,12 +4,68 @@
|
|||
<!-- ViewCVS -- http://viewcvs.sourceforge.net/
|
||||
by Greg Stein -- mailto:gstein@lyra.org
|
||||
-->
|
||||
<title>ViewCVS Exception</title>
|
||||
<title>Subversion revision - [rev]</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#ffffff">
|
||||
|
||||
<h1>What up, dawg?</h1>
|
||||
<h2>Revision information will soon be here.</h2>
|
||||
<h1>Subversion revision information</h1>
|
||||
<h2>Revision [rev]</h2>
|
||||
|
||||
<p>
|
||||
<b>Author:</b> [author]<br>
|
||||
<b>Date:</b> [date_str] <i>([ago] ago)</i>
|
||||
</p>
|
||||
<p><pre>[log]</pre></p>
|
||||
|
||||
<hr noshade>
|
||||
|
||||
<p><b>Changed paths:</b></p>
|
||||
<table border=0 cellspacing=1 cellpadding=2>
|
||||
<tr align=left>
|
||||
<th align=left bgcolor="#88ff88">Path</th>
|
||||
<th align=left bgcolor="#cccccc">Action</th>
|
||||
<th align=left bgcolor="#cccccc">Text Changes</th>
|
||||
<th align=left bgcolor="#cccccc">Prop Changes</th>
|
||||
<th align=left bgcolor="#cccccc">Diff to Previous</th>
|
||||
</tr>
|
||||
[if-any changes]
|
||||
[for changes]
|
||||
<tr bgcolor="[if-index changes even]#ffffff[else]#ccccee[end]">
|
||||
<td>
|
||||
[is changes.pathtype "dir"]
|
||||
<img src="[icons]/small/dir.gif">
|
||||
[else]
|
||||
<img src="[icons]/small/text.gif">
|
||||
[end]
|
||||
[is changes.action "deleted"]
|
||||
[changes.filename]
|
||||
[else]
|
||||
<a href="[changes.view_href]">[changes.filename]</a>
|
||||
[end]
|
||||
</td>
|
||||
<td align=center>[changes.action]</td>
|
||||
[is changes.action "deleted"]
|
||||
<td align=center> </td>
|
||||
<td align=center> </td>
|
||||
[else]
|
||||
<td align=center>[is changes.text_mods "1"]X[else] [end]</td>
|
||||
<td align=center>[is changes.prop_mods "1"]X[else] [end]</td>
|
||||
[end]
|
||||
[if-any changes.diff_href]
|
||||
[if-any changes.prev_rev]
|
||||
<td align=center><a href="[changes.diff_href]&r1=[rev]&r2=[changes.prev_rev]&p1=[changes.filename]&p2=[changes.prev_path]">(diff to previous)</a></td>
|
||||
[else]
|
||||
<td align=center> </td>
|
||||
[end]
|
||||
[end]
|
||||
</tr>
|
||||
[end]
|
||||
[else]
|
||||
<tr>
|
||||
<td colspan="5">No changed paths.</td>
|
||||
</tr>
|
||||
[end]
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue