[svk-commit] r2762 - in trunk: lib/SVK t/bm
nobody at bestpractical.com
nobody at bestpractical.com
Sun Apr 27 11:24:51 EDT 2008
Author: clsung
Date: Sun Apr 27 11:24:51 2008
New Revision: 2762
Added:
trunk/t/bm/prop-setup.t
Modified:
trunk/lib/SVK/Command/Branch.pm
trunk/lib/SVK/Project.pm
Log:
- add t/bm/prop-setup.t
- some unfinished implementation for it
Modified: trunk/lib/SVK/Command/Branch.pm
==============================================================================
--- trunk/lib/SVK/Command/Branch.pm (original)
+++ trunk/lib/SVK/Command/Branch.pm Sun Apr 27 11:24:51 2008
@@ -72,6 +72,7 @@
'push' => 'push',
'move' => 'move',
'remove' => 'remove',
+ 'setup' => 'setup',
'switch-to' => 'switch',
);
}
@@ -483,6 +484,72 @@
return;
}
+package SVK::Command::Branch::setup;
+use base qw( SVK::Command SVK::Command::Branch );
+use SVK::I18N;
+use SVK::Util qw( is_uri get_prompt );
+use SVK::Logger;
+
+sub parse_arg {
+ my ($self, @arg) = @_;
+ return if $#arg != 0;
+
+ my $dst = shift(@arg);
+ die loc ("Copy destination can't be URI.\n")
+ if is_uri ($dst);
+
+ return ($self->arg_co_maybe ($dst));
+}
+
+
+sub run {
+ my ($self, $target) = @_;
+
+ my $proj = $self->load_project($target);
+
+ if (!$proj) {
+ $logger->info( loc("New Project depotpath encountered: %1\n", $target->path));
+ my ($trunk_path, $branch_path, $tag_path, $project_name);
+ for my $path ($target->depot->mirror->entries) {
+ ($trunk_path, $project_name) = $target->path =~ m{^$path(/?([^/]+).*)$};
+ }
+ {
+ my $ans = get_prompt(
+ loc("It has no trunk, where is the trunk/? (press enter to use %1)\n=>", $trunk_path),
+ qr/^(?:.*)/
+ );
+ if (length($ans)) {
+ $trunk_path = $ans;
+ last;
+ }
+ }
+ $branch_path = $trunk_path.'/branches';
+ {
+ my $ans = get_prompt(
+ loc("And where is the branches/? (%1)\n=> ", $branch_path),
+ qr/^(?:.*)/
+ );
+ if (length($ans)) {
+ $branch_path = $ans;
+ last;
+ }
+ }
+ $tag_path = $trunk_path.'/tags';
+ {
+ my $ans = get_prompt(
+ loc("And where is the tags/? (press enter to skip)"),
+ qr/^(?:.*)/
+ );
+ if (length($ans)) {
+ $tag_path = $ans;
+ last;
+ }
+ }
+ #XXX implement setting properties of project here
+ return;
+ }
+ return;
+}
1;
__DATA__
Modified: trunk/lib/SVK/Project.pm
==============================================================================
--- trunk/lib/SVK/Project.pm (original)
+++ trunk/lib/SVK/Project.pm Sun Apr 27 11:24:51 2008
@@ -121,6 +121,21 @@
return \@branches;
}
+sub create_to_prop {
+ my ($self, $pathobj, $project_name, @paths) = @_;
+
+ my $fs = $pathobj->depot->repos->fs;
+ my $root = $fs->revision_root( $fs->youngest_rev );
+ my ($prop_path) = $root->node_prop('/','svm:mirror') =~ m/^(\S+)\s+$/;
+ my $allprops = $root->node_proplist($prop_path);
+
+ my %props;
+ $props{'path-trunk'} = $paths[0];
+ $props{'path-branches'} = $paths[1];
+ $props{'path-tags'} = $paths[2] || '';
+ return undef;
+}
+
sub create_from_prop {
my ($self, $pathobj) = @_;
Added: trunk/t/bm/prop-setup.t
==============================================================================
--- (empty file)
+++ trunk/t/bm/prop-setup.t Sun Apr 27 11:24:51 2008
@@ -0,0 +1,41 @@
+#!/usr/bin/perl -w
+# This test for trunk and/or branches are not in trunk/ and/or branches/ directories
+use strict;
+use SVK::Test;
+plan tests => 5;
+our $output;
+
+my ($xd, $svk) = build_test('test');
+
+my $tree = create_basic_tree($xd, '/test/');
+
+my $depot = $xd->find_depot('test');
+my $uri = uri($depot->repospath);
+
+my ($copath, $corpath) = get_copath('prop-setup');
+
+my $props = {
+ 'svk:project:A:path-trunk' => '/A',
+ 'svk:project:A:path-branches' => '/B',
+ 'svk:project:A:path-tags' => '/',
+};
+
+$svk->mirror('//mirror/nomeans', $uri);
+$svk->sync('//mirror/nomeans');
+
+$svk->checkout('//mirror/nomeans',$copath);
+
+chdir($copath);
+
+is_output ($svk, 'branch', ['--list', '//mirror/nomeans/A'], ['No project branch founded.']);
+TODO: {
+local $TODO = 'Need to implement br --setup ';
+$answer = ['','',''];
+$svk->branch('--setup', '//mirror/nomeans/A');
+is_output ($svk, 'list', ['//mirror/nomeans/A'], []);
+
+is_output_like ($svk, 'branch', ['--create', 'bar'], qr'Project branch created: bar');
+is_output ($svk, 'branch', ['--list'], ['bar']);
+is_output ($svk, 'list', ['//mirror/MyProject/branches/projA/bar'],
+ ['Q/' ,'be']);
+}
More information about the svk-commit
mailing list