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

ruby-changes:22127

From: knu <ko1@a...>
Date: Mon, 2 Jan 2012 22:18:20 +0900 (JST)
Subject: [ruby-changes:22127] knu:r34176 (trunk): * tool/file2lastrev.rb (VCS::detect): Add support for Subversion

knu	2012-01-02 22:14:24 +0900 (Mon, 02 Jan 2012)

  New Revision: 34176

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

  Log:
    * tool/file2lastrev.rb (VCS::detect): Add support for Subversion
      1.7 which adopted a whole new working directory structure.
    
    * tool/file2lastrev.rb (VCS::detect): Simply use .each instead of
      .sort.reverse_each which looks too arbitrary.	 If you want SVN
      to be tried first, then you just have to register it first as it
      is right now.

  Modified files:
    trunk/ChangeLog
    trunk/tool/file2lastrev.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 34175)
+++ ChangeLog	(revision 34176)
@@ -1,3 +1,13 @@
+Mon Jan  2 22:08:00 2012  Akinori MUSHA  <knu@i...>
+
+	* tool/file2lastrev.rb (VCS::detect): Add support for Subversion
+	  1.7 which adopted a whole new working directory structure.
+
+	* tool/file2lastrev.rb (VCS::detect): Simply use .each instead of
+	  .sort.reverse_each which looks too arbitrary.  If you want SVN
+	  to be tried first, then you just have to register it first as it
+	  is right now.
+
 Mon Jan  2 20:53:36 2012  Tanaka Akira  <akr@f...>
 
 	* lib/securerandom.rb (random_bytes): use IO#read instead of
Index: tool/file2lastrev.rb
===================================================================
--- tool/file2lastrev.rb	(revision 34175)
+++ tool/file2lastrev.rb	(revision 34176)
@@ -22,8 +22,15 @@
   end
 
   def self.detect(path)
-    @@dirs.sort.reverse_each do |dir, klass|
-      return klass.new(path) if File.directory?("#{path}/#{dir}")
+    @@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
@@ -127,7 +134,7 @@
 }
 parser.parse! rescue abort "#{File.basename(Program)}: #{$!}\n#{parser}"
 
-srcdir = srcdir ? srcdir : File.dirname(File.dirname(Program))
+srcdir ||= File.dirname(File.dirname(Program))
 begin
   vcs = VCS.detect(srcdir)
 rescue VCS::NotFoundError => e

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

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