[Codestriker-commits] CVS update: codestriker codestriker.conf
Brought to you by:
sits
|
From: <si...@us...> - 2008-09-06 00:31:54
|
User: sits
Date: 08/09/05 17:31:51
Modified: lib/Codestriker/FileParser PerforceDiff.pm PatchUnidiff.pm
ClearCaseSerialDiff.pm SubversionDiff.pm Parser.pm
BasicDiffUtils.pm PerforceDescribe.pm
UnidiffUtils.pm UnknownFormat.pm CvsUnidiff.pm
PatchBasicDiff.pm VssDiff.pm
lib/Codestriker/Http/Method AddProjectMethod.pm
SearchTopicsMethod.pm ViewTopicCommentsMethod.pm
DownloadTopicTextMethod.pm AddTopicMethod.pm
UpdateTopicMetricsMethod.pm
ViewTopicMetricsMethod.pm
UpdateTopicPropertiesMethod.pm
ViewTopicFileMethod.pm ViewTopicTextMethod.pm
UpdateCommentMetricsMethod.pm
SubmitSearchTopicsMethod.pm
DownloadMetricsMethod.pm ViewMetricsMethod.pm
ViewTopicPropertiesMethod.pm ListProjectsMethod.pm
EditProjectMethod.pm CreateCommentMethod.pm
ListTopicsMethod.pm StaticResourcesMethod.pm
CreateTopicMethod.pm UpdateTopicStateMethod.pm
AddCommentMethod.pm CreateProjectMethod.pm
UpdateProjectMethod.pm
lib/Codestriker/Action MetricsReport.pm ViewTopicComments.pm
SubmitNewComment.pm ListTopicsRSS.pm
SubmitSearch.pm CreateProject.pm
SubmitEditCommentsState.pm
SubmitEditTopicMetrics.pm ListTopics.pm
EditProject.pm ViewTopicInfo.pm ViewTopic.pm
CreateTopic.pm ListProjects.pm
SubmitEditTopicsState.pm
SubmitEditTopicProperties.pm DownloadTopic.pm
SubmitEditProject.pm ViewTopicFile.pm
SubmitNewTopic.pm ViewTopicProperties.pm Search.pm
EditComment.pm SubmitNewProject.pm
lib/Codestriker/Http NonHighlightedLxrLineFilter.pm
UrlBuilder.pm LineFilter.pm Response.pm Cookie.pm
Template.pm LxrLineFilter.pm Dispatcher.pm
TabToNbspLineFilter.pm HighlightLineFilter.pm
Input.pm HtmlEntityLineFilter.pm DeltaRenderer.pm
HighlightedLxrLineFilter.pm Method.pm
lib/Codestriker/Repository RepositoryFactory.pm CvsWeb.pm
ScmBug.pm ClearCaseSnapshot.pm Perforce.pm
Subversion.pm ViewCvs.pm ClearCaseDynamic.pm Cvs.pm
Vss.pm
lib/Codestriker/DB SQLite.pm PostgreSQL.pm Column.pm DBI.pm
MySQL.pm ODBC.pm Oracle.pm Database.pm Table.pm
lib/Codestriker/Model Delta.pm MetricStats.pm Metrics.pm
File.pm Topic.pm Project.pm Comment.pm
lib Codestriker.pm
lib/Codestriker/BugDB FlysprayConnection.pm
BugzillaConnection.pm BugDBConnectionFactory.pm
TestDirectorConnection.pm
bin codestriker.pl.base install.pl
lib/Codestriker/TopicListeners HistoryRecorder.pm Manager.pm
Email.pm BugTracking.pm TopicListener.pm
. codestriker.conf
Log:
Whitespace changes primarily - reverting bck to emacs's cperl-mode, and replaced all tabs with spaces.
Index: PerforceDiff.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/FileParser/PerforceDiff.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PerforceDiff.pm 22 May 2005 22:26:04 -0000 1.2
+++ PerforceDiff.pm 6 Sep 2008 00:31:44 -0000 1.3
@@ -29,7 +29,7 @@
# Skip initial whitespace.
my $line = <$fh>;
while (defined($line) && $line =~ /^\s*$/) {
- $line = <$fh>;
+ $line = <$fh>;
}
# Array of results found.
@@ -41,67 +41,65 @@
# Now read the actual diff chunks.
while (defined($line)) {
- if ($line =~ /^==== (.*)\#(\d+) \- .* ==== \((.*)\)$/) {
- my $filename = $1;
- my $revision = $2;
- my $file_type = $3;
-
- if ($file_type eq "ubinary" || $file_type eq "xbinary" ||
- $file_type eq "binary") {
- # Binary file, skip the next line and add the record in.
- $line = <$fh>;
- my $chunk = {};
- $chunk->{filename} = $filename;
- $chunk->{revision} = $revision;
- $chunk->{old_linenumber} = -1;
- $chunk->{new_linenumber} = -1;
- $chunk->{binary} = 1;
- $chunk->{text} = "";
- $chunk->{description} = "";
- $chunk->{repmatch} = $repmatch;
- push @result, $chunk;
- }
- elsif ($file_type eq "text") {
- # Note there may be an optional '---' and '+++' lines
- # before the chunk.
- my $lastpos = tell $fh;
- if (<$fh> !~ /^\-\-\-/ || <$fh> !~ /^\+\+\+/) {
- # Move the file pointer back.
- seek $fh, $lastpos, 0;
- }
-
- my @file_diffs = Codestriker::FileParser::UnidiffUtils->
- read_unidiff_text($fh, $filename, $revision, $repmatch);
- push @result, @file_diffs;
- }
- else {
- # Got knows what this is, can't parse it.
- return ();
- }
- } elsif ($line =~ /^==== (.*)\#(\d+) \-/) {
- my $filename = $1;
- my $revision = $2;
-
- # Now read the entire diff chunk (it may be empty if the
- # user hasn't actually modified the file). Note there
- # may be an optional '---' and '+++' lines before the
- # chunk.
- my $lastpos = tell $fh;
- if (<$fh> !~ /^\-\-\-/ || <$fh> !~ /^\+\+\+/) {
- # Move the file pointer back.
- seek $fh, $lastpos, 0;
- }
-
- my @file_diffs = Codestriker::FileParser::UnidiffUtils->
- read_unidiff_text($fh, $filename, $revision, $repmatch);
- push @result, @file_diffs;
- } else {
- # Can't parse this file.
- return ();
- }
-
- # Now read the next chunk.
- $line = <$fh> if defined $line;
+ if ($line =~ /^==== (.*)\#(\d+) \- .* ==== \((.*)\)$/) {
+ my $filename = $1;
+ my $revision = $2;
+ my $file_type = $3;
+
+ if ($file_type eq "ubinary" || $file_type eq "xbinary" ||
+ $file_type eq "binary") {
+ # Binary file, skip the next line and add the record in.
+ $line = <$fh>;
+ my $chunk = {};
+ $chunk->{filename} = $filename;
+ $chunk->{revision} = $revision;
+ $chunk->{old_linenumber} = -1;
+ $chunk->{new_linenumber} = -1;
+ $chunk->{binary} = 1;
+ $chunk->{text} = "";
+ $chunk->{description} = "";
+ $chunk->{repmatch} = $repmatch;
+ push @result, $chunk;
+ } elsif ($file_type eq "text") {
+ # Note there may be an optional '---' and '+++' lines
+ # before the chunk.
+ my $lastpos = tell $fh;
+ if (<$fh> !~ /^\-\-\-/ || <$fh> !~ /^\+\+\+/) {
+ # Move the file pointer back.
+ seek $fh, $lastpos, 0;
+ }
+
+ my @file_diffs = Codestriker::FileParser::UnidiffUtils->
+ read_unidiff_text($fh, $filename, $revision, $repmatch);
+ push @result, @file_diffs;
+ } else {
+ # Got knows what this is, can't parse it.
+ return ();
+ }
+ } elsif ($line =~ /^==== (.*)\#(\d+) \-/) {
+ my $filename = $1;
+ my $revision = $2;
+
+ # Now read the entire diff chunk (it may be empty if the
+ # user hasn't actually modified the file). Note there
+ # may be an optional '---' and '+++' lines before the
+ # chunk.
+ my $lastpos = tell $fh;
+ if (<$fh> !~ /^\-\-\-/ || <$fh> !~ /^\+\+\+/) {
+ # Move the file pointer back.
+ seek $fh, $lastpos, 0;
+ }
+
+ my @file_diffs = Codestriker::FileParser::UnidiffUtils->
+ read_unidiff_text($fh, $filename, $revision, $repmatch);
+ push @result, @file_diffs;
+ } else {
+ # Can't parse this file.
+ return ();
+ }
+
+ # Now read the next chunk.
+ $line = <$fh> if defined $line;
}
# Return the found diff chunks.
Index: PatchUnidiff.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/FileParser/PatchUnidiff.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PatchUnidiff.pm 14 Jul 2008 05:35:59 -0000 1.7
+++ PatchUnidiff.pm 6 Sep 2008 00:31:44 -0000 1.8
@@ -25,91 +25,91 @@
my $line = <$fh>;
while (defined($line)) {
- # Values associated with the diff.
- my $revision = $Codestriker::PATCH_REVISION;
- my $filename = "";
- my $old_linenumber = -1;
- my $new_linenumber = -1;
- my $binary = 0;
-
- # Skip any heading or trailing whitespace contained in the review
- # text.
- while (defined($line) && $line =~ /^\s*$/) {
- $line = <$fh>;
- }
- return @result unless defined $line;
-
- # For unidiffs, the diff line may appear first, but is optional,
- # depending on how the diff was generated. In any case, the line
- # is ignored.
- if (defined $line && $line =~ /^diff/o) {
- $line = <$fh>;
- }
- return () unless defined $line;
-
- # Git patches might have an index: line, such as:
- # index b3fc290..d13313f 100644
- if ($line =~ /^index /o) {
- $line = <$fh>;
- }
- return () unless defined $line;
-
+ # Values associated with the diff.
+ my $revision = $Codestriker::PATCH_REVISION;
+ my $filename = "";
+ my $old_linenumber = -1;
+ my $new_linenumber = -1;
+ my $binary = 0;
+
+ # Skip any heading or trailing whitespace contained in the review
+ # text.
+ while (defined($line) && $line =~ /^\s*$/) {
+ $line = <$fh>;
+ }
+ return @result unless defined $line;
+
+ # For unidiffs, the diff line may appear first, but is optional,
+ # depending on how the diff was generated. In any case, the line
+ # is ignored.
+ if (defined $line && $line =~ /^diff/o) {
+ $line = <$fh>;
+ }
+ return () unless defined $line;
+
+ # Git patches might have an index: line, such as:
+ # index b3fc290..d13313f 100644
+ if ($line =~ /^index /o) {
+ $line = <$fh>;
+ }
+ return () unless defined $line;
+
# Need to check for binary file differences.
# Unfortunately, when you provide the "-N" argument to diff,
# it doesn't indicate new files or removed files properly. Without
# the -N argument, it then indicates "Only in ...".
if ($line =~ /^Binary files .* and (.*) differ$/ ||
- $line =~ /^Files .* and (.*) differ$/) {
+ $line =~ /^Files .* and (.*) differ$/) {
$filename = $1;
$binary = 1;
} elsif ($line =~ /^Only in (.*): (.*)$/) {
$filename = "$1/$2";
$binary = 1;
- } elsif ($line =~ /^\-\-\- \/dev\/null/o) {
- # File has been added.
- $revision = $Codestriker::ADDED_REVISION;
- } elsif ($line =~ /^\-\-\- ([^\t\n]+)/o) {
- # Note git and quilt diffs don't have a tab character unlike normal diffs.
- $filename = $1;
- } else {
- return ();
- }
-
- if ($binary == 0) {
- # Now expect the +++ line.
- $line = <$fh>;
- return () unless defined $line;
-
- # Check if it is a removed file.
- if ($line =~ /^\+\+\+ \/dev\/null/o) {
- # File has been removed.
- $revision = $Codestriker::REMOVED_REVISION;
- } elsif ($line =~ /^\+\+\+ ([^\t\n]+)/o) {
- $filename = $1;
- } else {
- return ();
- }
-
- # Extract the diff chunks for this file.
- my @file_diffs = Codestriker::FileParser::UnidiffUtils->
- read_unidiff_text($fh, $filename, $revision, 0);
- push @result, @file_diffs;
- } else {
- my $chunk = {};
- $chunk->{filename} = $filename;
- $chunk->{revision} = $revision;
- $chunk->{old_linenumber} = -1;
- $chunk->{new_linenumber} = -1;
- $chunk->{binary} = 1;
- $chunk->{text} = "";
- $chunk->{description} = "";
- $chunk->{repmatch} = 0;
- push @result, $chunk;
- }
+ } elsif ($line =~ /^\-\-\- \/dev\/null/o) {
+ # File has been added.
+ $revision = $Codestriker::ADDED_REVISION;
+ } elsif ($line =~ /^\-\-\- ([^\t\n]+)/o) {
+ # Note git and quilt diffs don't have a tab character unlike normal diffs.
+ $filename = $1;
+ } else {
+ return ();
+ }
+
+ if ($binary == 0) {
+ # Now expect the +++ line.
+ $line = <$fh>;
+ return () unless defined $line;
+
+ # Check if it is a removed file.
+ if ($line =~ /^\+\+\+ \/dev\/null/o) {
+ # File has been removed.
+ $revision = $Codestriker::REMOVED_REVISION;
+ } elsif ($line =~ /^\+\+\+ ([^\t\n]+)/o) {
+ $filename = $1;
+ } else {
+ return ();
+ }
+
+ # Extract the diff chunks for this file.
+ my @file_diffs = Codestriker::FileParser::UnidiffUtils->
+ read_unidiff_text($fh, $filename, $revision, 0);
+ push @result, @file_diffs;
+ } else {
+ my $chunk = {};
+ $chunk->{filename} = $filename;
+ $chunk->{revision} = $revision;
+ $chunk->{old_linenumber} = -1;
+ $chunk->{new_linenumber} = -1;
+ $chunk->{binary} = 1;
+ $chunk->{text} = "";
+ $chunk->{description} = "";
+ $chunk->{repmatch} = 0;
+ push @result, $chunk;
+ }
- # Read the next line.
- $line = <$fh>;
+ # Read the next line.
+ $line = <$fh>;
}
# Return the found diff chunks.
@@ -118,4 +118,4 @@
1;
-
+
Index: ClearCaseSerialDiff.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/FileParser/ClearCaseSerialDiff.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ClearCaseSerialDiff.pm 24 Sep 2007 21:25:45 -0000 1.5
+++ ClearCaseSerialDiff.pm 6 Sep 2008 00:31:44 -0000 1.6
@@ -21,7 +21,7 @@
# Retrieve the repository root, and escape back-slashes in the case of
# a Windows CVS repository, as it is used in regular expressions.
my $repository_root =
- (defined $repository) ? $repository->getRoot() : undef;
+ (defined $repository) ? $repository->getRoot() : undef;
if (defined $repository_root) {
$repository_root =~ s/\\/\\\\/g;
}
@@ -37,128 +37,126 @@
# Ignore any whitespace at the start of the file.
my $line = <$fh>;
while (defined($line)) {
- # Skip any heading or trailing whitespace contained in the review
- # text, in addition to the "Files/Directories are identical" lines,
- # which happen due to the way review texts are generated.
- while (defined($line) &&
- ($line =~ /^\s*$/o ||
- $line =~ /^Files are identical$/o ||
- $line =~ /^Directories are identical$/o)) {
- $line = <$fh>;
- }
- return @result unless defined $line;
-
- # Check if the next fileheader is being read.
- if (defined $line &&
- $line =~ /^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*$/o) {
-
- # Now read the file/directory that has been modified.
- $line = <$fh>;
- return () unless defined $line;
-
- if ($line =~ /^\<\<\< file 1\: (.*)\@\@(.*)$/o) {
- $filename = $1;
- $revision = $2;
-
- # Check if the filename matches the clear case repository.
- # This is very simple for now, but will need to be more
- # sophisticated later.
- if (defined $repository_root &&
- $filename =~ /^$repository_root[\/\\](.*)$/o) {
- $filename = $1;
- $repmatch = 1;
- } else {
- $repmatch = 0;
- }
-
- # Read the next line which is the local file.
- $line = <$fh>;
- return () unless
- defined $line && $line =~ /^\>\>\> file 2\: .*$/o;
-
- # Now expect the end of the file header.
- $line = <$fh>;
- return () unless
- defined $line && $line =~ /^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*$/o;
-
- # Read the next line.
- $line = <$fh>;
- return () unless defined $line;
- }
- elsif ($line =~ /^\<\<\< directory 1\: (.*)\@\@(.*)$/o) {
- # Currently we don't really support directory
- # operations. ClearCase captures added/deleted
- # sub-directories and deleted files as a directory change,
- # but unfortunately added files go straight into the
- # VOB - great. Try to fddge this so that we treat the
- # directory as a file, where the contents are the diff
- # file itself - better than nothing, and the reviewers
- # can at least see what is going on.
- $filename = $1;
- $revision = $2;
-
- # Check if the filename matches the clear case repository.
- # This is very simple for now, but will need to be more
- # sophisticated later.
- if (defined $repository_root &&
- $filename =~ /^$repository_root[\/\\](.*)$/o) {
- $filename = $1;
- }
-
- # Read the next line which is the local directory.
- $line = <$fh>;
- return () unless
- defined $line && $line =~ /^\>\>\> directory 2\: .*$/o;
-
- # Now expect the end of the file header.
- $line = <$fh>;
- return () unless
- defined $line && $line =~ /^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*$/o;
-
- # Keep reading text until there is nothing left for this
- # segment.
- my $text = "";
- $line = <$fh>;
- while (defined $line &&
- $line !~ /^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*$/o) {
- if ($line !~ /^Files are identical$/o &&
- $line !~ /^Directories are identical$/o) {
- $text .= "+$line";
- }
- $line = <$fh>;
- }
-
- # Create the chunk, indicating there is not a repository match,
- # since this is for a directory entry with some basic text.
- my $chunk = {};
- $chunk->{filename} = $filename;
- $chunk->{revision} = $revision;
- $chunk->{old_linenumber} = 0;
- $chunk->{new_linenumber} = 1;
- $chunk->{binary} = 0;
- $chunk->{text} = $text;
- $chunk->{description} = "";
- $chunk->{repmatch} = 0;
- push @result, $chunk;
-
- # Process the next block.
- next;
- }
- else {
- # Some unknown format.
- return ();
- }
- }
-
- # Read the next diff chunk.
- my $chunk =
- Codestriker::FileParser::BasicDiffUtils->read_diff_text(
- $fh, $line, $filename, $revision, $repmatch);
- return () unless defined $chunk;
- push @result, $chunk;
+ # Skip any heading or trailing whitespace contained in the review
+ # text, in addition to the "Files/Directories are identical" lines,
+ # which happen due to the way review texts are generated.
+ while (defined($line) &&
+ ($line =~ /^\s*$/o ||
+ $line =~ /^Files are identical$/o ||
+ $line =~ /^Directories are identical$/o)) {
+ $line = <$fh>;
+ }
+ return @result unless defined $line;
+
+ # Check if the next fileheader is being read.
+ if (defined $line &&
+ $line =~ /^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*$/o) {
+
+ # Now read the file/directory that has been modified.
+ $line = <$fh>;
+ return () unless defined $line;
+
+ if ($line =~ /^\<\<\< file 1\: (.*)\@\@(.*)$/o) {
+ $filename = $1;
+ $revision = $2;
+
+ # Check if the filename matches the clear case repository.
+ # This is very simple for now, but will need to be more
+ # sophisticated later.
+ if (defined $repository_root &&
+ $filename =~ /^$repository_root[\/\\](.*)$/o) {
+ $filename = $1;
+ $repmatch = 1;
+ } else {
+ $repmatch = 0;
+ }
+
+ # Read the next line which is the local file.
+ $line = <$fh>;
+ return () unless
+ defined $line && $line =~ /^\>\>\> file 2\: .*$/o;
+
+ # Now expect the end of the file header.
+ $line = <$fh>;
+ return () unless
+ defined $line && $line =~ /^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*$/o;
+
+ # Read the next line.
+ $line = <$fh>;
+ return () unless defined $line;
+ } elsif ($line =~ /^\<\<\< directory 1\: (.*)\@\@(.*)$/o) {
+ # Currently we don't really support directory
+ # operations. ClearCase captures added/deleted
+ # sub-directories and deleted files as a directory change,
+ # but unfortunately added files go straight into the
+ # VOB - great. Try to fddge this so that we treat the
+ # directory as a file, where the contents are the diff
+ # file itself - better than nothing, and the reviewers
+ # can at least see what is going on.
+ $filename = $1;
+ $revision = $2;
+
+ # Check if the filename matches the clear case repository.
+ # This is very simple for now, but will need to be more
+ # sophisticated later.
+ if (defined $repository_root &&
+ $filename =~ /^$repository_root[\/\\](.*)$/o) {
+ $filename = $1;
+ }
+
+ # Read the next line which is the local directory.
+ $line = <$fh>;
+ return () unless
+ defined $line && $line =~ /^\>\>\> directory 2\: .*$/o;
+
+ # Now expect the end of the file header.
+ $line = <$fh>;
+ return () unless
+ defined $line && $line =~ /^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*$/o;
+
+ # Keep reading text until there is nothing left for this
+ # segment.
+ my $text = "";
+ $line = <$fh>;
+ while (defined $line &&
+ $line !~ /^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*$/o) {
+ if ($line !~ /^Files are identical$/o &&
+ $line !~ /^Directories are identical$/o) {
+ $text .= "+$line";
+ }
+ $line = <$fh>;
+ }
+
+ # Create the chunk, indicating there is not a repository match,
+ # since this is for a directory entry with some basic text.
+ my $chunk = {};
+ $chunk->{filename} = $filename;
+ $chunk->{revision} = $revision;
+ $chunk->{old_linenumber} = 0;
+ $chunk->{new_linenumber} = 1;
+ $chunk->{binary} = 0;
+ $chunk->{text} = $text;
+ $chunk->{description} = "";
+ $chunk->{repmatch} = 0;
+ push @result, $chunk;
+
+ # Process the next block.
+ next;
+ } else {
+ # Some unknown format.
+ return ();
+ }
+ }
+
+ # Read the next diff chunk.
+ my $chunk =
+ Codestriker::FileParser::BasicDiffUtils->read_diff_text(
+ $fh, $line, $filename, $revision, $repmatch);
+ return () unless defined $chunk;
+ push @result, $chunk;
- # Read the next line.
- $line = <$fh>;
+ # Read the next line.
+ $line = <$fh>;
}
# Return the found diff chunks.
@@ -167,4 +165,4 @@
1;
-
+
Index: SubversionDiff.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/FileParser/SubversionDiff.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SubversionDiff.pm 2 Sep 2008 06:33:57 -0000 1.11
+++ SubversionDiff.pm 6 Sep 2008 00:31:44 -0000 1.12
@@ -24,137 +24,137 @@
my $line = <$fh>;
while (defined($line)) {
- # Values associated with the diff.
- my $entry_type;
- my $revision;
- my $filename = "";
- my $old_linenumber = -1;
- my $new_linenumber = -1;
- my $binary = 0;
- my $diff = "";
-
- # Skip whitespace.
- while (defined($line) && $line =~ /^\s*$/o) {
- $line = <$fh>;
- }
- return @result unless defined $line;
-
- # For SVN diffs, the start of the diff block is the Index line.
- # For SVN look diffs, the start of the diff block contains the change type.
- # Also check for presence of property set blocks.
- while ($line =~ /^.*Property changes on: .*$/o) {
- $line = <$fh>;
- return () unless defined $line &&
- $line =~ /^___________________________________________________________________$/o;
-
- # Keep reading until we either get to the separator line or end of file.
- while (defined $line &&
- $line !~ /^===================================================================$/o) {
- if ($line =~ /^.*(Index|Added|Modified|Copied|Deleted): (.*)$/o) {
- $entry_type = $1;
- $filename = $2;
+ # Values associated with the diff.
+ my $entry_type;
+ my $revision;
+ my $filename = "";
+ my $old_linenumber = -1;
+ my $new_linenumber = -1;
+ my $binary = 0;
+ my $diff = "";
+
+ # Skip whitespace.
+ while (defined($line) && $line =~ /^\s*$/o) {
+ $line = <$fh>;
+ }
+ return @result unless defined $line;
+
+ # For SVN diffs, the start of the diff block is the Index line.
+ # For SVN look diffs, the start of the diff block contains the change type.
+ # Also check for presence of property set blocks.
+ while ($line =~ /^.*Property changes on: .*$/o) {
+ $line = <$fh>;
+ return () unless defined $line &&
+ $line =~ /^___________________________________________________________________$/o;
+
+ # Keep reading until we either get to the separator line or end of file.
+ while (defined $line &&
+ $line !~ /^===================================================================$/o) {
+ if ($line =~ /^.*(Index|Added|Modified|Copied|Deleted): (.*)$/o) {
+ $entry_type = $1;
+ $filename = $2;
+ }
+ $line = <$fh>;
+ }
+
+ if (!defined $line) {
+ # End of file has been reached, return what we have parsed.
+ return @result;
}
- $line = <$fh>;
}
-
- if (!defined $line) {
- # End of file has been reached, return what we have parsed.
- return @result;
+
+ if ($line =~ /^.*(Index|Added|Modified|Copied|Deleted): (.*)$/o) {
+ $entry_type = $1;
+ $filename = $2;
+ $line = <$fh>;
}
- }
- if ($line =~ /^.*(Index|Added|Modified|Copied|Deleted): (.*)$/o) {
- $entry_type = $1;
- $filename = $2;
- $line = <$fh>;
- }
+ # The separator line appears next.
+ return () unless defined $line && $line =~ /^===================================================================$/o;
+ $line = <$fh>;
+
+ # Check if this is a file entry with no content. If so, skip it.
+ next if ! defined $line || $line =~ /^\s*$/o;
+
+ # Check if the delta represents a binary file.
+ if ($line =~ /^Cannot display: file marked as a binary type\./o ||
+ $line =~ /^\(Binary files differ\)/o) {
+
+ # If it is a new binary file, there will be some lines before
+ # the next Index: line, or end of file. In other cases, it is
+ # impossible to know whether the file is being modified or
+ # removed, and what revision it is based off.
+ $line = <$fh>;
+ my $count = 0;
+ while (defined $line && $line !~ /^Index|Added|Modified|Deleted|Property changes on:/o) {
+ $line = <$fh>;
+ $count++;
+ }
+
+ my $chunk = {};
+ $chunk->{filename} = $filename;
+ if ($entry_type eq "Index") {
+ $chunk->{revision} = $count > 0 ? $Codestriker::ADDED_REVISION :
+ $Codestriker::PATCH_REVISION;
+ } elsif ($entry_type eq "Added") {
+ $chunk->{revision} = $Codestriker::ADDED_REVISION;
+ } elsif ($entry_type eq "Deleted") {
+ $chunk->{revision} = $Codestriker::REMOVED_REVISION;
+ } else {
+ $chunk->{revision} = $Codestriker::PATCH_REVISION;
+ }
+ $chunk->{old_linenumber} = -1;
+ $chunk->{new_linenumber} = -1;
+ $chunk->{binary} = 1;
+ $chunk->{text} = "";
+ $chunk->{description} = "";
+ $chunk->{repmatch} = 1;
+ push @result, $chunk;
+ } else {
+ # Try and read the base revision this change is against,
+ # while handling new and removed files.
+ my $base_revision = -1;
+ if ($line =~ /^\-\-\- .*\s.*\(.*?(\d+)\)/io) {
+ $base_revision = $1;
+ } elsif ($line !~ /^\-\-\- .*/io) {
+ return ();
+ }
- # The separator line appears next.
- return () unless defined $line && $line =~ /^===================================================================$/o;
- $line = <$fh>;
-
- # Check if this is a file entry with no content. If so, skip it.
- next if ! defined $line || $line =~ /^\s*$/o;
-
- # Check if the delta represents a binary file.
- if ($line =~ /^Cannot display: file marked as a binary type\./o ||
- $line =~ /^\(Binary files differ\)/o) {
-
- # If it is a new binary file, there will be some lines before
- # the next Index: line, or end of file. In other cases, it is
- # impossible to know whether the file is being modified or
- # removed, and what revision it is based off.
- $line = <$fh>;
- my $count = 0;
- while (defined $line && $line !~ /^Index|Added|Modified|Deleted|Property changes on:/o) {
- $line = <$fh>;
- $count++;
- }
-
- my $chunk = {};
- $chunk->{filename} = $filename;
- if ($entry_type eq "Index") {
- $chunk->{revision} = $count > 0 ? $Codestriker::ADDED_REVISION :
- $Codestriker::PATCH_REVISION;
- } elsif ($entry_type eq "Added") {
- $chunk->{revision} = $Codestriker::ADDED_REVISION;
- } elsif ($entry_type eq "Deleted") {
- $chunk->{revision} = $Codestriker::REMOVED_REVISION;
- } else {
- $chunk->{revision} = $Codestriker::PATCH_REVISION;
- }
- $chunk->{old_linenumber} = -1;
- $chunk->{new_linenumber} = -1;
- $chunk->{binary} = 1;
- $chunk->{text} = "";
- $chunk->{description} = "";
- $chunk->{repmatch} = 1;
- push @result, $chunk;
- } else {
- # Try and read the base revision this change is against,
- # while handling new and removed files.
- my $base_revision = -1;
- if ($line =~ /^\-\-\- .*\s.*\(.*?(\d+)\)/io) {
- $base_revision = $1;
- } elsif ($line !~ /^\-\-\- .*/io) {
- return ();
- }
-
- # Make sure the +++ line is present next.
- $line = <$fh>;
- return () unless defined $line;
- if ($line !~ /^\+\+\+ .*/io) {
- return ();
- }
-
- # Now parse the unidiff chunks.
- my @file_diffs = Codestriker::FileParser::UnidiffUtils->
- read_unidiff_text($fh, $filename, $base_revision, 1);
-
- # If $base_revision is -1, and old_linenumber is 0, then
- # the file is added. If $base_revision is -1, and
- # new_linenumber is 0, then the file is removed. Update
- # any chunks to indicate this.
- if ($base_revision == -1) {
- for (my $i = 0; $i <= $#file_diffs; $i++) {
- my $delta = $file_diffs[$i];
- if ($delta->{old_linenumber} == 0) {
- $delta->{revision} = $Codestriker::ADDED_REVISION;
- } elsif ($delta->{new_linenumber} == 0) {
- $delta->{revision} = $Codestriker::REMOVED_REVISION;
- }
- }
- }
-
- push @result, @file_diffs;
-
- # Read the next line.
- $line = <$fh>;
- }
+ # Make sure the +++ line is present next.
+ $line = <$fh>;
+ return () unless defined $line;
+ if ($line !~ /^\+\+\+ .*/io) {
+ return ();
+ }
+
+ # Now parse the unidiff chunks.
+ my @file_diffs = Codestriker::FileParser::UnidiffUtils->
+ read_unidiff_text($fh, $filename, $base_revision, 1);
+
+ # If $base_revision is -1, and old_linenumber is 0, then
+ # the file is added. If $base_revision is -1, and
+ # new_linenumber is 0, then the file is removed. Update
+ # any chunks to indicate this.
+ if ($base_revision == -1) {
+ for (my $i = 0; $i <= $#file_diffs; $i++) {
+ my $delta = $file_diffs[$i];
+ if ($delta->{old_linenumber} == 0) {
+ $delta->{revision} = $Codestriker::ADDED_REVISION;
+ } elsif ($delta->{new_linenumber} == 0) {
+ $delta->{revision} = $Codestriker::REMOVED_REVISION;
+ }
+ }
+ }
+
+ push @result, @file_diffs;
+
+ # Read the next line.
+ $line = <$fh>;
+ }
}
# Return the found diff chunks.
return @result;
}
-
+
1;
Index: Parser.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/FileParser/Parser.pm,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- Parser.pm 26 Jun 2008 21:52:23 -0000 1.25
+++ Parser.pm 6 Sep 2008 00:31:44 -0000 1.26
@@ -7,7 +7,7 @@
# the terms of the GPL.
# Main delegate parser object, which tries a bunch of parsers to determine what
-# format the input review is in. The last resort, is to view it as
+# format the input review is in. The last resort, is to view it as
# unstructured text, if it is content-type plain/text, otherwise indicate
# an error.
@@ -32,7 +32,7 @@
# lines, revisions and diffs have been submitted in this review.
sub parse ($$$$$$) {
my ($type, $fh, $content_type, $repository, $topicid,
- $uploaded_filename) = @_;
+ $uploaded_filename) = @_;
# Diffs found.
my @diffs = ();
@@ -45,139 +45,138 @@
# once this function has finished.
my $tmpfh;
if (defined $Codestriker::tmpdir && $Codestriker::tmpdir ne "") {
- $tmpfh = tempfile(DIR => $Codestriker::tmpdir);
- }
- else {
- $tmpfh = tempfile();
+ $tmpfh = tempfile(DIR => $Codestriker::tmpdir);
+ } else {
+ $tmpfh = tempfile();
}
binmode $tmpfh, ':utf8';
-
+
if (!$tmpfh) {
- die "Unable to create temporary parse file: $!";
+ die "Unable to create temporary parse file: $!";
}
binmode $fh;
my $first_line = 1;
while (<$fh>) {
- if ($first_line) {
- # Remove the UTF8 BOM if it exists.
- s/^\xEF\xBB\xBF//o;
- $first_line = 0;
- }
- my $line = Codestriker::decode_topic_text($_);
- $line =~ s/\r\n/\n/go;
- print $tmpfh $line;
+ if ($first_line) {
+ # Remove the UTF8 BOM if it exists.
+ s/^\xEF\xBB\xBF//o;
+ $first_line = 0;
+ }
+ my $line = Codestriker::decode_topic_text($_);
+ $line =~ s/\r\n/\n/go;
+ print $tmpfh $line;
}
# Rewind the file, then let the parsers have at it.
seek($tmpfh,0,0) ||
- die "Unable to seek to the start of the temporary file: $!";
+ die "Unable to seek to the start of the temporary file: $!";
# If the file is plain/text, try all of the text parsers.
if ($content_type eq "text/plain") {
- # Check if it is a CVS unidiff file.
- if ($#diffs == -1) {
- seek($tmpfh, 0, 0) ||
- die "Unable to seek to the start of the temporary file: $!";
- @diffs =
- Codestriker::FileParser::CvsUnidiff->parse($tmpfh,
- $repository);
- }
-
- # Check if it is a Subversion diff file.
- if ($#diffs == -1) {
- seek($tmpfh, 0, 0) ||
- die "Unable to seek to the start of the temporary file: $!";
- @diffs =
- Codestriker::FileParser::SubversionDiff->parse($tmpfh,
- $repository);
- }
-
- # Check if it is a Perforce describe file.
- if ($#diffs == -1) {
- seek($tmpfh, 0, 0) ||
- die "Unable to seek to the start of the temporary file: $!";
- @diffs =
- Codestriker::FileParser::PerforceDescribe->parse($tmpfh,
- $repository);
- }
-
- # Check if it is a Perforce diff file.
- if ($#diffs == -1) {
- seek($tmpfh, 0, 0) ||
- die "Unable to seek to the start of the temporary file: $!";
- @diffs =
- Codestriker::FileParser::PerforceDiff->parse($tmpfh,
- $repository);
- }
-
- # Check if it is a VSS diff file.
- if ($#diffs == -1) {
- seek($tmpfh, 0, 0) ||
- die "Unable to seek to the start of the temporary file: $!";
- @diffs =
- Codestriker::FileParser::VssDiff->parse($tmpfh,
- $repository);
- }
-
- # Check if it is a patch unidiff file.
- if ($#diffs == -1) {
- seek($tmpfh, 0, 0) ||
- die "Unable to seek to the start of the temporary file: $!";
- @diffs =
- Codestriker::FileParser::PatchUnidiff->parse($tmpfh,
- $repository);
- }
-
- # Check if it is a patch basic file.
- if ($#diffs == -1) {
- seek($tmpfh, 0, 0) ||
- die "Unable to seek to the start of the temporary file: $!";
- @diffs =
- Codestriker::FileParser::PatchBasicDiff->parse($tmpfh,
- $uploaded_filename);
- }
-
- # Check if it is a ClearCase serial diff file.
- if ($#diffs == -1) {
- seek($tmpfh, 0, 0) ||
- die "Unable to seek to the start of the temporary file: $!";
- @diffs =
- Codestriker::FileParser::ClearCaseSerialDiff->parse($tmpfh,
- $repository);
- }
-
- # Last stop-gap - the file format is unknown, treat it as a
- # single file with filename "unknown".
- if ($#diffs == -1) {
- if (! defined $uploaded_filename || $uploaded_filename eq '') {
- $uploaded_filename = 'unknown.txt';
- }
- seek($tmpfh, 0, 0) ||
- die "Unable to seek to the start of the temporary file: $!";
- @diffs = Codestriker::FileParser::UnknownFormat->
- parse($tmpfh, $uploaded_filename);
- }
+ # Check if it is a CVS unidiff file.
+ if ($#diffs == -1) {
+ seek($tmpfh, 0, 0) ||
+ die "Unable to seek to the start of the temporary file: $!";
+ @diffs =
+ Codestriker::FileParser::CvsUnidiff->parse($tmpfh,
+ $repository);
+ }
+
+ # Check if it is a Subversion diff file.
+ if ($#diffs == -1) {
+ seek($tmpfh, 0, 0) ||
+ die "Unable to seek to the start of the temporary file: $!";
+ @diffs =
+ Codestriker::FileParser::SubversionDiff->parse($tmpfh,
+ $repository);
+ }
+
+ # Check if it is a Perforce describe file.
+ if ($#diffs == -1) {
+ seek($tmpfh, 0, 0) ||
+ die "Unable to seek to the start of the temporary file: $!";
+ @diffs =
+ Codestriker::FileParser::PerforceDescribe->parse($tmpfh,
+ $repository);
+ }
+
+ # Check if it is a Perforce diff file.
+ if ($#diffs == -1) {
+ seek($tmpfh, 0, 0) ||
+ die "Unable to seek to the start of the temporary file: $!";
+ @diffs =
+ Codestriker::FileParser::PerforceDiff->parse($tmpfh,
+ $repository);
+ }
+
+ # Check if it is a VSS diff file.
+ if ($#diffs == -1) {
+ seek($tmpfh, 0, 0) ||
+ die "Unable to seek to the start of the temporary file: $!";
+ @diffs =
+ Codestriker::FileParser::VssDiff->parse($tmpfh,
+ $repository);
+ }
+
+ # Check if it is a patch unidiff file.
+ if ($#diffs == -1) {
+ seek($tmpfh, 0, 0) ||
+ die "Unable to seek to the start of the temporary file: $!";
+ @diffs =
+ Codestriker::FileParser::PatchUnidiff->parse($tmpfh,
+ $repository);
+ }
+
+ # Check if it is a patch basic file.
+ if ($#diffs == -1) {
+ seek($tmpfh, 0, 0) ||
+ die "Unable to seek to the start of the temporary file: $!";
+ @diffs =
+ Codestriker::FileParser::PatchBasicDiff->parse($tmpfh,
+ $uploaded_filename);
+ }
+
+ # Check if it is a ClearCase serial diff file.
+ if ($#diffs == -1) {
+ seek($tmpfh, 0, 0) ||
+ die "Unable to seek to the start of the temporary file: $!";
+ @diffs =
+ Codestriker::FileParser::ClearCaseSerialDiff->parse($tmpfh,
+ $repository);
+ }
+
+ # Last stop-gap - the file format is unknown, treat it as a
+ # single file with filename "unknown".
+ if ($#diffs == -1) {
+ if (! defined $uploaded_filename || $uploaded_filename eq '') {
+ $uploaded_filename = 'unknown.txt';
+ }
+ seek($tmpfh, 0, 0) ||
+ die "Unable to seek to the start of the temporary file: $!";
+ @diffs = Codestriker::FileParser::UnknownFormat->
+ parse($tmpfh, $uploaded_filename);
+ }
} elsif ($content_type eq "application/gzip" ||
- $content_type eq "application/x-gzip") {
- # Check if it is a gzip file.
+ $content_type eq "application/x-gzip") {
+ # Check if it is a gzip file.
} elsif ($content_type eq "application/zip" ||
- $content_type eq "application/x-zip") {
- # Check if it is a zip file.
+ $content_type eq "application/x-zip") {
+ # Check if it is a zip file.
}
# Restore the offset back to the start of the file again.
seek($fh, 0, 0) ||
- die "Unable to seek to the start of the temporary file. $!";
+ die "Unable to seek to the start of the temporary file. $!";
- if (defined $Codestriker::sort_diffs_by_filename &&
- $Codestriker::sort_diffs_by_filename) {
- # Sort the diff chunks by filename, then old linenumber.
- @diffs = sort { $a->{filename} cmp $b->{filename} ||
- $a->{old_linenumber} <=> $b->{old_linenumber} } @diffs;
- }
+ if (defined $Codestriker::sort_diffs_by_filename &&
+ $Codestriker::sort_diffs_by_filename) {
+ # Sort the diff chunks by filename, then old linenumber.
+ @diffs = sort { $a->{filename} cmp $b->{filename} ||
+ $a->{old_linenumber} <=> $b->{old_linenumber} } @diffs;
+ }
# Only include those files whose extension is not in
# @Codestriker::exclude_file_types, provided it is defined.
@@ -185,16 +184,16 @@
my @trimmed_diffs = ();
foreach my $curr (@diffs) {
- if ($curr->{filename} =~ /\.([^\.]+)(,v)?$/o) {
- my $ext = $1;
- push @trimmed_diffs, $curr
- unless grep { $_ eq $ext } @Codestriker::exclude_file_types;
- } else {
- # No extension on this file, add the diff in.
- push @trimmed_diffs, $curr;
- }
+ if ($curr->{filename} =~ /\.([^\.]+)(,v)?$/o) {
+ my $ext = $1;
+ push @trimmed_diffs, $curr
+ unless grep { $_ eq $ext } @Codestriker::exclude_file_types;
+ } else {
+ # No extension on this file, add the diff in.
+ push @trimmed_diffs, $curr;
+ }
}
-
+
# Return the diffs found, if any.
return @trimmed_diffs;
}
Index: BasicDiffUtils.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/FileParser/BasicDiffUtils.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BasicDiffUtils.pm 15 Nov 2004 10:44:06 -0000 1.4
+++ BasicDiffUtils.pm 6 Sep 2008 00:31:44 -0000 1.5
@@ -26,106 +26,106 @@
my $new_length = 0;
if ($line =~ /^(\d+)a(\d+),(\d+)$/o ||
- $line =~ /^\-\-\-\-\-\[after (\d+) inserted(?:\/moved)? (\d+)\-(\d+)(?: \(was at [\d\-]+\))?\]\-\-\-\-\-\s*$/o) {
- # Added multiple lines of text.
- $old_linenumber = $1+1;
- $new_linenumber = $2;
- $new_length = $3 - $2 + 1;
+ $line =~ /^\-\-\-\-\-\[after (\d+) inserted(?:\/moved)? (\d+)\-(\d+)(?: \(was at [\d\-]+\))?\]\-\-\-\-\-\s*$/o) {
+ # Added multiple lines of text.
+ $old_linenumber = $1+1;
+ $new_linenumber = $2;
+ $new_length = $3 - $2 + 1;
} elsif ($line =~ /^(\d+)a(\d+)$/o ||
- $line =~ /^\-\-\-\-\-\[after (\d+) inserted(?:\/moved)? (\d+)(?: \(was at [\d\-]+\))?\]\-\-\-\-\-\s*$/o) {
- # Added a single line of text.
- $old_linenumber = $1+1;
- $new_linenumber = $2;
- $new_length = 1;
+ $line =~ /^\-\-\-\-\-\[after (\d+) inserted(?:\/moved)? (\d+)(?: \(was at [\d\-]+\))?\]\-\-\-\-\-\s*$/o) {
+ # Added a single line of text.
+ $old_linenumber = $1+1;
+ $new_linenumber = $2;
+ $new_length = 1;
} elsif ($line =~ /^(\d+),(\d+)d(\d+)$/o ||
- $line =~ /^\-\-\-\-\-\[deleted(?:\/moved)? (\d+)\-(\d+) after (\d+)(?: \(now at [\d\-]+\))?\]\-\-\-\-\-\s*$/o) {
- # Multiple lines deleted.
- $old_linenumber = $1;
- $new_linenumber = $3+1;
- $old_length = $2 - $1 + 1;
+ $line =~ /^\-\-\-\-\-\[deleted(?:\/moved)? (\d+)\-(\d+) after (\d+)(?: \(now at [\d\-]+\))?\]\-\-\-\-\-\s*$/o) {
+ # Multiple lines deleted.
+ $old_linenumber = $1;
+ $new_linenumber = $3+1;
+ $old_length = $2 - $1 + 1;
} elsif ($line =~ /^(\d+)d(\d+)$/o ||
- $line =~ /^\-\-\-\-\-\[deleted(?:\/moved)? (\d+) after (\d+)(?: \(now at [\d\-]+\))?\]\-\-\-\-\-\s*$/o) {
- # Single line deleted.
- $old_linenumber = $1;
- $new_linenumber = $2+1;
- $old_length = 1;
+ $line =~ /^\-\-\-\-\-\[deleted(?:\/moved)? (\d+) after (\d+)(?: \(now at [\d\-]+\))?\]\-\-\-\-\-\s*$/o) {
+ # Single line deleted.
+ $old_linenumber = $1;
+ $new_linenumber = $2+1;
+ $old_length = 1;
} elsif ($line =~ /^(\d+),(\d+)c(\d+),(\d+)$/o ||
- $line =~ /^\-\-\-\-\-\[(\d+)\-(\d+) changed to (\d+)\-(\d+)\]\-\-\-\-\-\s*$/o) {
- # Multiple text lines changed.
- $old_linenumber = $1;
- $new_linenumber = $3;
- $old_length = $2 - $1 + 1;
- $new_length = $4 - $3 + 1;
+ $line =~ /^\-\-\-\-\-\[(\d+)\-(\d+) changed to (\d+)\-(\d+)\]\-\-\-\-\-\s*$/o) {
+ # Multiple text lines changed.
+ $old_linenumber = $1;
+ $new_linenumber = $3;
+ $old_length = $2 - $1 + 1;
+ $new_length = $4 - $3 + 1;
} elsif ($line =~ /^(\d+)c(\d+),(\d+)$/o ||
- $line =~ /^\-\-\-\-\-\[(\d+) changed to (\d+)\-(\d+)\]\-\-\-\-\-\s*$/o) {
- # Multiple source lines changed to single line.
- $old_linenumber = $1;
- $new_linenumber = $2;
- $old_length = 1;
- $new_length = $3 - $2 + 1;
+ $line =~ /^\-\-\-\-\-\[(\d+) changed to (\d+)\-(\d+)\]\-\-\-\-\-\s*$/o) {
+ # Multiple source lines changed to single line.
+ $old_linenumber = $1;
+ $new_linenumber = $2;
+ $old_length = 1;
+ $new_length = $3 - $2 + 1;
} elsif ($line =~ /^(\d+),(\d+)c(\d+)$/o ||
- $line =~ /^\-\-\-\-\-\[(\d+)\-(\d+) changed to (\d+)\]\-\-\-\-\-\s*$/o) {
- # Single source line changed to multiple lines.
- $old_linenumber = $1;
- $new_linenumber = $3;
- $old_length = $2 - $1 + 1;
- $new_length = 1;
+ $line =~ /^\-\-\-\-\-\[(\d+)\-(\d+) changed to (\d+)\]\-\-\-\-\-\s*$/o) {
+ # Single source line changed to multiple lines.
+ $old_linenumber = $1;
+ $new_linenumber = $3;
+ $old_length = $2 - $1 + 1;
+ $new_length = 1;
} elsif ($line =~ /^(\d+)c(\d+)$/o ||
- $line =~ /^\-\-\-\-\-\[(\d+) changed to (\d+)\]\-\-\-\-\-\s*$/o) {
- # Single line changed to another line.
- $old_linenumber = $1;
- $new_linenumber = $2;
- $old_length = 1;
- $new_length = 1;
+ $line =~ /^\-\-\-\-\-\[(\d+) changed to (\d+)\]\-\-\-\-\-\s*$/o) {
+ # Single line changed to another line.
+ $old_linenumber = $1;
+ $new_linenumber = $2;
+ $old_length = 1;
+ $new_length = 1;
} else {
- # Some other file format.
- return undef;
+ # Some other file format.
+ return undef;
}
-
+
# The chunk in unidiff format.
my $chunk_text = "";
-
+
# First read the old lines, if any.
for (my $i = 0; $i < $old_length; $i++) {
- $line = <$fh>;
- if (defined $line && $line =~ /^\< (.*)$/) {
- $chunk_text .= "-${1}\n";
- } else {
- # Some other format.
- return undef;
- }
+ $line = <$fh>;
+ if (defined $line && $line =~ /^\< (.*)$/) {
+ $chunk_text .= "-${1}\n";
+ } else {
+ # Some other format.
+ return undef;
+ }
}
-
+
# If there is both old and new text, read the separator line.
# Note bloody VSS for some versions will put the --- at the end of
# the previous line rather than on a new line!
if ($old_length > 0 && $new_length > 0) {
- my $previous_line = $line;
- my $pos = $fh->getpos;
- $line = <$fh>;
- return undef unless defined $line;
- if ($line !~ /^\-\-\-$/o && $chunk_text =~ /^(.*)\-\-\-$/os) {
- # Stupid VSS diff format, chop off the seperator characters
- # and move the file pointer back.
- $chunk_text = "$1\n";
- $fh->setpos($pos);
- } elsif ($line !~ /^\-\-\-$/o) {
- # Didn't match standard separator, some other format.
- return undef;
- }
+ my $previous_line = $line;
+ my $pos = $fh->getpos;
+ $line = <$fh>;
+ return undef unless defined $line;
+ if ($line !~ /^\-\-\-$/o && $chunk_text =~ /^(.*)\-\-\-$/os) {
+ # Stupid VSS diff format, chop off the seperator characters
+ # and move the file pointer back.
+ $chunk_text = "$1\n";
+ $fh->setpos($pos);
+ } elsif ($line !~ /^\-\-\-$/o) {
+ # Didn't match standard separator, some other format.
+ return undef;
+ }
}
-
+
# Now read the new lines, if any.
for (my $i = 0; $i < $new_length; $i++) {
- $line = <$fh>;
- if (defined $line && $line =~ /^\> (.*)$/) {
- $chunk_text .= "+${1}\n";
- } else {
- # Some other format.
- return undef;
- }
+ $line = <$fh>;
+ if (defined $line && $line =~ /^\> (.*)$/) {
+ $chunk_text .= "+${1}\n";
+ } else {
+ # Some other format.
+ return undef;
+ }
}
-
+
# Now create the chunk object, and return it.
my $chunk = {};
$chunk->{filename} = $filename;
Index: PerforceDescribe.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/FileParser/PerforceDescribe.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PerforceDescribe.pm 29 Aug 2008 11:48:26 -0000 1.7
+++ PerforceDescribe.pm 6 Sep 2008 00:31:44 -0000 1.8
@@ -30,7 +30,7 @@
# Skip initial whitespace.
my $line = <$fh>;
while (defined($line) && $line =~ /^\s*$/) {
- $line = <$fh>;
+ $line = <$fh>;
}
# Array of results found.
@@ -51,8 +51,8 @@
# Skip the lines up to the table of contents.
$line = <$fh>;
while (defined($line) && $line !~ /^\.\.\./) {
- $line = <$fh>;
- return () unless defined $line;
+ $line = <$fh>;
+ return () unless defined $line;
}
# Now read the initial table of contents entries. For added or
@@ -60,37 +60,37 @@
# repository, as it isn't included in the text of the diff,
# unlike CVS.
while (defined($line) && $line =~ /^\.\.\. (.*)\#(\d+) (.*)$/) {
- my $entry = {};
- $entry->{filename} = $1;
- $entry->{revision} = $2;
- $entry->{change_type} = $3;
- $entry->{repmatch} = 1;
- $entry->{old_linenumber} = 0;
- $entry->{new_linenumber} = 0;
- $entry->{text} = "";
- if ($entry->{change_type} eq 'add') {
- _retrieve_file($entry, $repository);
- } elsif ($entry->{change_type} eq 'delete') {
- # Need to retrieve the text of the previous revision number,
- # as the current one is empty.
- $entry->{revision}--;
- _retrieve_file($entry, $repository);
- $entry->{revision}++;
- } else {
- # Assume it is an edit, nothing else to do, as the diffs
- # will be included below.
- }
-
- # Add this to the table of contents array.
- push @toc, $entry;
-
- $line = <$fh>;
- return () unless defined $line;
+ my $entry = {};
+ $entry->{filename} = $1;
+ $entry->{revision} = $2;
+ $entry->{change_type} = $3;
+ $entry->{repmatch} = 1;
+ $entry->{old_linenumber} = 0;
+ $entry->{new_linenumber} = 0;
+ $entry->{text} = "";
+ if ($entry->{change_type} eq 'add') {
+ _retrieve_file($entry, $repository);
+ } elsif ($entry->{change_type} eq 'delete') {
+ # Need to retrieve the text of the previous revision number,
+ # as the current one is empty.
+ $entry->{revision}--;
+ _retrieve_file($entry, $repository);
+ $entry->{revision}++;
+ } else {
+ # Assume it is an edit, nothing else to do, as the diffs
+ # will be included below.
+ }
+
+ # Add this to the table of contents array.
+ push @toc, $entry;
+
+ $line = <$fh>;
+ return () unless defined $line;
}
# Skip the lines until the first diff chunk.
while (defined($line) && $line !~ /^==== /) {
- $line = <$fh>;
+ $line = <$fh>;
}
# Now read the actual diff chunks. Any entries not here will be added
@@ -98,66 +98,66 @@
# retrieved from the repository.
my $toc_index = 0;
while (defined($line) && $line =~ /^====/) {
- # Read the next diff chunk.
- return () unless $line =~ /^==== (.*)\#(\d+) \((.*)\) ====$/;
- my $filename = $1;
- my $revision = $2;
- my $filetype = $3;
-
- # Check if there are any outstanding added/removed entries from the
- # toc that need to be processed first.
- my $entry = $toc[$toc_index];
- while ($entry->{filename} ne $filename) {
- my $chunk = _make_chunk($entry);
- push @result, $chunk;
-
- # Check the next TOC entry, if any.
- last if ($toc_index >= $#toc);
-
- $toc_index++;
- $entry = $toc[$toc_index];
- }
-
- # Skip the next blank line before the unidiff.
- $line = <$fh>;
- next unless defined $line;
-
- if ($filetype =~ /.*text/) {
- # Now read the entire diff chunk.
- # Note there may be an optional '---' and '+++' lines
- # before the chunk.
- my $lastpos = tell $fh;
- if (<$fh> !~ /^\-\-\-/ || <$fh> !~ /^\+\+\+/) {
- # Move the file pointer back.
- seek $fh, $lastpos, 0;
- }
-
- my @file_diffs = Codestriker::FileParser::UnidiffUtils->
- read_unidiff_text($fh, $filename, $revision, $repmatch);
- push @result, @file_diffs;
- } else {
- # Assume it is a binary file, initialise the chunk from the
- # TOC entry, and flag it as binary.
- my $chunk = _make_chunk($entry);
- $chunk->{binary} = 1;
- push @result, $chunk;
- }
-
- # Move on to the next entry in the TOC.
- $toc_index++;
-
- # Skip the next blank line before the next chunk.
- $line = <$fh>;
- while (defined $line && $line =~ /^\s*$/) {
- $line = <$fh>;
- }
+ # Read the next diff chunk.
+ return () unless $line =~ /^==== (.*)\#(\d+) \((.*)\) ====$/;
+ my $filename = $1;
+ my $revision = $2;
+ my $filetype = $3;
+
+ # Check if there are any outstanding added/removed entries from the
+ # toc that need to be processed first.
+ my $entry = $toc[$toc_index];
+ while ($entry->{filename} ne $filename) {
+ my $chunk = _make_chunk($entry);
+ push @result, $chunk;
+
+ # Check the next TOC entry, if any.
+ last if ($toc_index >= $#toc);
+
+ $toc_index++;
+ $entry = $toc[$toc_index];
+ }
+
+ # Skip the next blank line before the unidiff.
+ $line = <$fh>;
+ next unless defined $line;
+
+ if ($filetype =~ /.*text/) {
+ # Now read the entire diff chunk...
[truncated message content] |