mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
6c68a3edfa
commit
b448b79217
1 changed files with 16 additions and 14 deletions
30
tool/vcs.rb
30
tool/vcs.rb
|
@ -61,6 +61,10 @@ class VCS
|
||||||
raise VCS::NotFoundError, "does not seem to be under a vcs: #{path}"
|
raise VCS::NotFoundError, "does not seem to be under a vcs: #{path}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.local_path?(path)
|
||||||
|
String === path or path.respond_to?(:to_path)
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(path)
|
def initialize(path)
|
||||||
@srcdir = path
|
@srcdir = path
|
||||||
super()
|
super()
|
||||||
|
@ -72,7 +76,7 @@ class VCS
|
||||||
# return a pair of strings, the last revision and the last revision in which
|
# return a pair of strings, the last revision and the last revision in which
|
||||||
# +path+ was modified.
|
# +path+ was modified.
|
||||||
def get_revisions(path)
|
def get_revisions(path)
|
||||||
if String === path or path.respond_to?(:to_path)
|
if self.class.local_path?(path)
|
||||||
path = relative_to(path)
|
path = relative_to(path)
|
||||||
end
|
end
|
||||||
last, changed, modified, *rest = (
|
last, changed, modified, *rest = (
|
||||||
|
@ -130,7 +134,7 @@ class VCS
|
||||||
register(".svn")
|
register(".svn")
|
||||||
|
|
||||||
def self.get_revisions(path, srcdir = nil)
|
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)
|
path = File.join(srcdir, path)
|
||||||
end
|
end
|
||||||
if srcdir
|
if srcdir
|
||||||
|
@ -144,6 +148,15 @@ class VCS
|
||||||
[last, changed, modified, branch]
|
[last, changed, modified, branch]
|
||||||
end
|
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
|
def get_info
|
||||||
@info ||= IO.pread(%W"svn info --xml #{@srcdir}")
|
@info ||= IO.pread(%W"svn info --xml #{@srcdir}")
|
||||||
end
|
end
|
||||||
|
@ -160,18 +173,7 @@ class VCS
|
||||||
unless @wcroot
|
unless @wcroot
|
||||||
info = get_info
|
info = get_info
|
||||||
@wcroot = info[/<wcroot-abspath>(.*)<\/wcroot-abspath>/, 1]
|
@wcroot = info[/<wcroot-abspath>(.*)<\/wcroot-abspath>/, 1]
|
||||||
unless @wcroot
|
@wcroot ||= self.class.search_root(@srcdir)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
@wcroot
|
@wcroot
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue