[svk-commit] r3078 - in trunk: lib/SVK/Command t/bm
nobody at bestpractical.com
nobody at bestpractical.com
Tue Sep 2 04:26:35 EDT 2008
Author: clsung
Date: Tue Sep 2 04:26:33 2008
New Revision: 3078
Added:
trunk/t/bm/online-offline-trunk.t
Modified:
trunk/ (props changed)
trunk/lib/SVK/Command/Branch.pm
Log:
r19469 at clsung-laptop: clsung | 2008-09-02 14:23:54 +0800
- for http://task.hm/GR9P
r19470 at clsung-laptop: clsung | 2008-09-02 14:39:08 +0800
- refine
r19471 at clsung-laptop: clsung | 2008-09-02 15:22:34 +0800
- for http://task.hm/H6MJ
r19472 at clsung-laptop: clsung | 2008-09-02 16:23:59 +0800
- fix http://task.hm/H8QQ
r19473 at clsung-laptop: clsung | 2008-09-02 16:24:38 +0800
- add comment
Modified: trunk/lib/SVK/Command/Branch.pm
==============================================================================
--- trunk/lib/SVK/Command/Branch.pm (original)
+++ trunk/lib/SVK/Command/Branch.pm Tue Sep 2 04:26:33 2008
@@ -57,6 +57,7 @@
use SVK::Util qw( is_uri get_prompt );
use SVK::Project;
use SVK::Logger;
+use Path::Class;
our $fromProp;
use constant narg => undef;
@@ -102,7 +103,12 @@
if ($proj) {
$proj->info($target, 1);
} else {
- $target->root->check_path($target->path)
+ # XXX: here just a shorthand if one calls svk br help
+ if ('help' eq file($target->path)->basename) {
+ select STDERR unless $self->{output};
+ $self->usage; return;
+ }
+ $target->root->check_path($target->path)
or die loc("Path %1 does not exist.\n", $target->depotpath);
}
@@ -165,7 +171,8 @@
last if ($proj) ;
}
} else {
- $proj = $self->load_project($target, $self->{project});
+ $proj = $self->load_project($target, $self->{project}) unless
+ $SVN::Node::none == $target->root->check_path($target->path);
$msg = loc( "No project found." );
}
return ($proj, $target, $msg);
@@ -622,6 +629,7 @@
my $branch_name = shift(@arg);
my ($project_path, $checkout_path) = ('','');
my ($proj, $target, $msg);
+ $self->{setup}++;
if (@arg and is_depotpath($arg[$#arg])) {
$project_path = pop(@arg);
my $ppath = eval {$self->arg_depotpath($project_path) };
@@ -635,21 +643,15 @@
if (@arg) { # this must be a project path, or error it
$project_path = pop(@arg);
if (!is_depotpath($project_path)) {
- $logger->info(
- loc("No avaliable Projects found in %1.\n", $project_path )
- );
- return;
+ die loc("No avaliable Projects found in %1.\n", $project_path );
}
}
+ $self->{setup}--;
($proj,$target, $msg) = $self->locate_project($project_path);
- if (!$proj) {
- $logger->info(
- loc("Project not found. use 'svk branch --setup mirror_path' to initialize one.\n",$msg)
- );
- return ;
- }
+ die loc("Project not found. use 'svk branch --setup mirror_path' to initialize one.\n",$msg)
+ unless $proj;
$branch_name = $proj->name."-trunk"
if ($branch_name eq 'trunk' and $self->{local}) ;
$checkout_path = $branch_name unless $checkout_path;
@@ -920,6 +922,8 @@
$self->{branch_name} = $arg if $arg;
$self->{branch_name} = $proj->branch_name($target->path, 1)
unless $arg;
+ # XXX: should provide a more generalized function for local/remote trunk switching
+ $self->{branch_name} = 'trunk' if $self->{branch_name} eq $proj->name."-trunk";
# check existence of remote branch
my $dst;
Added: trunk/t/bm/online-offline-trunk.t
==============================================================================
--- (empty file)
+++ trunk/t/bm/online-offline-trunk.t Tue Sep 2 04:26:33 2008
@@ -0,0 +1,50 @@
+#!/usr/bin/perl -w
+use strict;
+use SVK::Test;
+plan tests => 6;
+our $output;
+
+my ($xd, $svk) = build_test('test');
+
+$svk->mkdir(-m => 'trunk', '/test/trunk');
+$svk->mkdir(-m => 'trunk', '/test/branches');
+$svk->mkdir(-m => 'trunk', '/test/tags');
+my $tree = create_basic_tree($xd, '/test/trunk');
+
+my $depot = $xd->find_depot('test');
+my $uri = uri($depot->repospath);
+
+$svk->mirror('//mirror/myproj', $uri);
+$svk->sync('//mirror/myproj');
+
+my ($copath, $corpath) = get_copath('bm-online-offline-trunk');
+
+$svk->checkout('//mirror/myproj/trunk', $copath);
+
+chdir($copath);
+
+$svk->br('--offline');
+
+is_output_like ($svk, 'info', [],
+ qr|Depot Path: //local/myproj/myproj-trunk|);
+
+is_ancestor($svk, '//local/myproj/myproj-trunk', '/mirror/myproj/trunk', 6);
+
+is_output($svk, 'br', ['-l', '--local', '//mirror/myproj'],
+ ['myproj-trunk']);
+append_file('A/be', "fnordorz\n");
+$svk->commit(-m => '#H8QQ');
+
+is_output($svk, 'br', ['--online', '-C'],
+ ["Auto-merging (0, 8) /local/myproj/myproj-trunk to /mirror/myproj/trunk (base /mirror/myproj/trunk:6).",
+ "===> Auto-merging (0, 7) /local/myproj/myproj-trunk to /mirror/myproj/trunk (base /mirror/myproj/trunk:6).",
+ "Empty merge.",
+ "===> Auto-merging (7, 8) /local/myproj/myproj-trunk to /mirror/myproj/trunk (base /mirror/myproj/trunk:6).",
+ "U A/be",
+ qr"New merge ticket: [\w\d-]+:/local/myproj/myproj-trunk:8"]);
+is_output_like ($svk, 'branch', ['--online'],
+ qr|U A/be|);
+
+is_output_like ($svk, 'info', [],
+ qr|Depot Path: //mirror/myproj/trunk|);
+
More information about the svk-commit
mailing list