summaryrefslogtreecommitdiff
path: root/tool/file2lastrev.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-02 13:14:24 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-02 13:14:24 +0000
commitc093401b0e81f3b6d58a623f75a77a90f6e86fcb (patch)
treec92550b2a4cd42a68390c13c692fb25c5aac9e56 /tool/file2lastrev.rb
parent432a992aafc6756a02963629f49ff26b1489ddc8 (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/file2lastrev.rb')
-rwxr-xr-xtool/file2lastrev.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb
index 2965d21..90816ae 100755
--- a/tool/file2lastrev.rb
+++ b/tool/file2lastrev.rb
@@ -22,8 +22,15 @@ class VCS
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 = OptionParser.new {|opts|
}
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