[svk-commit] r2942 - in branches/mirror-boostrap: . lib/SVK lib/SVK/Command t

nobody at bestpractical.com nobody at bestpractical.com
Sun Jun 29 06:42:16 EDT 2008


Author: clkao
Date: Sun Jun 29 06:42:12 2008
New Revision: 2942

Added:
   branches/mirror-boostrap/t/07smerge-co-deleted.t
Modified:
   branches/mirror-boostrap/   (props changed)
   branches/mirror-boostrap/lib/SVK/Command.pm
   branches/mirror-boostrap/lib/SVK/Command/Branch.pm
   branches/mirror-boostrap/lib/SVK/Command/Merge.pm
   branches/mirror-boostrap/lib/SVK/Merge.pm
   branches/mirror-boostrap/lib/SVK/Project.pm
   branches/mirror-boostrap/lib/SVK/Root.pm
   branches/mirror-boostrap/t/bm/basic.t
   branches/mirror-boostrap/t/bm/create-nocheckout.t
   branches/mirror-boostrap/t/bm/create.t
   branches/mirror-boostrap/t/bm/prop-autoload.t

Log:
- Merge //mirror/svk/trunk to //mirror/svk/branches/mirror-boostrap

Modified: branches/mirror-boostrap/lib/SVK/Command.pm
==============================================================================
--- branches/mirror-boostrap/lib/SVK/Command.pm	(original)
+++ branches/mirror-boostrap/lib/SVK/Command.pm	Sun Jun 29 06:42:12 2008
@@ -858,7 +858,7 @@
     local $/=undef;
     my $buf = <$podfh>;
     if($buf =~ /^=head1\s+NAME\s*SVK::Command::(\w+ - .+)$/m) {
-	$logger->info( "   ",loc(lcfirst($1)),"\n");
+	$logger->info( "   ",loc(lcfirst($1)));
     }
     close $podfh;
 }

Modified: branches/mirror-boostrap/lib/SVK/Command/Branch.pm
==============================================================================
--- branches/mirror-boostrap/lib/SVK/Command/Branch.pm	(original)
+++ branches/mirror-boostrap/lib/SVK/Command/Branch.pm	Sun Jun 29 06:42:12 2008
@@ -64,11 +64,13 @@
 my @SUBCOMMANDS = qw(merge move push remove|rm|del|delete checkout|co create diff info setup online offline);
 
 sub options {
-    ('l|list'           => 'list',
+    ('l|list|ls'        => 'list',
      'C|check-only'     => 'check_only',
      'P|patch=s'        => 'patch',
      'all'              => 'all',
+     'export'           => 'export',
      'from=s'           => 'from',
+     'from-tag=s'       => 'fromtag',
      'local'            => 'local',
      'project=s'        => 'project',
      'switch-to'        => 'switch',
@@ -224,7 +226,7 @@
 	$logger->info (sprintf $fmt, $_, ' (in local)') for @{$branches};
 
     } else {
-	my $branches = $proj->branches ($self->{local});
+	my $branches = $self->{tag} ? $proj->tags() : $proj->branches ($self->{local});
 
 	my $fmt = "%s\n"; # here to change layout
 	$logger->info (sprintf $fmt, $_) for @{$branches};
@@ -269,9 +271,18 @@
 	);
 	return;
     }
+    if ($self->{from} and $self->{fromtag}) {
+	$logger->info(
+	    loc("You can not specify both --from and --fromtag")
+	);
+	return;
+    }
 
     delete $self->{from} if $self->{from} and $self->{from} eq 'trunk';
-    my $src_path = $proj->branch_path($self->{from} ? $self->{from} : 'trunk');
+    delete $self->{fromtag} if $self->{fromtag} and $self->{fromtag} eq 'trunk';
+    my $src_path = $self->{fromtag} ?
+	$proj->tag_path($self->{fromtag}) :
+	$proj->branch_path($self->{from} ? $self->{from} : 'trunk');
     my $newbranch_path = $self->dst_path($proj, $branch_name);
 
     my $src = $self->arg_uri_maybe($src_path, 'New mirror site not allowed here');
@@ -283,7 +294,7 @@
 	    $branch_name, $self->{local} ? '(in local)' : '');
 
     $self->{parent} = 1;
-    $self->{message} ||= "- Create branch $branch_name";
+    $self->{message} ||= join(" ", "- Create", ($self->{tag} ? "tag" : "branch"), $branch_name);
     my $ret = $self->SUPER::run($src, $dst);
 
     if (!$ret) {
@@ -291,7 +302,8 @@
         $self->{tag} ? "tag" : "branch",
 	    $branch_name,
 	    $self->{local} ? ' (in local)' : '',
-	    $self->{from} ? " (from $self->{from})" : '',
+	    $self->{fromtag} ? " (from tag $self->{fromtag})" :
+		$self->{from} ? " (from branch $self->{from})" : '',
 	  )
 	);
 	# call SVK::Command::Switch here if --switch-to
@@ -581,7 +593,7 @@
 	return ;
     }
 
-    my $newtarget_path = $proj->branch_path($branch_name, $self->{local});
+    my $newtarget_path = $self->dst_path($proj, $branch_name);
     unshift @arg, $newtarget_path, $checkout_path;
     return $self->SUPER::parse_arg(@arg);
 }
@@ -702,7 +714,9 @@
 
     my $local_root = $self->arg_depotpath('/'.$target->depot->depotname.'/');
     my ($trunk_path, $branch_path, $tag_path, $project_name, $preceding_path);
-    my $source_root = $target->is_mirrored->_backend->source_root;
+    my $m = $target->is_mirrored;
+    die loc("%1 is not a mirrored path.\n", $target->depotpath) if !$m;
+    my $source_root = $m->_backend->source_root;
     my $url = $target->is_mirrored->url;
 
     for my $path ($target->depot->mirror->entries) {
@@ -794,7 +808,7 @@
 	    "svk:project:$project_name:path-trunk" => $trunk_path,
 	    "svk:project:$project_name:path-branches" => $branch_path,
 	    "svk:project:$project_name:path-tags" => $tag_path);
-	if ($ret) { # we have problem to write to remote
+	if ($ret or $@) { # we have problem to write to remote
 	    if ($source_root ne $url) {
 		$logger->info( loc("Can't write project props to remote root. Save in local instead."));
 	    } else {
@@ -805,7 +819,7 @@
 	    $self->do_propset("svk:project:$project_name:path-tags",$tag_path, $local_root);
 	    $self->do_propset("svk:project:$project_name:root",$preceding_path, $local_root);
 	}
-	$proj = SVK::Project->create_from_prop($target);
+	$proj = SVK::Project->create_from_prop($target,$project_name);
 	# XXX: what if it still failed here? How to rollback the prop commits?
 	if (!$proj) {
 	    $logger->info( loc("Project setup failed.\n"));
@@ -948,7 +962,7 @@
  branch --create BRANCH [DEPOTPATH]
 
  branch --list [--all]
- branch --create BRANCH [--tag] [--local] [--switch-to] [DEPOTPATH]
+ branch --create BRANCH [--tag] [--local] [--switch-to] [--from|--from-tag BRANCH|TAG] [DEPOTPATH]
  branch --move BRANCH1 BRANCH2
  branch --merge BRANCH1 BRANCH2 ... TARGET
  branch --checkout BRANCH [PATH] [DEPOTPATH]

Modified: branches/mirror-boostrap/lib/SVK/Command/Merge.pm
==============================================================================
--- branches/mirror-boostrap/lib/SVK/Command/Merge.pm	(original)
+++ branches/mirror-boostrap/lib/SVK/Command/Merge.pm	Sun Jun 29 06:42:12 2008
@@ -58,7 +58,7 @@
 use SVK::Command::Log;
 use SVK::Logger;
 use SVK::Merge;
-use SVK::Util qw( get_buffer_from_editor traverse_history );
+use SVK::Util qw( get_buffer_from_editor traverse_history tmpfile );
 
 sub options {
     ($_[0]->SUPER::options,
@@ -193,6 +193,7 @@
 	return;
     }
 
+    # for checkouts we save later into a file
     $self->get_commit_message ($self->{log} ? $merge->log(1) : undef)
 	unless $dst->isa('SVK::Path::Checkout');
 
@@ -242,6 +243,13 @@
 	$merge->run ($self->get_editor ($dst, undef, $self->{auto} ? $src : undef));
 	delete $self->{save_message};
     }
+
+    if ( $self->{log} && $dst->isa('SVK::Path::Checkout') ) {
+        my ($fh, $file) = tmpfile ('commit', DIR => '', TEXT => 1, UNLINK => 0);
+        print $fh $merge->log(1);
+        $logger->warn(loc ("Log message saved in %1.", $file));
+    }
+
     return;
 }
 

Modified: branches/mirror-boostrap/lib/SVK/Merge.pm
==============================================================================
--- branches/mirror-boostrap/lib/SVK/Merge.pm	(original)
+++ branches/mirror-boostrap/lib/SVK/Merge.pm	Sun Jun 29 06:42:12 2008
@@ -534,7 +534,6 @@
 	    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);
 	    }

Modified: branches/mirror-boostrap/lib/SVK/Project.pm
==============================================================================
--- branches/mirror-boostrap/lib/SVK/Project.pm	(original)
+++ branches/mirror-boostrap/lib/SVK/Project.pm	Sun Jun 29 06:42:12 2008
@@ -131,10 +131,9 @@
     my $fs              = $pathobj->depot->repos->fs;
     my $root            = $fs->revision_root( $fs->youngest_rev );
     my @all_mirrors     = split "\n", $root->node_prop('/','svm:mirror') || '';
-    my $prop_path = '/';
+    my $prop_path = '';
     my $proj;
 
-    return unless $pathobj->path ne '/' or $pname;
     foreach my $m_path (@all_mirrors) {
 	if ($pathobj->path eq '/') { # in non-wc path
 	    $proj = $self->_create_from_prop($pathobj, $root, $m_path, $pname);
@@ -206,7 +205,7 @@
 		    branch_location => $props{'path-branches'},
 		    tag_location    => $props{'path-tags'},
 		    local_root      => "/local/${project_name}",
-		}) if $pathobj->path =~ m/^$props{$key}/ or $props{$key} =~ m/^$pathobj->{path}/
+		}) if $pathobj->path =~ m/^$props{$key}/ or $props{$key} =~ m/^$pathobj->{'path'}/
 		      or $pathobj->path =~ m{^/local/$project_name};
 	}
     }
@@ -342,6 +341,14 @@
     return $branch_path;
 }
 
+sub tag_name {
+    my ($self, $bpath) = @_;
+    return 'trunk' if (dir($self->trunk)->subsumes($bpath));
+    my $tag_location = $self->tag_location;
+    $bpath =~ s{^\Q$tag_location\E/}{};
+    return $bpath;
+}
+
 sub tag_path {
     my ($self, $tname) = @_;
     my $tag_path = ($tname ne 'trunk' ?  $self->tag_location . "/$tname" : $self->trunk);

Modified: branches/mirror-boostrap/lib/SVK/Root.pm
==============================================================================
--- branches/mirror-boostrap/lib/SVK/Root.pm	(original)
+++ branches/mirror-boostrap/lib/SVK/Root.pm	Sun Jun 29 06:42:12 2008
@@ -89,7 +89,7 @@
     # txn also, we need to use a new pool, otherwise it segfaults for
     # doing allocation in a pool that is being destroyed.
     $_[0]->txn->abort( SVN::Pool->new )
-        if $_[0]->txn && ( $_[0]->cleanup_pid || $$ ) == $$;
+        if ( $_[0]->cleanup_pid || $$ ) == $$;
 }
 
 # return the root and path on the given revnum, the returned path is

Added: branches/mirror-boostrap/t/07smerge-co-deleted.t
==============================================================================
--- (empty file)
+++ branches/mirror-boostrap/t/07smerge-co-deleted.t	Sun Jun 29 06:42:12 2008
@@ -0,0 +1,33 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use Test::More tests => 2;
+use File::Path;
+use Cwd;
+use SVK::Test;
+
+my ($xd, $svk) = build_test();
+our $output;
+my ($copath, $corpath) = get_copath ('smerge');
+$svk->mkdir ('-m', 'trunk', '//trunk');
+my $tree = create_basic_tree ($xd, '//trunk');
+$svk->cp ('-m', 'branch', '//trunk', '//local');
+$svk->rm ('-m', 'remove branch', '//local', '//local-moved');
+$svk->co ('//trunk', $copath);
+append_file("$copath/me", "a change\n");
+$svk->ci ('-m', 'change file', $copath );
+$svk->switch ('//local at 4', $copath);
+
+is_output($svk, 'sm', ['-C', '//trunk', $copath],
+    ['Auto-merging (3, 6) /trunk to /local (base /trunk:3).',
+     'U   t/checkout/smerge/me',
+     qr'New merge ticket: .*:/trunk:6']
+);
+is_output($svk, 'sm', ['//trunk', $copath],
+    ['Auto-merging (3, 6) /trunk to /local (base /trunk:3).',
+     'U   t/checkout/smerge/me',
+     qr'New merge ticket: .*:/trunk:6']
+);
+
+#diag $output;

Modified: branches/mirror-boostrap/t/bm/basic.t
==============================================================================
--- branches/mirror-boostrap/t/bm/basic.t	(original)
+++ branches/mirror-boostrap/t/bm/basic.t	Sun Jun 29 06:42:12 2008
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 use strict;
 use SVK::Test;
-plan tests => 13;
+plan tests => 16;
 our $output;
 
 my ($xd, $svk) = build_test('test');
@@ -67,3 +67,11 @@
 is_output($svk, 'br', ['-l', '--all', '//mirror/MyProject'],
           ['Foo', 'feature/foo', 'feature/foobar (in local)']);
 
+is_output_like ($svk, 'branch', ['--create', 'tagA', '--tag'],
+    qr'Project tag created: tagA');
+
+is_output($svk, 'br', ['-l', '--all', '//mirror/MyProject'],
+          ['Foo', 'feature/foo', 'tagA (tags)', 'feature/foobar (in local)']);
+
+is_output($svk, 'br', ['-l', '--tag', '//mirror/MyProject'],
+          ['tagA']);

Modified: branches/mirror-boostrap/t/bm/create-nocheckout.t
==============================================================================
--- branches/mirror-boostrap/t/bm/create-nocheckout.t	(original)
+++ branches/mirror-boostrap/t/bm/create-nocheckout.t	Sun Jun 29 06:42:12 2008
@@ -36,7 +36,7 @@
      "Syncing $uri",
      'Retrieving log information from 7 to 7',
      'Committed revision 8 from revision 7.',
-     "Project branch created: feature/foobar (from feature/foo)"]);
+     "Project branch created: feature/foobar (from branch feature/foo)"]);
 
 is_output ($svk, 'info',['//mirror/MyProject/branches/feature/foobar'],
     ["Depot Path: //mirror/MyProject/branches/feature/foobar",

Modified: branches/mirror-boostrap/t/bm/create.t
==============================================================================
--- branches/mirror-boostrap/t/bm/create.t	(original)
+++ branches/mirror-boostrap/t/bm/create.t	Sun Jun 29 06:42:12 2008
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 use strict;
-use Test::More tests => 7;
+use Test::More tests => 10;
 use SVK::Test;
 use File::Path;
 
@@ -50,7 +50,7 @@
      "Syncing $uri",
      'Retrieving log information from 9 to 9',
      'Committed revision 12 from revision 9.',
-     "Project branch created: feature/foobar (from feature/bar)"]);
+     "Project branch created: feature/foobar (from branch feature/bar)"]);
 
 is_output ($svk, 'info',['//mirror/MyProject/branches/feature/foobar'],
     ["Depot Path: //mirror/MyProject/branches/feature/foobar",
@@ -70,3 +70,34 @@
      'Retrieving log information from 10 to 10',
      'Committed revision 13 from revision 10.',
      "Project branch created: feature/footrunk"]);
+
+is_output ($svk, 'branch',
+    ['--create', 'release-1', '--tag', '--from', 'feature/bar'],
+    ["Merging back to mirror source $uri.",
+     "Merge back committed as revision 11.",
+     "Syncing $uri",
+     'Retrieving log information from 11 to 11',
+     'Committed revision 14 from revision 11.',
+     "Project tag created: release-1 (from branch feature/bar)"]);
+
+is_output ($svk, 'branch',
+    ['--create', 'bug-in-release-1', '--from-tag', 'release-1'],
+    ["Merging back to mirror source $uri.",
+     "Merge back committed as revision 12.",
+     "Syncing $uri",
+     'Retrieving log information from 12 to 12',
+     'Committed revision 15 from revision 12.',
+     "Project branch created: bug-in-release-1 (from tag release-1)"]);
+
+#$svk->br("--info", "bug-in-release-10"
+is_output ($svk, 'info',['//mirror/MyProject/branches/bug-in-release-1'],
+    ["Depot Path: //mirror/MyProject/branches/bug-in-release-1",
+     "Revision: 15", "Last Changed Rev.: 15",
+     qr/Last Changed Date: \d{4}-\d{2}-\d{2}/,
+     "Mirrored From: $uri, Rev. 12",
+     "Copied From: /mirror/MyProject/tags/release-1, Rev. 14",
+     "Copied From: /mirror/MyProject/branches/feature/bar, Rev. 9",
+     "Copied From: /mirror/MyProject/trunk, Rev. 6",
+     "Merged From: /mirror/MyProject/tags/release-1, Rev. 14",
+     "Merged From: /mirror/MyProject/branches/feature/bar, Rev. 9",
+     "Merged From: /mirror/MyProject/trunk, Rev. 6",'']);

Modified: branches/mirror-boostrap/t/bm/prop-autoload.t
==============================================================================
--- branches/mirror-boostrap/t/bm/prop-autoload.t	(original)
+++ branches/mirror-boostrap/t/bm/prop-autoload.t	Sun Jun 29 06:42:12 2008
@@ -1,10 +1,10 @@
 #!/usr/bin/perl -w
 use strict;
 use SVK::Test;
-plan tests => 3;
+plan tests => 4;
 our $output;
 
-my ($xd, $svk) = build_test('test');
+my ($xd, $svk) = build_test('test','rootProject');
 
 $svk->mkdir(-m => 'trunk', '/test/trunk');
 $svk->mkdir(-m => 'trunk', '/test/branches');
@@ -34,17 +34,14 @@
 
 $svk->mirror('--detach', '//mirror/MyProject');
 
-TODO: {
-local $TODO = "path properties are relative to the mirror root";
-$answer = ['','','y','1', ''];
-$svk->checkout($uri,$copath);
-
-chdir($copath);
+$svk->mirror('/rootProject/', $uri);
+$svk->sync('/rootProject/');
 is_output ($svk, 'propget',
-    ['svk:project:projectA:path-trunk', '//mirror/projectA'],
+    ['svk:project:projectA:path-trunk', '/rootProject/'],
     [$props->{'svk:project:projectA:path-trunk'}]);
 
-# currently core dump, after TODO implemented, remove the following #
-#is_output ($svk, 'branch', ['--list','//mirror/projectA'], ['Foo']);
+is_output ($svk, 'branch', ['--list','/rootProject/'], ['Foo']);
+$svk->checkout('/rootProject/',$copath);
+
+chdir($copath);
 is_output ($svk, 'branch', ['--list'], ['Foo']);
-}


More information about the svk-commit mailing list