Robustness fixes where empty or missing revision metadata occurs.

* lib/vclib/svn/__init__.py
  (_datestr_to_date): Make this function more robust in the face of
    bogus datestamps.

* lib/viewvc.py
  (htmlify, format_log, make_time_string, make_rss_time_string,
    build_commit, view_directory): Make this functions more gracefully
    handle "None" revision metadata, and not generate data like
    "Unknown date" or " ".
  
* templates/log.ezt,
* templates/markup.ezt,
* templates/rss.ezt,
* templates/revision.ezt,
* templates/log_table.ezt
  Handle empty revision metadata more gracefully.  


git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1533 8cb11bc2-c004-0410-86c3-e597b4017df7
remotes/options-overhaul
cmpilato 2007-02-26 19:28:48 +00:00
parent e4527a3732
commit 891dfa4b85
7 changed files with 24 additions and 14 deletions

View File

@ -102,7 +102,10 @@ def _rootpath2url(rootpath, path):
def _datestr_to_date(datestr):
return datestr and core.svn_time_from_cstring(datestr) / 1000000 or None
try:
return core.svn_time_from_cstring(datestr) / 1000000
except:
return None
def _fs_rev_props(fsptr, rev):

View File

@ -968,12 +968,16 @@ def get_file_view_info(request, where, rev=None, mime_type=None, pathrev=-1):
_re_rewrite_url = re.compile('((http|https|ftp|file|svn|svn\+ssh)(://[-a-zA-Z0-9%.~:_/]+)((\?|\&)([-a-zA-Z0-9%.~:_]+)=([-a-zA-Z0-9%.~:_])+)*(#([-a-zA-Z0-9%.~:_]+)?)?)')
_re_rewrite_email = re.compile('([-a-zA-Z0-9_.\+]+)@(([-a-zA-Z0-9]+\.)+[A-Za-z]{2,4})')
def htmlify(html):
if not html:
return html
html = cgi.escape(html)
html = re.sub(_re_rewrite_url, r'<a href="\1">\1</a>', html)
html = re.sub(_re_rewrite_email, r'<a href="mailto:\1&#64;\2">\1&#64;\2</a>', html)
return html
def format_log(log, cfg):
if not log:
return log
s = htmlify(log[:cfg.options.short_log_len])
if len(log) > cfg.options.short_log_len:
s = s + '...'
@ -1359,7 +1363,7 @@ def make_time_string(date, cfg):
"""
if date is None:
return 'Unknown date'
return None
if cfg.options.use_localtime:
localtime = time.localtime(date)
return time.asctime(localtime) + ' ' + time.tzname[localtime[8]]
@ -1373,7 +1377,7 @@ def make_rss_time_string(date, cfg):
"""
if date is None:
return 'Unknown date'
return None
return time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime(date)) + ' UTC'
def view_markup(request):
@ -1623,7 +1627,7 @@ def view_directory(request):
if file.date is not None:
row.date = make_time_string(file.date, cfg)
row.ago = html_time(request, file.date)
if cfg.options.show_logs and file.log is not None:
if cfg.options.show_logs:
row.short_log = format_log(file.log, cfg)
row.log = htmlify(file.log)
@ -3315,8 +3319,6 @@ def build_commit(request, files, limited_files, dir_strip):
commit_time = f.GetTime()
if commit_time:
commit_time = make_time_string(commit_time, request.cfg)
else:
commit_time = '&nbsp;'
dirname = f.GetDirectory()
filename = f.GetFile()
@ -3516,7 +3518,8 @@ def view_query(request):
dir_strip = _path_join(repos_dir)
for commit in query.commit_list:
# base modification time on the newest commit ...
if commit.GetTime() > mod_time: mod_time = commit.GetTime()
if commit.GetTime() > mod_time:
mod_time = commit.GetTime()
# form plus/minus totals
plus_count = plus_count + int(commit.GetPlusCount())
minus_count = minus_count + int(commit.GetMinusCount())

View File

@ -48,7 +48,9 @@
[if-index entries last]Added[else]Modified[end]
[end]
<em>[entries.date]</em> ([entries.ago] ago) by <em>[entries.author]</em>
<em>[if-any entries.date][entries.date][else](unknown date)[end]</em>
[if-any entries.ago]([entries.ago] ago)[end]
by <em>[if-any entries.author][entries.author][else](unknown author)[end]</em>
[if-any entries.orig_path]
<br />Original Path: <a href="[entries.orig_href]"><em>[entries.orig_path]</em></a>

View File

@ -126,7 +126,8 @@
[is roottype "svn"]
[if-index entries last]Added[else]Modified[end]
[end]
[entries.ago] ago<br /><em>[entries.date]</em>
[if-any entries.ago][entries.ago] ago<br />[end]
[if-any entries.date]<em>[entries.date]</em>[end]
[is roottype "cvs"]
[if-any entries.prev]
[if-any entries.changed]

View File

@ -13,9 +13,9 @@ Revision [if-any revision_href]<a href="[revision_href]"><strong>[rev]</strong><
[if-any annotate_href](<a href="[annotate_href]"><strong>annotate</strong></a>)[end]
[if-any vendor_branch] <em>(vendor branch)</em>[end]
<br />[if-any date]<em>[date]</em>[end]
<br /><em>[if-any date][date][else](unknown date)[end]</em>
[if-any ago]([ago] ago)[end]
[if-any author]by <em>[author]</em>[end]
by <em>[if-any author][author][else](unknown author)[end]</em>
[if-any orig_path]
<br />Original Path: <a href="[orig_href]"><em>[orig_path]</em></a>
[end]

View File

@ -21,11 +21,12 @@
</tr>
<tr align="left">
<th>Author:</th>
<td>[author]</td>
<td>[if-any author][author][else]<em>(unknown author)</em>[end]</td>
</tr>
<tr align="left">
<th>Date:</th>
<td>[date] <em>([ago] ago)</em></td>
<td>[if-any date][date][else]<em>(unknown date)</em>[end]
[if-any ago]<em>([ago] ago)</em>[end]</td>
</tr>
<tr align="left">
<th>Log Message:</th>

View File

@ -9,7 +9,7 @@
<title>[if-any commits.rev][commits.rev]: [end][[commits.author]] [commits.short_log]</title>
[if-any commits.rss_url]<link>[commits.rss_url]</link>[end]
<author>[commits.author]</author>
<pubDate>[commits.rss_date]</pubDate>
<pubDate>[if-any commits.rss_date][commits.rss_date][else](unknown date)[end]</pubDate>
<description>[commits.log]</description>
</item>[end]
</channel>