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

ruby-changes:15222

From: nobu <ko1@a...>
Date: Tue, 30 Mar 2010 13:01:36 +0900 (JST)
Subject: [ruby-changes:15222] Ruby:r27104 (trunk): * tool/file2lastrev.rb (VCS#get_revisions): particular commands do

nobu	2010-03-30 13:01:17 +0900 (Tue, 30 Mar 2010)

  New Revision: 27104

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

  Log:
    * tool/file2lastrev.rb (VCS#get_revisions): particular commands do
      not depend on instance.

  Modified files:
    trunk/ChangeLog
    trunk/tool/file2lastrev.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27103)
+++ ChangeLog	(revision 27104)
@@ -1,3 +1,8 @@
+Tue Mar 30 13:01:10 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* tool/file2lastrev.rb (VCS#get_revisions): particular commands do
+	  not depend on instance.
+
 Tue Mar 30 08:55:50 2010  Aaron Patterson <aaron@t...>
 
 	* ext/psych/extconf.rb: Making library detection more agnostic.
Index: tool/file2lastrev.rb
===================================================================
--- tool/file2lastrev.rb	(revision 27103)
+++ tool/file2lastrev.rb	(revision 27104)
@@ -24,16 +24,17 @@
 
   def initialize(path)
     @srcdir = path
+    super()
   end
 
   # return a pair of strings, the last revision and the last revision in which
   # +path+ was modified.
   def get_revisions(path)
     path = relative_to(path)
-    last, changed = Dir.chdir(@srcdir) {yield path}
+    last, changed, *rest = Dir.chdir(@srcdir) {self.class.get_revisions(path)}
     last or raise "last revision not found"
     changed or raise "changed revision not found"
-    return last, changed
+    return last, changed, *rest
   end
 
   def relative_to(path)
@@ -43,37 +44,32 @@
   class SVN < self
     register(".svn")
 
-    def get_revisions(*)
-      super do |path|
-        info_xml = `svn info --xml "#{path}"`
-        _, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
-        [last, changed]
-      end
+    def self.get_revisions(path)
+      info_xml = `svn info --xml "#{path}"`
+      _, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
+      [last, changed]
     end
   end
 
   class GIT_SVN < self
     register(".git/svn")
 
-    def get_revisions(*)
-      super do |path|
-        info = `git svn info "#{path}"`
-        [info[/^Revision: (\d+)/, 1], info[/^Last Changed Rev: (\d+)/, 1]]
-      end
+    def self.get_revisions(path)
+      lastlog = `git log -n1`
+      info = `git svn info "#{path}"`
+      [info[/^Revision: (\d+)/, 1], info[/^Last Changed Rev: (\d+)/, 1]]
     end
   end
 
   class GIT < self
     register(".git")
 
-    def get_revisions(*)
+    def self.get_revisions(path)
       logcmd = %Q[git log -n1 --grep="^ *git-svn-id: .*@[0-9][0-9]* "]
       idpat = /git-svn-id: .*?@(\d+) \S+\Z/
-      super do |path|
-        last = `#{logcmd}`[idpat, 1]
-        changed = path ? `#{logcmd} "#{path}"`[idpat, 1] : last
-        [last, changed]
-      end
+      last = `#{logcmd}`[idpat, 1]
+      changed = path ? `#{logcmd} "#{path}"`[idpat, 1] : last
+      [last, changed]
     end
   end
 end

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

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