mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Revert r61054
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b9426859e7
commit
4b4f7c428c
1 changed files with 31 additions and 45 deletions
76
tool/vcs.rb
76
tool/vcs.rb
|
@ -116,32 +116,6 @@ class VCS
|
||||||
String === path or path.respond_to?(:to_path)
|
String === path or path.respond_to?(:to_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.cmd_args(cmds, srcdir = nil)
|
|
||||||
if srcdir and local_path?(srcdir)
|
|
||||||
(opts = cmds.last).kind_of?(Hash) or cmds << (opts = {})
|
|
||||||
opts[:chdir] ||= srcdir
|
|
||||||
end
|
|
||||||
cmds
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.cmd_pipe_at(srcdir, cmds, &block)
|
|
||||||
IO.popen(*cmd_args(cmds, srcdir), &block)
|
|
||||||
rescue Errno::ENOENT => e
|
|
||||||
raise VCS::NotFoundError, e.message
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.cmd_read_at(srcdir, cmds)
|
|
||||||
IO.pread(*cmd_args(cmds, srcdir))
|
|
||||||
rescue Errno::ENOENT => e
|
|
||||||
raise VCS::NotFoundError, e.message
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.system(*cmds)
|
|
||||||
Process.wait(Process.spawn(*cmds))
|
|
||||||
rescue Errno::ENOENT => e
|
|
||||||
raise VCS::NotFoundError, e.message
|
|
||||||
end
|
|
||||||
|
|
||||||
attr_reader :srcdir
|
attr_reader :srcdir
|
||||||
|
|
||||||
def initialize(path)
|
def initialize(path)
|
||||||
|
@ -217,18 +191,6 @@ class VCS
|
||||||
def after_export(dir)
|
def after_export(dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
def cmd_pipe(*cmds, &block)
|
|
||||||
self.class.cmd_pipe_at(@srcdir, cmds, &block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def cmd_read(*cmds)
|
|
||||||
self.class.cmd_read_at(@srcdir, cmds)
|
|
||||||
end
|
|
||||||
|
|
||||||
def system(*cmds)
|
|
||||||
self.class.system(*cmds)
|
|
||||||
end
|
|
||||||
|
|
||||||
class SVN < self
|
class SVN < self
|
||||||
register(".svn")
|
register(".svn")
|
||||||
COMMAND = ENV['SVN'] || 'svn'
|
COMMAND = ENV['SVN'] || 'svn'
|
||||||
|
@ -238,10 +200,10 @@ class VCS
|
||||||
path = File.join(srcdir, path)
|
path = File.join(srcdir, path)
|
||||||
end
|
end
|
||||||
if srcdir
|
if srcdir
|
||||||
info_xml = cmd_read_at(nil, [%W"#{COMMAND} info --xml #{srcdir}"])
|
info_xml = IO.pread(%W"#{COMMAND} info --xml #{srcdir}")
|
||||||
info_xml = nil unless info_xml[/<url>(.*)<\/url>/, 1] == path.to_s
|
info_xml = nil unless info_xml[/<url>(.*)<\/url>/, 1] == path.to_s
|
||||||
end
|
end
|
||||||
info_xml ||= cmd_read_at(nil, [%W"#{COMMAND} info --xml #{path}"])
|
info_xml ||= IO.pread(%W"#{COMMAND} info --xml #{path}")
|
||||||
_, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
|
_, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
|
||||||
modified = info_xml[/<date>([^<>]*)/, 1]
|
modified = info_xml[/<date>([^<>]*)/, 1]
|
||||||
branch = info_xml[%r'<relative-url>\^/(?:branches/|tags/)?([^<>]+)', 1]
|
branch = info_xml[%r'<relative-url>\^/(?:branches/|tags/)?([^<>]+)', 1]
|
||||||
|
@ -258,7 +220,7 @@ class VCS
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_info
|
def get_info
|
||||||
@info ||= cmd_read(%W"#{COMMAND} info --xml")
|
@info ||= IO.pread(%W"#{COMMAND} info --xml #{@srcdir}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
|
@ -291,7 +253,7 @@ class VCS
|
||||||
end
|
end
|
||||||
|
|
||||||
def branch_list(pat)
|
def branch_list(pat)
|
||||||
cmd_pipe(%W"#{COMMAND} ls #{branch('')}") do |f|
|
IO.popen(%W"#{COMMAND} ls #{branch('')}") do |f|
|
||||||
f.each do |line|
|
f.each do |line|
|
||||||
line.chomp!
|
line.chomp!
|
||||||
line.chomp!('/')
|
line.chomp!('/')
|
||||||
|
@ -304,7 +266,7 @@ class VCS
|
||||||
cmd = %W"#{COMMAND} cat"
|
cmd = %W"#{COMMAND} cat"
|
||||||
files.map! {|n| File.join(tag, n)} if tag
|
files.map! {|n| File.join(tag, n)} if tag
|
||||||
set = block.binding.eval("proc {|match| $~ = match}")
|
set = block.binding.eval("proc {|match| $~ = match}")
|
||||||
cmd_pipe([cmd, *files]) do |f|
|
IO.popen([cmd, *files]) do |f|
|
||||||
f.grep(pat) do |s|
|
f.grep(pat) do |s|
|
||||||
set[$~]
|
set[$~]
|
||||||
yield s
|
yield s
|
||||||
|
@ -336,7 +298,7 @@ class VCS
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
cmd_pipe(%W"#{COMMAND} export -r #{revision} #{url} #{dir}") do |pipe|
|
IO.popen(%W"#{COMMAND} export -r #{revision} #{url} #{dir}") do |pipe|
|
||||||
pipe.each {|line| /^A/ =~ line or yield line}
|
pipe.each {|line| /^A/ =~ line or yield line}
|
||||||
end
|
end
|
||||||
$?.success?
|
$?.success?
|
||||||
|
@ -348,7 +310,7 @@ class VCS
|
||||||
|
|
||||||
def export_changelog(url, from, to, path)
|
def export_changelog(url, from, to, path)
|
||||||
range = [to, (from+1 if from)].compact.join(':')
|
range = [to, (from+1 if from)].compact.join(':')
|
||||||
cmd_pipe({'TZ' => 'JST-9', 'LANG' => 'C', 'LC_ALL' => 'C'},
|
IO.popen({'TZ' => 'JST-9', 'LANG' => 'C', 'LC_ALL' => 'C'},
|
||||||
%W"#{COMMAND} log -r#{range} #{url}") do |r|
|
%W"#{COMMAND} log -r#{range} #{url}") do |r|
|
||||||
open(path, 'w') do |w|
|
open(path, 'w') do |w|
|
||||||
IO.copy_stream(r, w)
|
IO.copy_stream(r, w)
|
||||||
|
@ -365,6 +327,22 @@ class VCS
|
||||||
register(".git") {|path, dir| File.exist?(File.join(path, dir))}
|
register(".git") {|path, dir| File.exist?(File.join(path, dir))}
|
||||||
COMMAND = ENV["GIT"] || 'git'
|
COMMAND = ENV["GIT"] || 'git'
|
||||||
|
|
||||||
|
def self.cmd_args(cmds, srcdir = nil)
|
||||||
|
if srcdir and local_path?(srcdir)
|
||||||
|
(opts = cmds.last).kind_of?(Hash) or cmds << (opts = {})
|
||||||
|
opts[:chdir] ||= srcdir
|
||||||
|
end
|
||||||
|
cmds
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.cmd_pipe_at(srcdir, cmds, &block)
|
||||||
|
IO.popen(*cmd_args(cmds, srcdir), &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.cmd_read_at(srcdir, cmds)
|
||||||
|
IO.pread(*cmd_args(cmds, srcdir))
|
||||||
|
end
|
||||||
|
|
||||||
def self.get_revisions(path, srcdir = nil)
|
def self.get_revisions(path, srcdir = nil)
|
||||||
gitcmd = [COMMAND]
|
gitcmd = [COMMAND]
|
||||||
desc = cmd_read_at(srcdir, [gitcmd + %w[describe --tags --match REV_*]])
|
desc = cmd_read_at(srcdir, [gitcmd + %w[describe --tags --match REV_*]])
|
||||||
|
@ -400,6 +378,14 @@ class VCS
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cmd_pipe(*cmds, &block)
|
||||||
|
self.class.cmd_pipe_at(@srcdir, cmds, &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cmd_read(*cmds)
|
||||||
|
self.class.cmd_read_at(@srcdir, cmds)
|
||||||
|
end
|
||||||
|
|
||||||
Branch = Struct.new(:to_str)
|
Branch = Struct.new(:to_str)
|
||||||
|
|
||||||
def branch(name)
|
def branch(name)
|
||||||
|
|
Loading…
Add table
Reference in a new issue