Wednesday, August 30, 2006

svn merge hell!

svn: REPORT request failed on '/svn/rhg/!svn/vcc/default'
svn: Working copy path 'path/to/afile/in/your/project/a_file_that_is_broken' does not exist in repository


If you've ever seen this error you've probably resorted to 'rm -rf'

Thanks to some of the great minds of revolution we have a simple fix that involves editing the .svn/entries file and locating an incorrect attribute revision="0"

And to automate this I wrote a little ruby script. It uses libxml-ruby because I wanted to get fimilar with the API, which thankfully is very similar to the C API.

Note: This only applies to subversion 1.3 client, the newer 1.4 client does not generate xml property files.
#!/usr/bin/env ruby
require 'find'
require 'pathname'
require 'rubygems'

require 'xml/libxml'
# going to search through all the folders in the current project
# and locate all .svn/entries files. Parse each file looking for
# bad entries
# a bad entry is defined as
# any entry with a revision="0"

# that is not scheduled="add"


def start_doc
end

def start_element(name,attrs, entry_path)

if( name == "entry" && attrs["revision"] == "0" && attrs["schedule"] != "add" )

puts "Potential Error in #{entry_path}"
end
end

def end_element(name)

end

def chars
end
def comments
end


subversion_folder = /\.svn$/i

root_path = Pathname.new(".").realpath
Find.find(root_path) do |file_name|

if subversion_folder.match(file_name)
Find.find(file_name) do |sub_file|

entry_file = File.basename(sub_file)
if entry_file == "entries"

entry_path = "#{file_name}/#{entry_file}"
parser = XML::SaxParser.new

parser.on_start_element {|name,attrs| start_element( name, attrs, entry_path ) }

parser.on_end_element {|name| end_element(name) }
parser.filename = entry_path

parser.parse
break
end
end
end

end

0 comments:

Reading list