The Real Adam Master of rectangles

Posted
19 March 2008 @ 2pm

In
Code, Tumblin'

Fix Subversion conflicts

Got a case where you did a svn up and now you have a bunch of conflicts where you just want to overwrite your changes? I’ve got a little bit of Ruby cleverness for you:


  `svn status`.split("\n").grep(/^C/).map { |c| c.scan(/\S+/).last }.each { |c| `svn cat #{c} > #{c} && svn resolved #{c}` }

I run this from irb at the root of my Subversion working directory. It makes me happy.

Update: lord that looks ugly on one line!


  status = `svn status`.split("\n")
  conflicts = status.grep(/^C/)
  files = conflicts.map { |c| c.scan(/\S+/).last }
  conflicts.each do |c| 
    `svn cat #{c} > #{c} && svn resolved #{c}`
  end

1 Comment

Posted by
Marc-André Cournoyer
19 March 2008 @ 6pm

You can do this by reverting too I think:

ruby -e ‘`svn st`.scan(/^C\s+(.*)/){|f| `svn revert #{f}`}’

or just: svn -R revert . to revert all


Leave a Comment

Comments will be sent to the moderation queue.

Keep your pants on Write a script in April for Script Frenzy

Flickr View All » FredRubyConf Notes #3RubyConf Notes #2RubyConf Notes #1RubyConf Notes #0Dogs in the morningMy Day, YesterdayGetting aroundMolly lounging