summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
Diffstat (limited to 'tool')
-rwxr-xr-xtool/make-snapshot5
-rw-r--r--tool/vcs.rb49
2 files changed, 45 insertions, 9 deletions
diff --git a/tool/make-snapshot b/tool/make-snapshot
index 788c2b9a0a..d2f92f53c6 100755
--- a/tool/make-snapshot
+++ b/tool/make-snapshot
@@ -205,7 +205,6 @@ def package(vcs, rev, destdir, tmp = nil)
end
end
- srcdir = File.realpath($srcdir)
Dir.chdir(tmp) if tmp
if !File.directory?(v)
@@ -215,13 +214,13 @@ def package(vcs, rev, destdir, tmp = nil)
end
# get last revision from previous ChangeLog archive
- last_ChangeLog = Dir["#{v}/doc/ChangeLog-*"].grep(/-\d+\z/).last
+ last_ChangeLog = Dir["#{v}/doc/ChangeLog-*"].grep(/-(\d+)\z/) {|n| [$1.to_i, n]}.max[1]
open(last_ChangeLog) do |f|
f.readline
unless /\Ar(\d+) / =~ f.readline
abort "Cannot find revision from '#{last_ChangeLog}'"
end
- vcs.export_changelog(srcdir, url, $1.to_i+1, revision.to_i, "#{v}/ChangeLog")
+ vcs.export_changelog($1.to_i, revision.to_i, "#{v}/ChangeLog")
end
open("#{v}/revision.h", "wb") {|f| f.puts "#define RUBY_REVISION #{revision}"}
diff --git a/tool/vcs.rb b/tool/vcs.rb
index e663d86a98..43b18e4879 100644
--- a/tool/vcs.rb
+++ b/tool/vcs.rb
@@ -24,6 +24,10 @@ if RUBY_VERSION < "2.0"
if defined?(fork)
def self.popen(command, *rest, &block)
+ if command.kind_of?(Hash)
+ env = command
+ command = rest.shift
+ end
opts = rest.last
if opts.kind_of?(Hash)
dir = opts.delete(:chdir)
@@ -36,6 +40,7 @@ if RUBY_VERSION < "2.0"
yield(f)
else
Dir.chdir(dir) if dir
+ ENV.replace(env) if env
exec(*command)
end
end
@@ -43,6 +48,7 @@ if RUBY_VERSION < "2.0"
f = @orig_popen.call("-", *rest)
unless f
Dir.chdir(dir) if dir
+ ENV.replace(env) if env
exec(*command)
end
f
@@ -51,6 +57,11 @@ if RUBY_VERSION < "2.0"
else
require 'shellwords'
def self.popen(command, *rest, &block)
+ if command.kind_of?(Hash)
+ env = command
+ oldenv = ENV.to_hash
+ command = rest.shift
+ end
opts = rest.last
if opts.kind_of?(Hash)
dir = opts.delete(:chdir)
@@ -59,11 +70,26 @@ if RUBY_VERSION < "2.0"
command = command.shelljoin if Array === command
Dir.chdir(dir || ".") do
+ ENV.replace(env) if env
@orig_popen.call(command, *rest, &block)
+ ENV.replace(oldenv) if oldenv
end
end
end
end
+else
+ module DebugPOpen
+ verbose, $VERBOSE = $VERBOSE, nil if RUBY_VERSION < "2.1"
+ refine IO.singleton_class do
+ def popen(*args)
+ STDERR.puts args.inspect if $DEBUG
+ super
+ end
+ end
+ ensure
+ $VERBOSE = verbose unless verbose.nil?
+ end
+ using DebugPOpen
end
class VCS
@@ -94,6 +120,7 @@ class VCS
def initialize(path)
@srcdir = path
+ @abs_srcdir = File.realpath(path)
super()
end
@@ -281,8 +308,10 @@ class VCS
FileUtils.rm_rf(dir+"/.svn")
end
- def export_changelog(srcdir, url, from, to, path)
- IO.popen({'TZ' => 'JST-9'}, "svn log -r#{to}:#{from} #{url}") do |r|
+ def export_changelog(from, to, path)
+ range = [to, (from+1 if from)].compact.join(':')
+ IO.popen({'TZ' => 'JST-9', 'LANG' => 'C', 'LC_ALL' => 'C'},
+ %W"svn log -r#{range} #{url}") do |r|
open(path, 'w') do |w|
IO.copy_stream(r, w)
end
@@ -364,10 +393,18 @@ class VCS
FileUtils.rm_rf("#{dir}/.git")
end
- def export_changelog(srcdir, url, from, to, path)
- from = `git -C #{srcdir} log -n1 --format=format:%H --grep='^ *git-svn-id: .*@#{from} '`
- to = `git -C #{srcdir} log -n1 --format=format:%H --grep='^ *git-svn-id: .*@#{to} '`
- IO.popen({'TZ' => 'JST-9'}, "git -C #{srcdir} log --date=iso-local --topo-order #{from}..#{to}") do |r|
+ def export_changelog(from, to, path)
+ range = [from, to].map do |rev|
+ rev or next
+ rev = IO.pread({'LANG' => 'C', 'LC_ALL' => 'C'},
+ %W"git log -n1 --format=format:%H" <<
+ "--grep=^ *git-svn-id: .*@#{rev} ",
+ :chdir => @abs_srcdir)
+ rev unless rev.empty?
+ end.join('..')
+ IO.popen({'TZ' => 'JST-9', 'LANG' => 'C', 'LC_ALL' => 'C'},
+ %W"git svn log --date=iso-local --topo-order #{range}",
+ :chdir => @abs_srcdir) do |r|
open(path, 'w') do |w|
IO.copy_stream(r, w)
end