[svk-commit] r2325 - in branches/2.0-releng: lib/SVK/Mirror/Backend
t/mirror
nobody at bestpractical.com
nobody at bestpractical.com
Wed Mar 14 19:51:19 EDT 2007
Author: clkao
Date: Wed Mar 14 19:51:17 2007
New Revision: 2325
Added:
branches/2.0-releng/t/mirror/sync-revhole.t
Modified:
branches/2.0-releng/MANIFEST
branches/2.0-releng/lib/SVK/Mirror/Backend/SVNRa.pm
Log:
Merge from trunk:
r2318 at trunk: clkao | 2007-03-08 16:42:34 +0000
When mirroring partial repository with copies, the from revision
number might not be exactly the ones we have mirrored. We should
seek back to use appropriate revision.
r2321 at trunk: clkao | 2007-03-11 20:40:20 +0000
Restore the old but arguably wrong behaviour when
find_rev_from_changeset fails to find rev.
r2322 at trunk: clkao | 2007-03-11 20:59:18 +0000
r2320 was incorrect.
Modified: branches/2.0-releng/MANIFEST
==============================================================================
--- branches/2.0-releng/MANIFEST (original)
+++ branches/2.0-releng/MANIFEST Wed Mar 14 19:51:17 2007
@@ -283,6 +283,7 @@
t/mirror/sync-replaced-nocopy.t
t/mirror/sync-replaced.t
t/mirror/sync-replicate.t
+t/mirror/sync-revhole.t
t/update-gone.t
t/svk-sec.gpg
t/svk.gpg
Modified: branches/2.0-releng/lib/SVK/Mirror/Backend/SVNRa.pm
==============================================================================
--- branches/2.0-releng/lib/SVK/Mirror/Backend/SVNRa.pm (original)
+++ branches/2.0-releng/lib/SVK/Mirror/Backend/SVNRa.pm Wed Mar 14 19:51:17 2007
@@ -373,18 +373,38 @@
=cut
sub find_rev_from_changeset {
- my ($self, $changeset) = @_;
+ my ($self, $changeset, $seekback) = @_;
my $t = $self->mirror->get_svkpath;
no warnings 'uninitialized'; # $s_changeset below may be undef
- return $t->search_revision
+ my $r = $t->search_revision
( cmp => sub {
my $rev = shift;
- my $search = $t->mclone(revision => $rev);
my $s_changeset = scalar $self->find_changeset($rev);
return $s_changeset <=> $changeset;
} );
+
+ return defined $r ? $r : () if $r || !$seekback;
+
+ my $result;
+ $r = $t->search_revision
+ ( cmp => sub {
+ my $rev = shift;
+
+ my $s_changeset = scalar $self->find_changeset($rev);
+
+ if ($s_changeset > $changeset) {
+ my $prev = $t->mclone(revision => $rev)->prev;
+ $result = $prev
+ if scalar $self->find_changeset($prev->revision) < $changeset;
+ }
+ return $s_changeset <=> $changeset;
+ } );
+
+ return unless $result;
+
+ return $result->revision;
}
=item find_changeset( $local_rev )
@@ -506,7 +526,7 @@
return $target->as_url(
1,
$self->mirror->path . $path,
- $self->find_rev_from_changeset($rev)
+ $self->find_rev_from_changeset($rev, 1)
);
}
);
Added: branches/2.0-releng/t/mirror/sync-revhole.t
==============================================================================
--- (empty file)
+++ branches/2.0-releng/t/mirror/sync-revhole.t Wed Mar 14 19:51:17 2007
@@ -0,0 +1,53 @@
+#!/usr/bin/perl -w
+use strict;
+use Test::More tests => 4;
+use SVK::Test;
+use SVN::Ra;
+use SVK::Mirror::Backend::SVNSync;
+
+my ($xd, $svk) = build_test('test');
+my $depot = $xd->find_depot('test');
+
+my ($copath, $corpath) = get_copath('sync-revhole');
+our $output;
+
+my ($srepospath, $spath, $srepos) = $xd->find_repos ('/test/A', 1);
+my $tree = create_basic_tree($xd, '/test/');
+
+my $uri = uri($srepospath.($spath eq '/' ? '' : $spath));
+
+is_output($svk, mirror => ['//A', $uri],
+ ["Mirror initialized. Run svk sync //A to start mirroring."]);
+waste_rev($svk, '/test/useless');
+
+$svk->co('/test/', $copath);
+
+append_file("$copath/A/Q/qu", "edited");
+$svk->ci(-m => 'change A qu', $copath);
+
+is_output($svk, sync => ['//A'],
+ ['Syncing '.$uri,
+ 'Retrieving log information from 1 to 5',
+ 'Committed revision 2 from revision 1.',
+ 'Committed revision 3 from revision 2.',
+ 'Committed revision 4 from revision 5.']);
+
+
+my $path = SVK::Path->real_new( { depot => $depot, path => '/A'})->refresh_revision;
+{
+ my $pool = SVN::Pool->new;
+ my ($editor) =
+ $path->get_editor( callback => sub { ok(1, 'committed with api') },
+ author => 'svktest', message => 'creating copy with revhole');
+ my $rb = $editor->open_root($path->revision);
+ $editor->close_file( $editor->add_file('qu-from-a', $rb, uri($srepospath."/A/Q/qu"), 4), undef);
+ $editor->close_directory($rb);
+ $editor->close_edit;
+}
+
+is_output($svk, sync => ['//A'],
+ ['Syncing '.$uri,
+ 'Retrieving log information from 6 to 6',
+ 'Committed revision 5 from revision 6.']);
+
+
More information about the svk-commit
mailing list