summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-30 07:53:22 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-30 07:53:22 +0000
commit99c8ded878ba60391fb5439a2b17adefa607a3dd (patch)
tree6bc08bed48b0eba850123ca99b493eb11bf543b9
parentfd8323072678d42891f097e2992189ae27cfcf5f (diff)
* tool/file2lastrev.rb: get rid of global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--tool/file2lastrev.rb26
2 files changed, 17 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 6ca76ff..a813924 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
-Tue Jun 30 16:48:49 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Jun 30 16:53:17 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * tool/file2lastrev.rb: get rid of global variables.
* tool/compile_prelude.rb: use US-ASCII name.
diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb
index ddc83e8..e913783 100644
--- a/tool/file2lastrev.rb
+++ b/tool/file2lastrev.rb
@@ -48,25 +48,27 @@ def get_revisions(path)
return last, changed
end
-def raise_if_conflict
- raise "you can specify only one of --changed, --revision.h and --doxygen" if $output
+@output = nil
+def self.output=(output)
+ if @output and @output != output
+ raise "you can specify only one of --changed, --revision.h and --doxygen"
+ end
+ @output = output
end
+@suppress_not_found = false
parser = OptionParser.new {|opts|
opts.on("--changed", "changed rev") do
- raise_if_conflict
- $output = :changed
+ self.output = :changed
end
opts.on("--revision.h") do
- raise_if_conflict
- $output = :revision_h
+ self.output = :revision_h
end
opts.on("--doxygen") do
- raise_if_conflict
- $output = :doxygen
+ self.output = :doxygen
end
opts.on("-q", "--suppress_not_found") do
- $suppress_not_found = true
+ @suppress_not_found = true
end
}
parser.parse!
@@ -75,10 +77,10 @@ parser.parse!
begin
last, changed = get_revisions(ARGV.shift)
rescue VCSNotFoundError
- raise unless $suppress_not_found
+ raise unless @suppress_not_found
end
-case $output
+case @output
when :changed, nil
puts changed
when :revision_h
@@ -86,5 +88,5 @@ when :revision_h
when :doxygen
puts "r#{changed}/r#{last}"
else
- raise "unknown output format `#{$output}'"
+ raise "unknown output format `#{@output}'"
end