background image
HomeRecent PostsDrupalSearchTagsRSSContactAboutAccount

How to get around the error "object of the same name already exists" when doing an svn update

Eric.London's picture

I recently had to deploy some new code to an old production environment. Like a good doobie, I made all my changes in a local checked out copy of the subversion file system. I did not want to break the production environment, so I copied the entire vhost into my home directory on the server. I tried to execute an svn update command, but it terminated with the message: object of the same name already exists. This means that a file was creating in my development environment (later revision) that was also created in the production environment. When I ran a svn stat command, there were too many additions, deletions, and modifications, so I decided to write a PHP script to compare the directory structure and files of the 2 environments. I used this script to analyze the file system and create a deployment plan...

<?php
// define where all my files are
$path_httpdocs = '/my/first/path/httpdocs';
$path_httpdocs_new = '/my/second/path/httpdocs';

// get a list of files from the 1st location, ignoring subversion folders
chdir($path_httpdocs);
$files_httpdocs = `find . | grep -v \.svn | sort`;
$files_httpdocs = explode("\n", $files_httpdocs);

// get a list of files from the 2nd location, ignoring subversion folders
chdir($path_httpdocs_new);
$files_httpdocs_new = `find . | grep -v \.svn | sort`;
$files_httpdocs_new = explode("\n", $files_httpdocs_new);

// check for file list diffs
$diffs = array_diff($files_httpdocs, $files_httpdocs_new);
sort($diffs);
echo
"### Additions to httpdocs:\n";
print_r($diffs);

// loop through files and check if they are additions
foreach ($diffs as $f) {
  if (
file_exists($path_httpdocs . '/' . $f) && !file_exists($path_httpdocs_new . '/' . $f)) {
   
// copy new addition to new folder
   
copy($path_httpdocs . '/' . $f, $path_httpdocs_new .'/' . $f);
  }
}

// check for file list diffs
$diffs = array_diff($files_httpdocs_new, $files_httpdocs);
sort($diffs);
echo
"### Additions to httpdocs_new:\n";
print_r($diffs);

// do not continue if there are file differences in the 2 directories
if (count(array_diff($files_httpdocs, $files_httpdocs_new)) || count(array_diff($files_httpdocs_new, $files_httpdocs))) {
  echo
"### Clean up file differences before continuing...\n";
  die;
}

// loop through files and check file properties
$diffs = array();
foreach (
$files_httpdocs as $f) {
  if (!
is_file($path_httpdocs . '/' . $f)) continue;

 
// do a diff on the files 
 
$command = "diff \"$path_httpdocs/$f\" \"$path_httpdocs_new/$f\"";
 
$t = `$command`;

 
// if the diff command generated output, store it
 
if (strlen($t)) {
   
$diffs[$f] = $t;
  }

}

// print all the file diffs
print_r($diffs);
?>