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

ruby-changes:33124

From: nobu <ko1@a...>
Date: Fri, 28 Feb 2014 10:23:36 +0900 (JST)
Subject: [ruby-changes:33124] nobu:r45203 (trunk): tool/vcs.rb: discard error messages

nobu	2014-02-28 10:23:31 +0900 (Fri, 28 Feb 2014)

  New Revision: 45203

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

  Log:
    tool/vcs.rb: discard error messages
    
    * tool/vcs.rb (VCS#get_revisions): discard error messages for all
      VCS not only SVN.

  Modified files:
    trunk/tool/vcs.rb
Index: tool/vcs.rb
===================================================================
--- tool/vcs.rb	(revision 45202)
+++ tool/vcs.rb	(revision 45203)
@@ -38,11 +38,27 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L38
     super()
   end
 
+  NullDevice = defined?(IO::NULL) ? IO::NULL :
+    %w[/dev/null NUL NIL: NL:].find {|dev| File.exist?(dev)}
+
   # 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, changed, modified, *rest = Dir.chdir(@srcdir) {
+      begin
+        if NullDevice
+          save_stderr = STDERR.dup
+          STDERR.reopen NullDevice, 'w'
+        end
+        self.class.get_revisions(path)
+      ensure
+        if save_stderr
+          STDERR.reopen save_stderr
+          save_stderr.close
+        end
+      end
+    }
     last or raise VCS::NotFoundError, "last revision not found"
     changed or raise VCS::NotFoundError, "changed revision not found"
     modified &&= Time.parse(modified)
@@ -73,19 +89,7 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L89
     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
+      info_xml = `svn info --xml "#{path}"`
       _, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
       modified = info_xml[/<date>([^<>]*)/, 1]
       [last, changed, modified]

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

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