Revision: 47424
Updated Code
at June 8, 2011 01:35 by jigante
Updated Code
<?php if (count($argv) !== 4) { die("Usage: svnforeigncopy from-repo-url to-repo-url local-checkout-dir\n"); } $from = $argv[1]; $to = $argv[2]; $local = $argv[3]; echo("Creating $to\n"); mysystem("svn mkdir --parents " . escapeshellarg($to)); echo("Checking out $to\n"); mysystem("svn co " . escapeshellarg($to) . " " . escapeshellarg($local)); echo("Exporting non-external content of $from to $local\n"); mysystem("svn export --force --ignore-externals " . escapeshellarg($from) . " " . escapeshellarg($local)); echo("Checking out $from to $local.tmp without externals so that we can do efficient recursive propgets\n"); mysystem("svn co --ignore-externals " . escapeshellarg($from) . " " . escapeshellarg("$local.tmp")); echo("Querying svn:externals properties of $from\n"); $externals = simplexml_load_string(stream_get_contents(popen("svn propget --xml --recursive svn:externals " . escapeshellarg("$local.tmp"), "r"))); echo("Querying svn:ignore properties of $from\n"); $ignores = simplexml_load_string(stream_get_contents(popen("svn propget --xml --recursive svn:ignore " . escapeshellarg("$local.tmp"), "r"))); echo("Adding $local contents (necessary before externals can be set)\n"); mysystem("cd " . escapeshellarg($local) . "; svn add *; cd .."); echo("Applying externals\n"); applyProperties($externals); echo("Applying ignores\n"); applyProperties($ignores); echo("Removing $local.tmp"); mysystem("rm -rf " . escapeshellarg("$local.tmp")); echo("Committing $local\n"); mysystem("svn commit " . escapeshellarg($local)); echo("Updating $local\n"); mysystem("svn update " . escapeshellarg($local)); echo("Done!\n"); function applyProperties($properties) { global $local; foreach ($properties->target as $target) { $path = $target['path']; $path = str_replace("$local.tmp/", "", $path); foreach ($target->property as $property) { $name = $property['name']; $value = (string) $property; mysystem("svn propset " . escapeshellarg($name) . " " . escapeshellarg($value) . " " . escapeshellarg("$local/$path")); } } } function mysystem($cmd) { passthru($cmd, $val); if ($val != 0) { die("Command $cmd exited with nonzero exit status $val\n"); } }
Revision: 47423
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 8, 2011 01:34 by jigante
Initial Code
Initial URL
Initial Description
Initial Title
Apostrophe SVN Foreign Copy
Initial Tags
svn, textmate
Initial Language
PHP