summaryrefslogtreecommitdiff
path: root/tool/make-snapshot
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-15 01:02:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-15 01:02:52 +0000
commitfff1128281f49583d4b227cec7d32bfce735a1fb (patch)
treed804bbf5a2619fec96595bde1974a83b9ae0e1e7 /tool/make-snapshot
parent81ac745846986ae5fe22885342a6039e408e4e82 (diff)
vcs.rb: abstract
* tool/vcs.rb: abstract VCS interfaces from make-snapshot. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/make-snapshot')
-rwxr-xr-xtool/make-snapshot43
1 files changed, 24 insertions, 19 deletions
diff --git a/tool/make-snapshot b/tool/make-snapshot
index c451d7e..835d465 100755
--- a/tool/make-snapshot
+++ b/tool/make-snapshot
@@ -5,6 +5,7 @@ require 'digest/md5'
require 'digest/sha2'
require 'fileutils'
require 'tmpdir'
+require File.expand_path("../vcs", __FILE__)
STDOUT.sync = true
$exported = nil if ($exported ||= nil) == ""
@@ -121,50 +122,53 @@ unless tmp = $exported
FileUtils.rm_rf(tmp)
} unless $keep_temp
end
-Dir.chdir tmp
-def package(rev, destdir)
+def package(vcs, rev, destdir, tmp = nil)
patchlevel = false
prerelease = false
if revision = rev[/@(\d+)\z/, 1]
rev = $`
end
case rev
- when /\Atrunk\z/, /\Abranches\//, /\Atags\//
- url = SVNURL + rev
+ when /\Atrunk\z/
+ url = vcs.trunk
+ when /\Abranches\//
+ url = vcs.branch($')
+ when /\Atags\//
+ url = vcs.tag($')
when /\Astable\z/
- url = SVNURL + "branches/"
- url = url + `svn ls #{url}`[/.*^(ruby_\d+_\d+)\//m, 1]
+ vcs.branch_list(/ruby_[0-9]*/) {|n| url = /\Aruby_\d+_\d+\z/ =~ n}
+ url &&= vcs.branch(url)
when /\A(.*)\.(.*)\.(.*)-(preview|rc)(\d+)/
prerelease = true
tag = "#{$4}#{$5}"
- url = SVNURL + "tags/v#{$1}_#{$2}_#{$3}_#{$4}#{$5}"
+ url = vcs.tag("v#{$1}_#{$2}_#{$3}_#{$4}#{$5}")
when /\A(.*)\.(.*)\.(.*)-p(\d+)/
patchlevel = true
tag = "p#{$4}"
- url = SVNURL + "tags/v#{$1}_#{$2}_#{$3}_#{$4}"
+ url = vcs.tag("v#{$1}_#{$2}_#{$3}_#{$4}")
when /\A(\d+)\.(\d+)(?:\.(\d+))?\z/
if $3 && ($1 > "2" || $1 == "2" && $2 >= "1")
patchlevel = true
tag = ""
- url = SVNURL + "tags/v#{$1}_#{$2}_#{$3}"
+ url = vcs.tag("v#{$1}_#{$2}_#{$3}")
else
- url = SVNURL + "branches/ruby_#{rev.tr('.', '_')}"
+ url = vcs.branch("ruby_#{rev.tr('.', '_')}")
end
else
warn "#{$0}: unknown version - #{rev}"
return
end
- revision ||= `svn info #{url} 2>&1`[/Last Changed Rev: (\d+)/, 1]
+ revision ||= vcs.get_revisions(url)[1]
version = nil
unless revision
- url = SVNURL + "trunk"
- version = `svn cat #{url + "version.h"}`[RUBY_VERSION_PATTERN, 1]
+ url = vcs.trunk
+ vcs.grep(RUBY_VERSION_PATTERN, url, "version.h") {version = $1}
unless rev == version
warn "#{$0}: #{rev} not found"
return
end
- revision = `svn info #{url}`[/Last Changed Rev: (\d+)/, 1]
+ revision = vcs.get_revisions(url)[1]
end
v = nil
if $exported
@@ -174,15 +178,14 @@ def package(rev, destdir)
else
v = "ruby"
puts "Exporting #{rev}@#{revision}"
- IO.popen(%W"svn export -r #{revision} #{url} #{v}") do |pipe|
- pipe.each {|line| /^A/ =~ line or print line}
- end
- unless $?.success?
+ unless vcs.export(revision, url, tmp ? File.join(tmp, v) : v) {|line| print line}
warn("Export failed")
return
end
end
+ Dir.chdir(tmp) if tmp
+
if !File.directory?(v)
v = Dir.glob("ruby-*").select(&File.method(:directory?))
v.size == 1 or abort "not exported"
@@ -338,8 +341,10 @@ ensure
FileUtils.rm_rf(v) if v and !$exported and !$keep_temp
end
+vcs = VCS::SVN.new(SVNURL)
+
success = true
-revisions.collect {|rev| package(rev, destdir)}.flatten.each do |name|
+revisions.collect {|rev| package(vcs, rev, destdir, tmp)}.flatten.each do |name|
if !name
success = false
next