[svk-commit] r2178 - in trunk: lib/SVK lib/SVK/Command t

clkao at bestpractical.com clkao at bestpractical.com
Sat Nov 18 18:46:59 EST 2006


Author: clkao
Date: Sat Nov 18 18:46:59 2006
New Revision: 2178

Added:
   trunk/t/77floating.t
Modified:
   trunk/MANIFEST
   trunk/lib/SVK/Command/Checkout.pm
   trunk/lib/SVK/Test.pm

Log:
Fix floating checkout which was broken with the lock overhaul.
Also make sure the regression tests are there this time.


Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	(original)
+++ trunk/MANIFEST	Sat Nov 18 18:46:59 2006
@@ -264,6 +264,7 @@
 t/74view.t
 t/75hook.t
 t/76ignore.t
+t/77floating.t
 t/api/mirror.t
 t/copy-escape.t
 t/copy-replace.t

Modified: trunk/lib/SVK/Command/Checkout.pm
==============================================================================
--- trunk/lib/SVK/Command/Checkout.pm	(original)
+++ trunk/lib/SVK/Command/Checkout.pm	Sat Nov 18 18:46:59 2006
@@ -95,7 +95,7 @@
 			     depotmap => { $depotname => $depotpath },
 			     floating => $copath,
 			   );
-
+	$xd->giant_lock;
 	my $magic = catfile($svkpath, 'floating');
 	open my $magic_fh, '>', $magic or die $!;
 	print $magic_fh "This is an SVK floating checkout.";

Modified: trunk/lib/SVK/Test.pm
==============================================================================
--- trunk/lib/SVK/Test.pm	(original)
+++ trunk/lib/SVK/Test.pm	Sat Nov 18 18:46:59 2006
@@ -164,6 +164,7 @@
 
     my $svkpath = File::Spec->catfile($directory, '.svk');
     my $xd = SVK::XD->new (statefile => File::Spec->catfile($svkpath, 'config'),
+			   giantlock => File::Spec->catfile($svkpath, 'lock'),
 			   svkpath => $svkpath,
 			   floating => $directory);
     $xd->load;

Added: trunk/t/77floating.t
==============================================================================
--- (empty file)
+++ trunk/t/77floating.t	Sat Nov 18 18:46:59 2006
@@ -0,0 +1,57 @@
+#!/usr/bin/perl -w
+use Test::More tests => 12;
+use strict;
+use SVK::Test;
+
+my ($basexd, $basesvk) = build_test();
+our $output;
+my ($copath, $corpath) = get_copath ('floating');
+
+is_output($basesvk, 'checkout', ['--floating', '//', $copath], [
+        "Syncing //(/) in $corpath to 0.", ]);
+ok(-e $copath, 'floating checkout');
+ok(-e "$copath/.svk/floating", 'checkout is floating');
+ok(-e "$copath/.svk/config", 'config file exists');
+
+my ($xd, $svk) = build_floating_test($corpath);
+
+mkdir "$copath/A";
+overwrite_file ("$copath/A/foo", "foobar");
+$svk->add ("$copath/A");
+$svk->commit ('-m', 'commit message here', "$copath");
+
+is_output($svk, 'checkout', ['--list'], [
+            "  Depot Path                    \tPath",
+            "========================================================================",
+            "  //                            \t$corpath",
+	    ], 'one checkout in list');
+
+ok(exists $xd->{checkout}->get($corpath)->{revision}, 'xd is absolute');
+my $ref = $xd->{checkout}->{hash};
+my @ref = each %$ref;
+ok(! exists $xd->{checkout}->get("A/foo")->{revision}, 'xd is not relative');
+
+use YAML::Syck;
+my $loaded = LoadFile("$copath/.svk/config");
+ok(ref($loaded->{checkout}) eq "Data::Hierarchy::Relative",
+   'stored config is relative');
+my $checkout = $loaded->{checkout}->to_absolute('/nowhere');
+ok(exists $checkout->get("/nowhere/A/foo")->{revision}, 'relative lookup');
+
+my ($copath2, $corpath2) = get_copath ('floating2');
+rename ($corpath, $corpath2);
+($xd, $svk) = build_floating_test($corpath2);
+
+is_output($svk, 'checkout', ['--list'], [
+            "  Depot Path                    \tPath",
+            "========================================================================",
+            "  //                            \t$corpath2",
+	    ], 'checkout in list changed');
+is_output($svk, 'status', [$corpath2], [], 'clean status');
+overwrite_file ("$copath2/A/foo", "barfoo");
+overwrite_file ("$copath2/A/other", "text");
+$svk->add("$copath2/A/other");
+$svk->commit("-m", "Some message", "$copath2/A/other");
+is_output_like($svk, 'log', [$corpath2], qr/Some message/);
+
+1;


More information about the svk-commit mailing list