scm: cvs: code clean up adapter.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5436 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
20b33942ba
commit
d09e496a57
@ -5,12 +5,12 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@ -68,11 +68,13 @@ module Redmine
|
|||||||
def initialize(url, root_url=nil, login=nil, password=nil,
|
def initialize(url, root_url=nil, login=nil, password=nil,
|
||||||
path_encoding=nil)
|
path_encoding=nil)
|
||||||
@url = url
|
@url = url
|
||||||
@login = login if login && !login.empty?
|
|
||||||
@password = (password || "") if @login
|
|
||||||
# TODO: better Exception here (IllegalArgumentException)
|
# TODO: better Exception here (IllegalArgumentException)
|
||||||
raise CommandFailed if root_url.blank?
|
raise CommandFailed if root_url.blank?
|
||||||
@root_url = root_url
|
@root_url = root_url
|
||||||
|
|
||||||
|
# These are unused.
|
||||||
|
@login = login if login && !login.empty?
|
||||||
|
@password = (password || "") if @login
|
||||||
end
|
end
|
||||||
|
|
||||||
def root_url
|
def root_url
|
||||||
@ -160,7 +162,7 @@ module Redmine
|
|||||||
"'#{path}',identifier_from #{identifier_from}, identifier_to #{identifier_to}"
|
"'#{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|-q rlog|
|
cmd_args = %w|-q 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
|
||||||
scm_cmd(*cmd_args) do |io|
|
scm_cmd(*cmd_args) do |io|
|
||||||
state = "entry_start"
|
state = "entry_start"
|
||||||
@ -191,15 +193,15 @@ module Redmine
|
|||||||
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"
|
||||||
if /^(.*):\s(.*)/ =~ (line.strip)
|
if /^(.*):\s(.*)/ =~ (line.strip)
|
||||||
branch_map[$1]=$2
|
branch_map[$1]=$2
|
||||||
else
|
else
|
||||||
state="tags"
|
state="tags"
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
elsif state=="tags"
|
elsif state=="tags"
|
||||||
if /^#{STARTLOG}/ =~ line
|
if /^#{STARTLOG}/ =~ line
|
||||||
commit_log = ""
|
commit_log = ""
|
||||||
@ -244,12 +246,12 @@ module Redmine
|
|||||||
if /^branches: (.+)$/ =~ line
|
if /^branches: (.+)$/ =~ line
|
||||||
# TODO: version.branch = $1
|
# TODO: version.branch = $1
|
||||||
elsif /^revision (\d+(?:\.\d+)+).*$/ =~ line
|
elsif /^revision (\d+(?:\.\d+)+).*$/ =~ line
|
||||||
revision = $1
|
revision = $1
|
||||||
elsif /^date:\s+(\d+.\d+.\d+\s+\d+:\d+:\d+)/ =~ line
|
elsif /^date:\s+(\d+.\d+.\d+\s+\d+:\d+:\d+)/ =~ line
|
||||||
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:
|
# TODO:
|
||||||
# linechanges only available in CVS....
|
# linechanges only available in CVS....
|
||||||
# maybe a feature our SVN implementation.
|
# maybe a feature our SVN implementation.
|
||||||
# I'm sure, they are useful for stats or something else
|
# I'm sure, they are useful for stats or something else
|
||||||
@ -345,7 +347,7 @@ module Redmine
|
|||||||
def time_to_cvstime(time)
|
def time_to_cvstime(time)
|
||||||
return nil if time.nil?
|
return nil if time.nil?
|
||||||
return Time.now if time == 'HEAD'
|
return Time.now if time == 'HEAD'
|
||||||
|
|
||||||
unless time.kind_of? Time
|
unless time.kind_of? Time
|
||||||
time = Time.parse(time)
|
time = Time.parse(time)
|
||||||
end
|
end
|
||||||
@ -364,7 +366,7 @@ module Redmine
|
|||||||
|
|
||||||
def normalize_path(path)
|
def normalize_path(path)
|
||||||
path.sub(/^(\/)*(.*)/,'\2').sub(/(.*)(,v)+/,'\1')
|
path.sub(/^(\/)*(.*)/,'\2').sub(/(.*)(,v)+/,'\1')
|
||||||
end
|
end
|
||||||
|
|
||||||
class Revision < Redmine::Scm::Adapters::Revision
|
class Revision < Redmine::Scm::Adapters::Revision
|
||||||
# Returns the readable identifier
|
# Returns the readable identifier
|
||||||
@ -383,27 +385,27 @@ module Redmine
|
|||||||
ret
|
ret
|
||||||
end
|
end
|
||||||
private :scm_cmd
|
private :scm_cmd
|
||||||
end
|
end
|
||||||
|
|
||||||
class CvsRevisionHelper
|
class CvsRevisionHelper
|
||||||
attr_accessor :complete_rev, :revision, :base, :branchid
|
attr_accessor :complete_rev, :revision, :base, :branchid
|
||||||
|
|
||||||
def initialize(complete_rev)
|
def initialize(complete_rev)
|
||||||
@complete_rev = complete_rev
|
@complete_rev = complete_rev
|
||||||
parseRevision()
|
parseRevision()
|
||||||
end
|
end
|
||||||
|
|
||||||
def branchPoint
|
def branchPoint
|
||||||
return @base
|
return @base
|
||||||
end
|
end
|
||||||
|
|
||||||
def branchVersion
|
def branchVersion
|
||||||
if isBranchRevision
|
if isBranchRevision
|
||||||
return @base+"."+@branchid
|
return @base+"."+@branchid
|
||||||
end
|
end
|
||||||
return @base
|
return @base
|
||||||
end
|
end
|
||||||
|
|
||||||
def isBranchRevision
|
def isBranchRevision
|
||||||
!@branchid.nil?
|
!@branchid.nil?
|
||||||
end
|
end
|
||||||
@ -429,7 +431,7 @@ module Redmine
|
|||||||
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
|
||||||
@ -445,7 +447,7 @@ module Redmine
|
|||||||
@base = pieces[0..-baseSize].join(".")
|
@base = pieces[0..-baseSize].join(".")
|
||||||
if baseSize > 2
|
if baseSize > 2
|
||||||
@branchid = pieces[-2]
|
@branchid = pieces[-2]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user