"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/blame.py" between
viewvc-1.1.28.tar.gz and viewvc-1.2.1.tar.gz

About: ViewVC is a browser interface for CVS and Subversion version control repositories.

blame.py  (viewvc-1.1.28):blame.py  (viewvc-1.2.1)
skipping to change at line 30 skipping to change at line 30
# This file is based on the cvsblame.pl portion of the Bonsai CVS tool, # This file is based on the cvsblame.pl portion of the Bonsai CVS tool,
# developed by Steve Lamm for Netscape Communications Corporation. More # developed by Steve Lamm for Netscape Communications Corporation. More
# information about Bonsai can be found at # information about Bonsai can be found at
# http://www.mozilla.org/bonsai.html # http://www.mozilla.org/bonsai.html
# #
# cvsblame.pl, in turn, was based on Scott Furman's cvsblame script # cvsblame.pl, in turn, was based on Scott Furman's cvsblame script
# #
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
import sys import sys
import string
import os import os
import re import re
import time import time
import math import math
from common import _item
import vclib import vclib
import sapi import sapi
re_includes = re.compile('\\#(\\s*)include(\\s*)"(.*?)"') re_includes = re.compile('\\#(\\s*)include(\\s*)"(.*?)"')
def link_includes(text, repos, path_parts, include_url): def link_includes(text, repos, path_parts, include_url):
match = re_includes.match(text) match = re_includes.match(text)
if match: if match:
incfile = match.group(3) incfile = match.group(3)
include_path_parts = path_parts[:-1] include_path_parts = path_parts[:-1]
for part in filter(None, string.split(incfile, '/')): for part in filter(None, incfile.split('/')):
if part == "..": if part == "..":
if not include_path_parts: if not include_path_parts:
# nothing left to pop; don't bother marking up this include. # nothing left to pop; don't bother marking up this include.
return text return text
include_path_parts.pop() include_path_parts.pop()
elif part and part != ".": elif part and part != ".":
include_path_parts.append(part) include_path_parts.append(part)
include_path = None include_path = None
try: try:
if repos.itemtype(include_path_parts, None) == vclib.FILE: if repos.itemtype(include_path_parts, None) == vclib.FILE:
include_path = string.join(include_path_parts, '/') include_path = '/'.join(include_path_parts)
except vclib.ItemNotFound: except vclib.ItemNotFound:
pass pass
if include_path: if include_path:
return '#%sinclude%s<a href="%s">"%s"</a>' % \ return '#%sinclude%s<a href="%s">"%s"</a>' % \
(match.group(1), match.group(2), (match.group(1), match.group(2),
string.replace(include_url, '/WHERE/', include_path), incfile) include_url.replace('/WHERE/', include_path), incfile)
return text return text
class HTMLBlameSource: class HTMLBlameSource:
"""Wrapper around a the object by the vclib.annotate() which does """Wrapper around a the object by the vclib.annotate() which does
HTML escaping, diff URL generation, and #include linking.""" HTML escaping, diff URL generation, and #include linking."""
def __init__(self, repos, path_parts, diff_url, include_url, opt_rev=None): def __init__(self, repos, path_parts, diff_url, include_url, opt_rev=None):
self.repos = repos self.repos = repos
self.path_parts = path_parts self.path_parts = path_parts
self.diff_url = diff_url self.diff_url = diff_url
skipping to change at line 94 skipping to change at line 95
thisline = link_includes(sapi.escape(item.text), self.repos, thisline = link_includes(sapi.escape(item.text), self.repos,
self.path_parts, self.include_url) self.path_parts, self.include_url)
return _item(text=thisline, line_number=item.line_number, return _item(text=thisline, line_number=item.line_number,
rev=item.rev, prev_rev=item.prev_rev, rev=item.rev, prev_rev=item.prev_rev,
diff_url=diff_url, date=item.date, author=item.author) diff_url=diff_url, date=item.date, author=item.author)
def blame(repos, path_parts, diff_url, include_url, opt_rev=None): def blame(repos, path_parts, diff_url, include_url, opt_rev=None):
source = HTMLBlameSource(repos, path_parts, diff_url, include_url, opt_rev) source = HTMLBlameSource(repos, path_parts, diff_url, include_url, opt_rev)
return source, source.revision return source, source.revision
class _item:
def __init__(self, **kw):
vars(self).update(kw)
def make_html(root, rcs_path): def make_html(root, rcs_path):
import vclib.ccvs.blame import vclib.ccvs.blame
bs = vclib.ccvs.blame.BlameSource(os.path.join(root, rcs_path)) bs = vclib.ccvs.blame.BlameSource(os.path.join(root, rcs_path))
line = 0 line = 0
old_revision = 0 old_revision = 0
row_color = 'ffffff' row_color = 'ffffff'
rev_count = 0 rev_count = 0
align = ' style="text-align: %s;"' align = ' style="text-align: %s;"'
skipping to change at line 135 skipping to change at line 132
if old_revision != revision or rev_count > 20: if old_revision != revision or rev_count > 20:
sys.stdout.write('<td%s>%s</td>' % (align % 'right', author or '&nbsp;')) sys.stdout.write('<td%s>%s</td>' % (align % 'right', author or '&nbsp;'))
sys.stdout.write('<td%s>%s</td>' % (align % 'left', revision)) sys.stdout.write('<td%s>%s</td>' % (align % 'left', revision))
old_revision = revision old_revision = revision
rev_count = 0 rev_count = 0
else: else:
sys.stdout.write('<td>&nbsp;</td><td>&nbsp;</td>') sys.stdout.write('<td>&nbsp;</td><td>&nbsp;</td>')
rev_count = rev_count + 1 rev_count = rev_count + 1
sys.stdout.write('<td%s>%s</td></tr>\n' % (align % 'left', string.rstrip(thi sline) or '&nbsp;')) sys.stdout.write('<td%s>%s</td></tr>\n' % (align % 'left', thisline.rstrip() or '&nbsp;'))
sys.stdout.write('</table>\n') sys.stdout.write('</table>\n')
def main(): def main():
import sys import sys
if len(sys.argv) != 3: if len(sys.argv) != 3:
print 'USAGE: %s cvsroot rcs-file' % sys.argv[0] print 'USAGE: %s cvsroot rcs-file' % sys.argv[0]
sys.exit(1) sys.exit(1)
make_html(sys.argv[1], sys.argv[2]) make_html(sys.argv[1], sys.argv[2])
if __name__ == '__main__': if __name__ == '__main__':
 End of changes. 7 change blocks. 
9 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)