"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/vclib/ccvs/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 29 skipping to change at line 29
# #
# 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 string
import re import re
import time import time
import math import math
import rcsparse import rcsparse
import vclib import vclib
class CVSParser(rcsparse.Sink): class CVSParser(rcsparse.Sink):
# Precompiled regular expressions # Precompiled regular expressions
trunk_rev = re.compile('^[0-9]+\\.[0-9]+$') trunk_rev = re.compile('^[0-9]+\\.[0-9]+$')
last_branch = re.compile('(.*)\\.[0-9]+') last_branch = re.compile('(.*)\\.[0-9]+')
skipping to change at line 103 skipping to change at line 102
ancestors = [] ancestors = []
revision = self.prev_revision.get(revision) revision = self.prev_revision.get(revision)
while revision: while revision:
ancestors.append(revision) ancestors.append(revision)
revision = self.prev_revision.get(revision) revision = self.prev_revision.get(revision)
return ancestors return ancestors
# Split deltatext specified by rev to each line. # Split deltatext specified by rev to each line.
def deltatext_split(self, rev): def deltatext_split(self, rev):
lines = string.split(self.revision_deltatext[rev], '\n') lines = self.revision_deltatext[rev].split('\n')
if lines[-1] == '': if lines[-1] == '':
del lines[-1] del lines[-1]
return lines return lines
# Extract the given revision from the digested RCS file. # Extract the given revision from the digested RCS file.
# (Essentially the equivalent of cvs up -rXXX) # (Essentially the equivalent of cvs up -rXXX)
def extract_revision(self, revision): def extract_revision(self, revision):
path = [] path = []
add_lines_remaining = 0 add_lines_remaining = 0
start_line = 0 start_line = 0
skipping to change at line 142 skipping to change at line 141
for command in diffs: for command in diffs:
dmatch = self.d_command.match(command) dmatch = self.d_command.match(command)
amatch = self.a_command.match(command) amatch = self.a_command.match(command)
if add_lines_remaining > 0: if add_lines_remaining > 0:
# Insertion lines from a prior "a" command # Insertion lines from a prior "a" command
text.insert(start_line + adjust, command) text.insert(start_line + adjust, command)
add_lines_remaining = add_lines_remaining - 1 add_lines_remaining = add_lines_remaining - 1
adjust = adjust + 1 adjust = adjust + 1
elif dmatch: elif dmatch:
# "d" - Delete command # "d" - Delete command
start_line = string.atoi(dmatch.group(1)) start_line = int(dmatch.group(1))
count = string.atoi(dmatch.group(2)) count = int(dmatch.group(2))
begin = start_line + adjust - 1 begin = start_line + adjust - 1
del text[begin:begin + count] del text[begin:begin + count]
adjust = adjust - count adjust = adjust - count
lines_removed_now = lines_removed_now + count lines_removed_now = lines_removed_now + count
elif amatch: elif amatch:
# "a" - Add command # "a" - Add command
start_line = string.atoi(amatch.group(1)) start_line = int(amatch.group(1))
count = string.atoi(amatch.group(2)) count = int(amatch.group(2))
add_lines_remaining = count add_lines_remaining = count
lines_added_now = lines_added_now + count lines_added_now = lines_added_now + count
else: else:
raise RuntimeError, 'Error parsing diff commands' raise RuntimeError, 'Error parsing diff commands'
self.lines_added[revision] = self.lines_added[revision] + lines_added_ now self.lines_added[revision] = self.lines_added[revision] + lines_added_ now
self.lines_removed[revision] = self.lines_removed[revision] + lines_remove d_now self.lines_removed[revision] = self.lines_removed[revision] + lines_remove d_now
return text return text
def set_head_revision(self, revision): def set_head_revision(self, revision):
skipping to change at line 314 skipping to change at line 313
while rev: while rev:
diffs = self.deltatext_split(rev) diffs = self.deltatext_split(rev)
for command in diffs: for command in diffs:
dmatch = self.d_command.match(command) dmatch = self.d_command.match(command)
amatch = self.a_command.match(command) amatch = self.a_command.match(command)
if skip > 0: if skip > 0:
# Skip insertion lines from a prior "a" command # Skip insertion lines from a prior "a" command
skip = skip - 1 skip = skip - 1
elif dmatch: elif dmatch:
# "d" - Delete command # "d" - Delete command
start_line = string.atoi(dmatch.group(1)) start_line = int(dmatch.group(1))
count = string.atoi(dmatch.group(2)) count = int(dmatch.group(2))
line_count = line_count - count line_count = line_count - count
elif amatch: elif amatch:
# "a" - Add command # "a" - Add command
start_line = string.atoi(amatch.group(1)) start_line = int(amatch.group(1))
count = string.atoi(amatch.group(2)) count = int(amatch.group(2))
skip = count skip = count
line_count = line_count + count line_count = line_count + count
else: else:
raise RuntimeError, 'error: illegal RCS file' raise RuntimeError, 'error: illegal RCS file'
rev = self.prev_revision.get(rev) rev = self.prev_revision.get(rev)
# Now, play the delta edit commands *backwards* from the primordial # Now, play the delta edit commands *backwards* from the primordial
# revision forward, but rather than applying the deltas to the text of # revision forward, but rather than applying the deltas to the text of
# each revision, apply the changes to an array of revision numbers. # each revision, apply the changes to an array of revision numbers.
skipping to change at line 362 skipping to change at line 361
# Revisions on the trunk specify deltas that transform a # Revisions on the trunk specify deltas that transform a
# revision into an earlier revision, so invert the translation # revision into an earlier revision, so invert the translation
# of the 'diff' commands. # of the 'diff' commands.
for command in diffs: for command in diffs:
if skip > 0: if skip > 0:
skip = skip - 1 skip = skip - 1
else: else:
dmatch = self.d_command.match(command) dmatch = self.d_command.match(command)
amatch = self.a_command.match(command) amatch = self.a_command.match(command)
if dmatch: if dmatch:
start_line = string.atoi(dmatch.group(1)) start_line = int(dmatch.group(1))
count = string.atoi(dmatch.group(2)) count = int(dmatch.group(2))
temp = [] temp = []
while count > 0: while count > 0:
temp.append(revision) temp.append(revision)
count = count - 1 count = count - 1
self.revision_map = (self.revision_map[:start_line - 1] + self.revision_map = (self.revision_map[:start_line - 1] +
temp + self.revision_map[start_line - 1:]) temp + self.revision_map[start_line - 1:])
elif amatch: elif amatch:
start_line = string.atoi(amatch.group(1)) start_line = int(amatch.group(1))
count = string.atoi(amatch.group(2)) count = int(amatch.group(2))
del self.revision_map[start_line:start_line + count] del self.revision_map[start_line:start_line + count]
skip = count skip = count
else: else:
raise RuntimeError, 'Error parsing diff commands' raise RuntimeError, 'Error parsing diff commands'
else: else:
# Revisions on a branch are arranged backwards from those on # Revisions on a branch are arranged backwards from those on
# the trunk. They specify deltas that transform a revision # the trunk. They specify deltas that transform a revision
# into a later revision. # into a later revision.
adjust = 0 adjust = 0
diffs = self.deltatext_split(revision) diffs = self.deltatext_split(revision)
for command in diffs: for command in diffs:
if skip > 0: if skip > 0:
skip = skip - 1 skip = skip - 1
else: else:
dmatch = self.d_command.match(command) dmatch = self.d_command.match(command)
amatch = self.a_command.match(command) amatch = self.a_command.match(command)
if dmatch: if dmatch:
start_line = string.atoi(dmatch.group(1)) start_line = int(dmatch.group(1))
count = string.atoi(dmatch.group(2)) count = int(dmatch.group(2))
adj_begin = start_line + adjust - 1 adj_begin = start_line + adjust - 1
adj_end = start_line + adjust - 1 + count adj_end = start_line + adjust - 1 + count
del self.revision_map[adj_begin:adj_end] del self.revision_map[adj_begin:adj_end]
adjust = adjust - count adjust = adjust - count
elif amatch: elif amatch:
start_line = string.atoi(amatch.group(1)) start_line = int(amatch.group(1))
count = string.atoi(amatch.group(2)) count = int(amatch.group(2))
skip = count skip = count
temp = [] temp = []
while count > 0: while count > 0:
temp.append(revision) temp.append(revision)
count = count - 1 count = count - 1
self.revision_map = (self.revision_map[:start_line + adjust] + self.revision_map = (self.revision_map[:start_line + adjust] +
temp + self.revision_map[start_line + adjust:]) temp + self.revision_map[start_line + adjust:])
adjust = adjust + skip adjust = adjust + skip
else: else:
raise RuntimeError, 'Error parsing diff commands' raise RuntimeError, 'Error parsing diff commands'
 End of changes. 10 change blocks. 
18 lines changed or deleted 17 lines changed or added

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