scm: cvs: code clean up adapter.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5386 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-04-10 12:27:53 +00:00
parent 3be326f0a4
commit d5bb4b349a
1 changed files with 34 additions and 37 deletions

View File

@ -156,9 +156,10 @@ module Redmine
# in the repository. both identifier have to be dates or nil. # in the repository. both identifier have to be dates or nil.
# these method returns nothing but yield every result in block # these method returns nothing but yield every result in block
def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}, &block) def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}, &block)
logger.debug "<cvs> revisions path:'#{path}',identifier_from #{identifier_from}, identifier_to #{identifier_to}" logger.debug "<cvs> revisions path:" +
"'#{path}',identifier_from #{identifier_from}, identifier_to #{identifier_to}"
path_with_project="#{url}#{with_leading_slash(path)}" path_with_project = "#{url}#{with_leading_slash(path)}"
cmd_args = %w|rlog| cmd_args = %w|rlog|
cmd_args << "-d" << ">#{time_to_cvstime_rlog(identifier_from)}" if identifier_from cmd_args << "-d" << ">#{time_to_cvstime_rlog(identifier_from)}" if identifier_from
cmd_args << path_with_project cmd_args << path_with_project
@ -187,10 +188,10 @@ module Redmine
elsif /^head: (.+)$/ =~ line elsif /^head: (.+)$/ =~ line
entry_headRev = $1 #unless entry.nil? entry_headRev = $1 #unless entry.nil?
elsif /^symbolic names:/ =~ line elsif /^symbolic names:/ =~ line
state="symbolic" #unless entry.nil? state = "symbolic" #unless entry.nil?
elsif /^#{STARTLOG}/ =~ line elsif /^#{STARTLOG}/ =~ line
commit_log=String.new commit_log = String.new
state="revision" state = "revision"
end end
next next
elsif state=="symbolic" elsif state=="symbolic"
@ -211,36 +212,30 @@ module Redmine
elsif state=="revision" elsif state=="revision"
if /^#{ENDLOG}/ =~ line || /^#{STARTLOG}/ =~ line if /^#{ENDLOG}/ =~ line || /^#{STARTLOG}/ =~ line
if revision if revision
revHelper=CvsRevisionHelper.new(revision) revHelper=CvsRevisionHelper.new(revision)
revBranch="HEAD" revBranch="HEAD"
branch_map.each() do |branch_name, branch_point|
branch_map.each() do |branch_name,branch_point|
if revHelper.is_in_branch_with_symbol(branch_point) if revHelper.is_in_branch_with_symbol(branch_point)
revBranch=branch_name revBranch=branch_name
end end
end end
logger.debug("********** YIELD Revision #{revision}::#{revBranch}") logger.debug("********** YIELD Revision #{revision}::#{revBranch}")
yield Revision.new({ yield Revision.new({
:time => date, :time => date,
:author => author, :author => author,
:message=>commit_log.chomp, :message => commit_log.chomp,
:paths => [{ :paths => [{
:revision => revision, :revision => revision,
:branch=> revBranch, :branch => revBranch,
:path=>entry_path, :path => entry_path,
:name=>entry_name, :name => entry_name,
:kind=>'file', :kind => 'file',
:action=>file_state :action => file_state
}] }]
}) })
end end
commit_log = String.new
commit_log=String.new revision = nil
revision=nil
if /^#{ENDLOG}/ =~ line if /^#{ENDLOG}/ =~ line
state="entry_start" state="entry_start"
end end
@ -255,8 +250,10 @@ module Redmine
date = Time.parse($1) date = Time.parse($1)
author = /author: ([^;]+)/.match(line)[1] author = /author: ([^;]+)/.match(line)[1]
file_state = /state: ([^;]+)/.match(line)[1] file_state = /state: ([^;]+)/.match(line)[1]
#TODO: linechanges only available in CVS.... maybe a feature our SVN implementation. i'm sure, they are # TODO:
# useful for stats or something else # linechanges only available in CVS....
# maybe a feature our SVN implementation.
# I'm sure, they are useful for stats or something else
# linechanges =/lines: \+(\d+) -(\d+)/.match(line) # linechanges =/lines: \+(\d+) -(\d+)/.match(line)
# unless linechanges.nil? # unless linechanges.nil?
# version.line_plus = linechanges[1] # version.line_plus = linechanges[1]
@ -405,16 +402,16 @@ module Redmine
private private
def buildRevision(rev) def buildRevision(rev)
if rev== 0 if rev == 0
if @branchid.nil? if @branchid.nil?
@base+".0" @base + ".0"
else else
@base @base
end end
elsif @branchid.nil? elsif @branchid.nil?
@base+"."+rev.to_s @base + "." + rev.to_s
else else
@base+"."+@branchid+"."+rev.to_s @base + "." + @branchid + "." + rev.to_s
end end
end end