[svk-commit] r2477 - in branches/2.0-releng: lib/SVK t
nobody at bestpractical.com
nobody at bestpractical.com
Tue Jul 17 11:05:45 EDT 2007
Author: clkao
Date: Tue Jul 17 11:05:44 2007
New Revision: 2477
Added:
branches/2.0-releng/t/07smerge-rename3.t
Modified:
branches/2.0-releng/lib/SVK/Command/Smerge.pm
branches/2.0-releng/lib/SVK/Merge.pm
Log:
Merge from trunk:
r2350 at trunk: stig | 2007-03-21 15:48:06 +0000
Smerge tracks renames _only the first time_. For subsequent smerges changes to
the original is original. Hopefully somebody can sprinkle some magic pixie dust
over the code and make it pass without the TODO mark.
r2351 at trunk: stig | 2007-03-21 17:12:16 +0000
more tests
r2371 at trunk: clkao | 2007-03-28 07:34:34 -0400
r8840 at ubuntu: clkao | 2007-03-28 10:37:16 +0100
Don't forget about rename on dst when doing smerge again with
--track-renames.
Modified: branches/2.0-releng/lib/SVK/Command/Smerge.pm
==============================================================================
--- branches/2.0-releng/lib/SVK/Command/Smerge.pm (original)
+++ branches/2.0-releng/lib/SVK/Command/Smerge.pm Tue Jul 17 11:05:44 2007
@@ -58,7 +58,7 @@
sub options {
($_[0]->SUPER::options,
- 'B|baseless' => 'baseless',
+ 'B|baseless' => 'baseless',
'b|base=s' => 'merge_base',
'baserev=i' => 'rev',
);
Modified: branches/2.0-releng/lib/SVK/Merge.pm
==============================================================================
--- branches/2.0-releng/lib/SVK/Merge.pm (original)
+++ branches/2.0-releng/lib/SVK/Merge.pm Tue Jul 17 11:05:44 2007
@@ -463,7 +463,24 @@
print "Collecting renames, this might take a while.\n";
$self->_collect_rename_for($renamed, $self->{base}, $base, 0)
unless $self->{track_rename} eq 'dst';
- $self->_collect_rename_for($renamed, $self->{dst}, $base, 1);
+
+ { # different base lookup logic for smerge
+ if ($self->{track_rename} eq 'dst') {
+ my $usrc = $self->{src}->universal;
+ my $dstkey = $self->{dst}->universal->ukey;
+ my $srcinfo = $self->merge_info_with_copy($self->{src}->new);
+
+ use Data::Dumper;
+ if ($srcinfo->{$dstkey}) {
+ $base = $srcinfo->{$dstkey}->local($self->{src}->depot);
+ }
+ else {
+ $base = $base->mclone(revision => 0);
+ }
+ }
+ $self->_collect_rename_for($renamed, $self->{dst}, $base, 1);
+ }
+
return $editor unless @$renamed;
my $rename_editor = SVK::Editor::Rename->new (editor => $editor, rename_map => $renamed);
Added: branches/2.0-releng/t/07smerge-rename3.t
==============================================================================
--- (empty file)
+++ branches/2.0-releng/t/07smerge-rename3.t Tue Jul 17 11:05:44 2007
@@ -0,0 +1,149 @@
+#!/usr/bin/perl -w
+
+#
+# Tests that smerge handles updates after renames have been made
+#
+
+use Test::More tests => 11;
+use strict;
+use File::Path;
+use Cwd;
+use SVK::Test;
+
+my ($xd, $svk) = build_test();
+our ($answer, $output);
+my ($co_trunk_rpath, $co_trunk_path) = get_copath ('smerge-rename3-trunk');
+my ($co_branch_rpath, $co_branch_path) = get_copath ('smerge-rename3-branch');
+my ($repospath, undef, $repos) = $xd->find_repos ('//', 1);
+my $uuid = $repos->fs->get_uuid;
+
+# Setup the trunk
+$svk->mkdir ('-m', 'trunk', '//trunk');
+$svk->checkout ('//trunk', $co_trunk_path);
+
+# Create some data in trunk
+chdir($co_trunk_path);
+$svk->mkdir('module');
+overwrite_file('module/test.txt', '1');
+$svk->add('module/test.txt');
+$svk->ci(-m => "test 1");
+
+# Make a copy
+$svk->mkdir ('-m', 'branches', '//branches');
+$svk->cp(-m => 'newbranch', '//trunk', '//branches/newbranch');
+$svk->checkout ('//branches/newbranch', $co_branch_path);
+is_file_content("$co_branch_path/module/test.txt", '1');
+
+# Rename the module in the branch
+chdir($co_branch_path);
+$svk->move('module', 'module2');
+$svk->commit(-m => "renamed");
+
+# Make a change to trunk
+chdir($co_trunk_path);
+overwrite_file('module/test.txt', '2');
+$svk->ci(-m => "test 2");
+
+# Merge changes w/rename from trunk to branch
+is_output ($svk, 'smerge', ['//trunk', '//branches/newbranch', '--track-rename', '-m', 'merge 1'], [
+ 'Auto-merging (2, 6) /trunk to /branches/newbranch (base /trunk:2).',
+ 'Collecting renames, this might take a while.',
+ 'U module/test.txt - module2/test.txt',
+ "New merge ticket: $uuid:/trunk:6",
+ 'Committed revision 7.',
+]);
+
+# Update the branch
+chdir($co_branch_path);
+$svk->update();
+is_file_content('module2/test.txt', '2');
+
+# Make another change to trunk
+chdir($co_trunk_path);
+overwrite_file('module/test.txt', '3');
+$svk->ci(-m => "test 3");
+
+
+# Merge changes w/rename from trunk to branch
+is_output ($svk, 'smerge', ['//trunk', '//branches/newbranch', '--track-rename', '-m', 'merge 2'], [
+ 'Auto-merging (6, 8) /trunk to /branches/newbranch (base /trunk:6).',
+ 'Collecting renames, this might take a while.',
+ 'U module/test.txt - module2/test.txt',
+ "New merge ticket: $uuid:/trunk:8",
+ 'Committed revision 9.',
+]);
+
+# Update the branch
+chdir($co_branch_path);
+$svk->update();
+is_file_content('module2/test.txt', '3');
+
+append_file('module2/test.txt', '4');
+$svk->ci(-m => "test 4");
+
+# Merge changes w/rename from trunk to branch
+# NOTE: This expected output might not be completely correct!
+
+#$answer = ['d', 's'];
+#$answer = 's'; # skip
+#$ENV{SVKRESOLVE} = 'd'; # diff
+TODO: {
+$TODO = "merging renamed change back should have proper base.";
+
+is_output ($svk, 'smerge', ['//branches/newbranch', '//trunk', '--track-rename', '-m', 'merge back'], [
+ 'Auto-merging (0, 10) /branches/newbranch to /trunk (base /trunk:8).',
+ 'Collecting renames, this might take a while.',
+ 'A + module2',
+ 'U module2/test.txt',
+ 'D module',
+ "New merge ticket: $uuid:/trunk:9",
+ 'Committed revision 9.',
+]);
+}
+
+TODO: {
+todo_skip 'not working', 5;
+
+chdir($co_trunk_path);
+$svk->update();
+is_file_content('module2/test.txt', '34');
+
+
+# adding a new dir on trunk
+$svk->mkdir('foo');
+overwrite_file('foo/test.txt', 'a');
+$svk->add('foo/test.txt');
+$svk->ci(-m => "new module added");
+
+# Merge changes w/rename from trunk to branch
+is_output ($svk, 'smerge', ['//trunk', '//branches/newbranch', '--track-rename', '-m', 'merge 3'], [
+ 'Auto-merging (6, 10) /trunk to /branches/newbranch (base /trunk:6).',
+ 'Collecting renames, this might take a while.',
+ 'A foo',
+ 'A foo/test.txt',
+ "New merge ticket: $uuid:/trunk:10",
+ 'Committed revision 11.',
+]);
+
+chdir($co_branch_path);
+$svk->update();
+is_file_content('foo/test.txt', 'a');
+
+$svk->move('foo', 'bar');
+overwrite_file('bar/test.txt', 'b');
+$svk->ci(-m => "test 6 - renamed and changed");
+
+is_output ($svk, 'smerge', ['//branches/newbranch', '//trunk', '--track-rename', '-m', 'merge back'], [
+ 'Auto-merging (0, 12) /branches/newbranch to /trunk (base /trunk:10).',
+ 'Collecting renames, this might take a while.',
+ 'A bar',
+ 'A bar/test.txt',
+ 'D foo',
+ "New merge ticket: $uuid:/trunk:10",
+ 'Committed revision 13.',
+]);
+
+chdir($co_trunk_path);
+$svk->update();
+is_file_content('bar/test.txt', 'b');
+}
More information about the svk-commit
mailing list