Skip to content

Instantly share code, notes, and snippets.

@miau
Created January 8, 2016 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miau/e4416ace4fe294f9b73f to your computer and use it in GitHub Desktop.
Save miau/e4416ace4fe294f9b73f to your computer and use it in GitHub Desktop.
A script to replace svn:log property of revisions
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