[svk-commit] r2165 - in trunk: lib/SVK/Mirror/Backend t/mirror

clkao at bestpractical.com clkao at bestpractical.com
Sat Nov 18 00:41:35 EST 2006


Author: clkao
Date: Sat Nov 18 00:41:34 2006
New Revision: 2165

Added:
   trunk/t/mirror/relocate.t
Modified:
   trunk/MANIFEST
   trunk/lib/SVK/Mirror/Backend/SVNRa.pm

Log:
Check source_path when doing relocate.

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	(original)
+++ trunk/MANIFEST	Sat Nov 18 00:41:34 2006
@@ -267,6 +267,7 @@
 t/copy-escape.t
 t/copy-replace.t
 t/mirror/dav-authz.t
+t/mirror/relocate.t
 t/mirror/sync-crazy-replace.t
 t/mirror/sync-empty.t
 t/mirror/sync-escape.t

Modified: trunk/lib/SVK/Mirror/Backend/SVNRa.pm
==============================================================================
--- trunk/lib/SVK/Mirror/Backend/SVNRa.pm	(original)
+++ trunk/lib/SVK/Mirror/Backend/SVNRa.pm	Sat Nov 18 00:41:34 2006
@@ -173,6 +173,15 @@
     my $mirror = $self->mirror;
     die loc("Mirror source UUIDs differ.\n")
 	unless $ra_uuid eq $mirror->server_uuid;
+    my $source_root = $ra->get_repos_root;
+    my $source_path = $source;
+    die "source url not under source root"
+	if substr($source_path, 0, length($source_root), '') ne $source_root;
+
+    die loc( "Can't relocate: mirror subdirectory changed from %1 to %2.\n",
+        $self->source_path, $source_path )
+        unless $self->source_path eq $source_path;
+
     $self->source_root( $ra->get_repos_root );
     $mirror->url($source);
 

Added: trunk/t/mirror/relocate.t
==============================================================================
--- (empty file)
+++ trunk/t/mirror/relocate.t	Sat Nov 18 00:41:34 2006
@@ -0,0 +1,32 @@
+#!/usr/bin/perl -w
+use strict;
+use Test::More;
+use SVK::Test;
+use SVK::Util qw(HAS_SYMLINK);
+
+plan(skip_all => 'symlink not supported') if !HAS_SYMLINK;
+plan tests => 3;
+
+my ($xd, $svk) = build_test('test', 'test2');
+my ($copath, $corpath) = get_copath ('sync-replicate');
+
+our $output;
+
+my $tree = create_basic_tree ($xd, '/test/');
+
+my ($srepospath, $spath, $srepos) = $xd->find_repos('/test/A', 1);
+my ($srepospath2) = $xd->find_repos('/test2/A', 1);
+rmtree [$srepospath2];
+symlink($srepospath, $srepospath2);
+
+my $uri = uri($srepospath.($spath eq '/' ? '' : $spath));
+my $uri2 = uri($srepospath);
+
+is_output($svk, mirror => ['//m', $uri],
+          ["Mirror initialized.  Run svk sync //m to start mirroring."]);
+
+is_output($svk, 'mirror', ['--relocate', '//m', "$uri2/B"],
+	  ["Can't relocate: mirror subdirectory changed from /A to /B."]);
+
+is_output($svk, 'mirror', ['--relocate', '//m', "$uri2/A"],
+	  ['Mirror relocated.']);


More information about the svk-commit mailing list