diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-07 05:57:43 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-07 05:57:43 +0000 |
commit | 81234c5ecaab58e03e346ebdbf5678e4b8a3db55 (patch) | |
tree | 3e291a26fec6b193bb7cca54e312e6d6d4801aaf /tool/vcs.rb | |
parent | e432492b4062931f656624f7904b73f89dfa4790 (diff) | |
parent | 4c5f4258aac15c8162e8e9c08ad45781511c3d48 (diff) |
add tag v2_4_0_preview3v2_4_0_preview3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v2_4_0_preview3@56661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/vcs.rb')
-rw-r--r-- | tool/vcs.rb | 49 |
1 files changed, 43 insertions, 6 deletions
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 |