rendered paste body#!/usr/bin/perl
# Created:20070613
# By Jeff Connelly
#
# Emulate svn rm --keep-local
#
use File::Basename;
our ($svn) = "sudo svn";
our ($tmp) = "/tmp/svn-unversion";
our ($log);
mkdir($tmp);
sub modified_files
{
my (@mods);
while(`$svn status` =~ m/^M\s+(.*)/gm)
{
push @mods, $1;
}
return @mods;
}
sub unversion
{
my ($file) = @_;
my ($tmp_file) = "$tmp/" . basename($file);
print "«" . (" " x 10) . "$file\n";
system("mv", $file, $tmp_file);
die "couldn't move $file to $tmp_file (out of the way): $?" if $?;
system("$svn rm $file");
die "couldn't svn rm $file: $?" if $?;
print "»" . (" " x 10) . "$file\n";
system("mv", "$tmp_file", $file);
die "couldn't move $tmp_file to $file (restore): $?" if $?;
$log .= "$file\n";
}
if (!@ARGV)
{
print <<EOT;
usage: $0 [-m | files-to-unversion]
-m: unversions all modified files
Otherwise, each parameter is taken as a filename to unversion.
EOT
exit(-1);
} elsif ($ARGV[0] eq "-m") {
for (modified_files())
{
unversion($_);
}
} else {
for (@ARGV)
{
unversion($_);
}
}
system("$svn commit")