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

ruby-changes:58100

From: Nobuyoshi <ko1@a...>
Date: Thu, 3 Oct 2019 19:23:38 +0900 (JST)
Subject: [ruby-changes:58100] b7ae26e2ee (master): vcs.rb: fix to export git-svn version

https://git.ruby-lang.org/ruby.git/commit/?id=b7ae26e2ee

From b7ae26e2eec9efb826e4a2d913a67341531c6342 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 3 Oct 2019 16:47:05 +0900
Subject: vcs.rb: fix to export git-svn version

* Use the given branch name instead of implicit 'HEAD".
* Format like as git-svn when `from` or `to` is SVN revision
  number.

diff --git a/tool/lib/vcs.rb b/tool/lib/vcs.rb
index 924dfe3..370530d 100644
--- a/tool/lib/vcs.rb
+++ b/tool/lib/vcs.rb
@@ -590,13 +590,15 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L590
     def branch_beginning(url)
       cmd_read(%W[ #{COMMAND} log -n1 --format=format:%H
                    --author=matz --committer=matz --grep=has\ started
-                   -- version.h include/ruby/version.h])
+                   #{url.to_str} -- version.h include/ruby/version.h])
     end
 
     def export_changelog(url, from, to, path)
+      svn = nil
       from, to = [from, to].map do |rev|
         rev or next
         if Integer === rev
+          svn = true
           rev = cmd_read({'LANG' => 'C', 'LC_ALL' => 'C'},
                          %W"#{COMMAND} log -n1 --format=format:%H" <<
                          "--grep=^ *git-svn-id: .*@#{rev} ")
@@ -607,17 +609,21 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L609
         warn "no starting commit found", uplevel: 1
         from = nil
       end
-      unless system(*%W"#{COMMAND} fetch origin refs/notes/commits:refs/notes/commits",
-                    chdir: @srcdir, exception: false)
+      unless svn or system(*%W"#{COMMAND} fetch origin refs/notes/commits:refs/notes/commits",
+                           chdir: @srcdir, exception: false)
         abort "Could not fetch notes/commits tree"
       end
-      to ||= 'HEAD'
+      to ||= url.to_str
       if from
         arg = ["#{from}^..#{to}"]
       else
         arg = ["--since=25 Dec 00:00:00", to]
       end
-      format_changelog(path, arg)
+      if svn
+        format_changelog_as_svn(path, arg)
+      else
+        format_changelog(path, arg)
+      end
     end
 
     def format_changelog(path, arg)
@@ -632,6 +638,27 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L638
       system(env, *cmd, chdir: @srcdir, out: path)
     end
 
+    def format_changelog_as_svn(path, arg)
+      cmd = %W"#{COMMAND} log --topo-order --no-notes -z --format=%an%n%at%n%B"
+      cmd.concat(arg)
+      open(path, 'w') do |w|
+        sep = "-"*72 + "\n"
+        w.print sep
+        cmd_pipe(cmd) do |r|
+          while s = r.gets("\0")
+            s.chomp!("\0")
+            author, time, s = s.split("\n", 3)
+            s.sub!(/\n\ngit-svn-id: .*@(\d+) .*\n\Z/, '')
+            rev = $1
+            time = Time.at(time.to_i).getlocal("+09:00").strftime("%F %T %z (%a, %d %b %Y)")
+            lines = s.count("\n") + 1
+            lines = "#{lines} line#{lines == 1 ? '' : 's'}"
+            w.print "r#{rev} | #{author} | #{time} | #{lines}\n\n", s, "\n", sep
+          end
+        end
+      end
+    end
+
     def upstream
       (branch = cmd_read(%W"#{COMMAND} symbolic-ref --short HEAD")).chomp!
       (upstream = cmd_read(%W"#{COMMAND} branch --list --format=%(upstream) #{branch}")).chomp!
@@ -668,27 +695,6 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L695
       SVN.revision_name(rev)
     end
 
-    def format_changelog(path, arg)
-      cmd = %W"#{COMMAND} log --topo-order --no-notes -z --format=%an%n%at%n%B"
-      cmd.concat(arg)
-      open(path, 'w') do |w|
-        sep = "-"*72
-        w.puts sep
-        cmd_pipe(cmd) do |r|
-          while s = r.gets("\0")
-            s.chomp!("\0")
-            author, time, s = s.split("\n", 3)
-            s.sub!(/\n\ngit-svn-id: .*@(\d+) .*\n\Z/, '')
-            rev = $1
-            time = Time.at(time.to_i).getlocal("+09:00").strftime("%F %T %z (%a, %d %b %Y)")
-            lines = s.count("\n")
-            lines = "#{lines} line#{lines == 1 ? '' : 's'}"
-            w.puts "r#{rev} | #{author} | #{time} | #{lines}\n\n", s, sep
-          end
-        end
-      end
-    end
-
     def last_changed_revision
       rev = cmd_read(%W"#{COMMAND} svn info"+[STDERR=>[:child, :out]])[/^Last Changed Rev: (\d+)/, 1]
       com = cmd_read(%W"#{COMMAND} svn find-rev r#{rev}").chomp
-- 
cgit v0.10.2


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

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