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

ruby-changes:37274

From: nobu <ko1@a...>
Date: Tue, 20 Jan 2015 23:43:44 +0900 (JST)
Subject: [ruby-changes:37274] nobu:r49355 (trunk): vcs.rb: fix for local svn

nobu	2015-01-20 23:43:30 +0900 (Tue, 20 Jan 2015)

  New Revision: 49355

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

  Log:
    vcs.rb: fix for local svn
    
    * tool/vcs.rb (VCS.local_path?): predicate that the argument is a
      local path.
    
    * tool/vcs.rb (VCS::SVN.search_root): extract a method to search
      working root directory.

  Modified files:
    trunk/tool/vcs.rb
Index: tool/vcs.rb
===================================================================
--- tool/vcs.rb	(revision 49354)
+++ tool/vcs.rb	(revision 49355)
@@ -61,6 +61,10 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L61
     raise VCS::NotFoundError, "does not seem to be under a vcs: #{path}"
   end
 
+  def self.local_path?(path)
+    String === path or path.respond_to?(:to_path)
+  end
+
   def initialize(path)
     @srcdir = path
     super()
@@ -72,7 +76,7 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L76
   # return a pair of strings, the last revision and the last revision in which
   # +path+ was modified.
   def get_revisions(path)
-    if String === path or path.respond_to?(:to_path)
+    if self.class.local_path?(path)
       path = relative_to(path)
     end
     last, changed, modified, *rest = (
@@ -130,7 +134,7 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L134
     register(".svn")
 
     def self.get_revisions(path, srcdir = nil)
-      if srcdir and (String === path or path.respond_to?(:to_path))
+      if srcdir and local_path?(path)
         path = File.join(srcdir, path)
       end
       if srcdir
@@ -144,6 +148,15 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L148
       [last, changed, modified, branch]
     end
 
+    def self.search_root(path)
+      return unless local_path?(path)
+      parent = File.realpath(path)
+      begin
+        parent = File.dirname(wkdir = parent)
+        return wkdir if File.directory?(wkdir + "/.svn")
+      end until parent == wkdir
+    end
+
     def get_info
       @info ||= IO.pread(%W"svn info --xml #{@srcdir}")
     end
@@ -160,18 +173,7 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L173
       unless @wcroot
         info = get_info
         @wcroot = info[/<wcroot-abspath>(.*)<\/wcroot-abspath>/, 1]
-        unless @wcroot
-          begin
-            parent = File.realpath(@srcdir)
-            begin
-              parent = File.dirname(wkdir = parent)
-              if File.directory?(wkdir + "/.svn")
-                break @wcroot = wkdir
-              end
-            end until parent == wkdir
-          rescue TypeError
-          end
-        end
+        @wcroot ||= self.class.search_root(@srcdir)
       end
       @wcroot
     end

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

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