[前][次][番号順一覧][スレッド一覧]

ruby-changes:31576

From: nagachika <ko1@a...>
Date: Tue, 12 Nov 2013 23:35:20 +0900 (JST)
Subject: [ruby-changes:31576] nagachika:r43655 (ruby_2_0_0): merge revision(s) 43609, 43617: [Backport #8878] [Backport #9085]

nagachika	2013-11-12 23:35:13 +0900 (Tue, 12 Nov 2013)

  New Revision: 43655

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43655

  Log:
    merge revision(s) 43609,43617: [Backport #8878] [Backport #9085]
    
    vcs.rb: split
    
    * tool/vcs.rb: split from file2lastrev.rb.
    * tool/rbinstall.rb (Gem::Specification.load): obtain spec date from
      VCS for the case using git, RUBY_RELEASE_DATE is the last resort.
      probably fixes [Bug #9085].

  Added files:
    branches/ruby_2_0_0/tool/vcs.rb
  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/tool/file2lastrev.rb
    branches/ruby_2_0_0/tool/rbinstall.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 43654)
+++ ruby_2_0_0/ChangeLog	(revision 43655)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Tue Nov 12 23:33:08 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* tool/rbinstall.rb (Gem::Specification.load): obtain spec date from
+	  VCS for the case using git, RUBY_RELEASE_DATE is the last resort.
+	  probably fixes [Bug #9085].
+
 Tue Nov 12 23:24:35 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (RUNRUBY): append -- only after runruby.rb, not
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 43654)
+++ ruby_2_0_0/version.h	(revision 43655)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2013-11-12"
-#define RUBY_PATCHLEVEL 347
+#define RUBY_PATCHLEVEL 348
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 11
Index: ruby_2_0_0/tool/rbinstall.rb
===================================================================
--- ruby_2_0_0/tool/rbinstall.rb	(revision 43654)
+++ ruby_2_0_0/tool/rbinstall.rb	(revision 43655)
@@ -18,10 +18,17 @@ require 'shellwords' https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/tool/rbinstall.rb#L18
 require 'optparse'
 require 'optparse/shellwords'
 require 'ostruct'
+require_relative 'vcs'
 
 STDOUT.sync = true
 File.umask(0)
 
+begin
+  $vcs = VCS.detect(File.expand_path('../..', __FILE__))
+rescue VCS::NotFoundError
+  $vcs = nil
+end
+
 def parse_args(argv = ARGV)
   $mantype = 'doc'
   $destdir = nil
@@ -555,13 +562,20 @@ module Gem https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/tool/rbinstall.rb#L562
       super
       yield(self) if defined?(yield)
       self.executables ||= []
-      self.date ||= RUBY_RELEASE_DATE
     end
 
     def self.load(path)
       src = File.open(path, "rb") {|f| f.read}
       src.sub!(/\A#.*/, '')
-      eval(src, nil, path)
+      spec = eval(src, nil, path)
+      spec.date ||= last_date(path) || RUBY_RELEASE_DATE
+      spec
+    end
+
+    def self.last_date(path)
+      return unless $vcs
+      return unless time = $vcs.get_revisions(path)[2]
+      time.strftime("%Y-%m-%d")
     end
 
     def to_ruby
Index: ruby_2_0_0/tool/vcs.rb
===================================================================
--- ruby_2_0_0/tool/vcs.rb	(revision 0)
+++ ruby_2_0_0/tool/vcs.rb	(revision 43655)
@@ -0,0 +1,112 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/tool/vcs.rb#L1
+# vcs
+
+require 'time'
+
+ENV.delete('PWD')
+
+unless File.respond_to? :realpath
+  require 'pathname'
+  def File.realpath(arg)
+    Pathname(arg).realpath.to_s
+  end
+end
+
+class VCS
+  class NotFoundError < RuntimeError; end
+
+  @@dirs = []
+  def self.register(dir)
+    @@dirs << [dir, self]
+  end
+
+  def self.detect(path)
+    @@dirs.each do |dir, klass|
+      return klass.new(path) if File.directory?(File.join(path, dir))
+      prev = path
+      loop {
+        curr = File.realpath(File.join(prev, '..'))
+        break if curr == prev	# stop at the root directory
+        return klass.new(path) if File.directory?(File.join(curr, dir))
+        prev = curr
+      }
+    end
+    raise VCS::NotFoundError, "does not seem to be under a vcs: #{path}"
+  end
+
+  def initialize(path)
+    @srcdir = path
+    super()
+  end
+
+  # return a pair of strings, the last revision and the last revision in which
+  # +path+ was modified.
+  def get_revisions(path)
+    path = relative_to(path)
+    last, changed, modified, *rest = Dir.chdir(@srcdir) {self.class.get_revisions(path)}
+    last or raise "last revision not found"
+    changed or raise "changed revision not found"
+    modified &&= Time.parse(modified)
+    return last, changed, modified, *rest
+  end
+
+  def relative_to(path)
+    if path
+      srcdir = File.realpath(@srcdir)
+      path = File.realpath(path)
+      list1 = srcdir.split(%r{/})
+      list2 = path.split(%r{/})
+      while !list1.empty? && !list2.empty? && list1.first == list2.first
+        list1.shift
+        list2.shift
+      end
+      if list1.empty? && list2.empty?
+        "."
+      else
+        ([".."] * list1.length + list2).join("/")
+      end
+    else
+      '.'
+    end
+  end
+
+  class SVN < self
+    register(".svn")
+
+    def self.get_revisions(path)
+      begin
+        nulldevice = %w[/dev/null NUL NIL: NL:].find {|dev| File.exist?(dev)}
+        if nulldevice
+          save_stderr = STDERR.dup
+          STDERR.reopen nulldevice, 'w'
+        end
+        info_xml = `svn info --xml "#{path}"`
+      ensure
+        if save_stderr
+          STDERR.reopen save_stderr
+          save_stderr.close
+        end
+      end
+      _, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
+      modified = info_xml[/<date>([^<>]*)/, 1]
+      [last, changed, modified]
+    end
+  end
+
+  class GIT < self
+    register(".git")
+
+    def self.get_revisions(path)
+      logcmd = %Q[git log -n1 --grep="^ *git-svn-id: .*@[0-9][0-9]* "]
+      idpat = /git-svn-id: .*?@(\d+) \S+\Z/
+      last = `#{logcmd}`[idpat, 1]
+      if path
+        log = `#{logcmd} "#{path}"`
+        changed = log[idpat, 1]
+        modified = `git log --format=%ai -- #{path}`
+      else
+        changed = last
+      end
+      [last, changed, modified]
+    end
+  end
+end

Property changes on: ruby_2_0_0/tool/vcs.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: ruby_2_0_0/tool/file2lastrev.rb
===================================================================
--- ruby_2_0_0/tool/file2lastrev.rb	(revision 43654)
+++ ruby_2_0_0/tool/file2lastrev.rb	(revision 43655)
@@ -1,110 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/tool/file2lastrev.rb#L1
 #!/usr/bin/env ruby
 
-ENV.delete('PWD')
-
 require 'optparse'
 
-unless File.respond_to? :realpath
-  require 'pathname'
-  def File.realpath(arg)
-    Pathname(arg).realpath.to_s
-  end
-end
+# this file run with BASERUBY, which may be older than 1.9, so no
+# require_relative
+require File.expand_path('../vcs', __FILE__)
 
 Program = $0
 
-class VCS
-  class NotFoundError < RuntimeError; end
-
-  @@dirs = []
-  def self.register(dir)
-    @@dirs << [dir, self]
-  end
-
-  def self.detect(path)
-    @@dirs.each do |dir, klass|
-      return klass.new(path) if File.directory?(File.join(path, dir))
-      prev = path
-      loop {
-        curr = File.realpath(File.join(prev, '..'))
-        break if curr == prev	# stop at the root directory
-        return klass.new(path) if File.directory?(File.join(curr, dir))
-        prev = curr
-      }
-    end
-    raise VCS::NotFoundError, "does not seem to be under a vcs: #{path}"
-  end
-
-  def initialize(path)
-    @srcdir = path
-    super()
-  end
-
-  # return a pair of strings, the last revision and the last revision in which
-  # +path+ was modified.
-  def get_revisions(path)
-    path = relative_to(path)
-    last, changed, *rest = Dir.chdir(@srcdir) {self.class.get_revisions(path)}
-    last or raise "last revision not found"
-    changed or raise "changed revision not found"
-    return last, changed, *rest
-  end
-
-  def relative_to(path)
-    if path
-      srcdir = File.realpath(@srcdir)
-      path = File.realpath(path)
-      list1 = srcdir.split(%r{/})
-      list2 = path.split(%r{/})
-      while !list1.empty? && !list2.empty? && list1.first == list2.first
-        list1.shift
-        list2.shift
-      end
-      if list1.empty? && list2.empty?
-        "."
-      else
-        ([".."] * list1.length + list2).join("/")
-      end
-    else
-      '.'
-    end
-  end
-
-  class SVN < self
-    register(".svn")
-
-    def self.get_revisions(path)
-      begin
-        nulldevice = %w[/dev/null NUL NIL: NL:].find {|dev| File.exist?(dev)}
-        if nulldevice
-          save_stderr = STDERR.dup
-          STDERR.reopen nulldevice, 'w'
-        end
-        info_xml = `svn info --xml "#{path}"`
-      ensure
-        if save_stderr
-          STDERR.reopen save_stderr
-          save_stderr.close
-        end
-      end
-      _, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
-      [last, changed]
-    end
-  end
-
-  class GIT < self
-    register(".git")
-
-    def self.get_revisions(path)
-      logcmd = %Q[git log -n1 --grep="^ *git-svn-id: .*@[0-9][0-9]* "]
-      idpat = /git-svn-id: .*?@(\d+) \S+\Z/
-      last = `#{logcmd}`[idpat, 1]
-      changed = path ? `#{logcmd} "#{path}"`[idpat, 1] : last
-      [last, changed]
-    end
-  end
-end
-
 @output = nil
 def self.output=(output)
   if @output and @output != output

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r43609,43617


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]