Created
January 8, 2016 09:08
-
-
Save miau/e4416ace4fe294f9b73f to your computer and use it in GitHub Desktop.
A script to replace svn:log property of revisions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "tempfile" | |
require "rexml/document" | |
REVISION_FROM = "86678" | |
REVISION_TO = "HEAD" | |
REGEX = /#19358/ | |
REPLACE = "#18958" | |
xml = `svn log -r#{REVISION_FROM}:#{REVISION_TO} --xml` | |
doc = REXML::Document.new xml | |
doc.elements.each("log/logentry") do |element| | |
rev = element.attribute("revision") | |
msg = element.elements["msg"].text | |
# puts "#{rev} #{msg}" | |
next unless msg.match(REGEX) | |
new_msg = msg.gsub(REGEX, REPLACE) | |
temp = Tempfile.new('replace_svn_log', :encoding => "UTF-8") | |
temp.write new_msg | |
temp.close | |
command = %<svn propset --revprop -r#{rev} svn:log -F "#{temp.path}" --encoding UTF-8> | |
puts command | |
system(command) | |
# break | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment