Over a million developers have joined DZone.

Resolve All SVN Conflicts With The Right Version Of The File

·
This small PHP shell script recourses through the subdirectories and looks for files that match the "conflict" files that SVN creates when merging from another branch. It chooses the "right" version of the files and resolves the conflict.



$dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("."));
foreach($dir as $file)
{
  $path = $file->getPathname();
  if (preg_match('/\.merge-right\.r\d+$/', $path, $matches)) {
    $orig = str_replace($matches[0], '' , $path);
    copy($path, $orig);
    $cmd = "svn resolved $orig";
    `$cmd`;
  }
}
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}