From b448b79217a75b6198ae13c7ce715e68cfc522f5 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 20 Jan 2015 14:43:30 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/vcs.rb | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tool/vcs.rb b/tool/vcs.rb index 72201a598d..361e11b78e 100644 --- a/tool/vcs.rb +++ b/tool/vcs.rb @@ -61,6 +61,10 @@ class VCS 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 # 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 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 [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 unless @wcroot info = get_info @wcroot = info[/(.*)<\/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