[svk-commit] r3077 - in trunk: lib/SVK lib/SVK/Command t/api t/bm
nobody at bestpractical.com
nobody at bestpractical.com
Sun Aug 31 08:06:55 EDT 2008
Author: clsung
Date: Sun Aug 31 08:06:52 2008
New Revision: 3077
Modified:
trunk/ (props changed)
trunk/lib/SVK/Command/Branch.pm
trunk/lib/SVK/Project.pm
trunk/t/api/project.t
trunk/t/bm/move.t
Log:
r17754 at clsung-laptop: clsung | 2008-08-31 11:44:24 +0800
- Create branch strunk
r19043 at clsung-laptop: clsung | 2008-08-31 16:14:01 +0800
- be cautious if no copy_ancestors
r19044 at clsung-laptop: clsung | 2008-08-31 16:42:26 +0800
- better handling for checkout local project's trunk
r19045 at clsung-laptop: clsung | 2008-08-31 16:49:25 +0800
- the order is messed
r19046 at clsung-laptop: clsung | 2008-08-31 16:56:18 +0800
- $proj is required in --offline
r19047 at clsung-laptop: clsung | 2008-08-31 18:09:38 +0800
- make the test comment more meaningful
r19048 at clsung-laptop: clsung | 2008-08-31 18:12:20 +0800
- implements 'svk br -l --verbose'
- shows the Last Changed Date/Author
- rewrite the t/api/project.t, since the output changed
Modified: trunk/lib/SVK/Command/Branch.pm
==============================================================================
--- trunk/lib/SVK/Command/Branch.pm (original)
+++ trunk/lib/SVK/Command/Branch.pm Sun Aug 31 08:06:52 2008
@@ -175,7 +175,7 @@
my ($self, $proj, $arg) = @_;
return $arg unless $arg =~ m/\*/;
my $match = SVK::XD::compile_apr_fnmatch($arg);
- return grep { m/$match/ } @{ $proj->branches };
+ return map {$_->[0]} grep {$_->[0] =~ m/$match/ } @{ $proj->branches } ;
}
sub dst_name {
@@ -214,23 +214,24 @@
my ($self, $proj) = @_;
return unless $proj;
+ $proj->{verbose} = $self->{verbose};
if ($self->{all}) {
- my $fmt = "%s%s\n"; # here to change layout
+ my $fmt = "%s%s%s\n"; # here to change layout
my $branches = $proj->branches (0); # branches
- $logger->info (sprintf $fmt, $_, '') for @{$branches};
+ $logger->info (sprintf $fmt, $_->[0], '', $_->[1]) for @{$branches};
$branches = $proj->tags (); # tags
- $logger->info (sprintf $fmt, $_, ' (tags)') for @{$branches};
+ $logger->info (sprintf $fmt, $_->[0], ' (tags)', $_->[1]) for @{$branches};
$branches = $proj->branches (1); # local branches
- $logger->info (sprintf $fmt, $_, ' (in local)') for @{$branches};
+ $logger->info (sprintf $fmt, $_->[0], ' (in local)', $_->[1]) for @{$branches};
} else {
my $branches = $self->{tag} ? $proj->tags() : $proj->branches ($self->{local});
- my $fmt = "%s\n"; # here to change layout
- $logger->info (sprintf $fmt, $_) for @{$branches};
+ my $fmt = "%s%s\n"; # here to change layout
+ $logger->info (sprintf $fmt, $_->[0], $_->[1]) for @{$branches};
}
return;
}
@@ -365,7 +366,7 @@
$branch_path, $self->{local} ? ' (in local)' : '');
die loc("Project branch already exists: %1%2\n",
$dst_name, $self->{local} ? ' (in local)' : '')
- if grep /$dst_name/,@{$proj->branches};
+ if grep {$_->[0] =~ m/$dst_name/} @{$proj->branches};
$self->{parent} = 1;
for my $src_path (@src_paths) {
@@ -631,8 +632,6 @@
}
}
$checkout_path = pop(@arg);
- $checkout_path = $branch_name unless $checkout_path;
-
if (@arg) { # this must be a project path, or error it
$project_path = pop(@arg);
if (!is_depotpath($project_path)) {
@@ -651,6 +650,9 @@
);
return ;
}
+ $branch_name = $proj->name."-trunk"
+ if ($branch_name eq 'trunk' and $self->{local}) ;
+ $checkout_path = $branch_name unless $checkout_path;
my $newtarget_path = $self->dst_path($proj, $branch_name);
unshift @arg, $newtarget_path, $checkout_path;
@@ -976,6 +978,7 @@
sub run {
my ($self, $proj, $target, $branch_name) = @_;
+ return unless $proj;
die loc ("Current branch already offline\n")
if ($target->_to_pclass("/local")->subsumes($target->path));
Modified: trunk/lib/SVK/Project.pm
==============================================================================
--- trunk/lib/SVK/Project.pm (original)
+++ trunk/lib/SVK/Project.pm Sun Aug 31 08:06:52 2008
@@ -55,6 +55,7 @@
use SVK::Logger;
use SVK::I18N;
use base 'Class::Accessor::Fast';
+use autouse 'SVK::Util' => qw( reformat_svn_date );
__PACKAGE__->mk_accessors(
qw(name trunk branch_location tag_location local_root depot));
@@ -82,19 +83,19 @@
my $root = $fs->revision_root( $fs->youngest_rev );
my $branch_location = $local ? $self->local_root : $self->branch_location;
- return [ apply {s{^\Q$branch_location\E/}{}}
+ return [ apply {$_->[0] =~ s{^\Q$branch_location\E/}{}}
@{ $self->_find_branches( $root, $branch_location ) } ];
}
sub tags {
- my $self = shift;
+ my ( $self ) = @_;
return [] unless $self->tag_location;
my $fs = $self->depot->repos->fs;
my $root = $fs->revision_root( $fs->youngest_rev );
my $tag_location = $self->tag_location;
- return [ apply {s{^\Q$tag_location\E/}{}}
+ return [ apply {$_->[0] =~ s{^\Q$tag_location\E/}{}}
@{ $self->_find_branches( $root, $tag_location ) } ];
}
@@ -119,12 +120,28 @@
next if $b->path eq $trunk->path;
push @branches, $b->related_to($trunk)
- ? $b->path
+ ? [$b->path, $self->{verbose} ? ":\n ".$self->lastchanged_info($b) : ""]
: @{ $self->_find_branches( $root, $path . '/' . $entry ) };
}
return \@branches;
}
+sub lastchanged_info {
+ my ($self, $target) = @_;
+ if (defined( my $lastchanged = $target->root->node_created_rev( $target->path ))) {
+ my $date
+ = $target->root->fs->revision_prop( $lastchanged, 'svn:date' );
+ my $author
+ = $target->root->fs->revision_prop( $lastchanged, 'svn:author' );
+ return sprintf (
+ "Last Changed Rev: %s (%s, by %s)",
+ $lastchanged,
+ reformat_svn_date( "%Y-%m-%d", $date ),
+ $author
+ );
+ }
+}
+
sub create_from_prop {
my ($self, $pathobj, $pname) = @_;
@@ -269,7 +286,7 @@
if ($path_obj->_to_pclass("/local")->subsumes($current_path)) { # guess if in local branch
# should only be 1 entry
- $current_path = ($path_obj->copy_ancestors)[0]->[0];
+ $current_path = ($path_obj->copy_ancestors)[0]->[0] if $path_obj->copy_ancestors;
$path_obj = $path_obj->copied_from if $path_obj->copied_from;
}
@@ -316,7 +333,7 @@
my ($self, $name) = @_;
# return 1 for branch, 2 for tag, others => 0
return '/'.dir($self->depot->depotname,$self->branch_location,$name)->as_foreign('Unix')
- if grep { $_ eq $name } @{$self->branches};
+ if grep { $_->[0] eq $name } @{$self->branches};
return '/'.dir($self->depot->depotname,$self->tag_location,$name)->as_foreign('Unix')
if grep { $_ eq $name } @{$self->tags};
return ;
@@ -328,8 +345,8 @@
my $branch_location = $is_local ? $self->local_root : $self->branch_location;
$bpath =~ s{^\Q$branch_location\E/}{};
my $pbname;
- ($pbname) = grep { $bpath =~ m#^$_(/|$)# } @{$self->branches};
- return $pbname if $pbname;
+ ($pbname) = grep { my $base = $_->[0]; $bpath =~ m#^$base(/|$)# } @{$self->branches};
+ return $pbname->[0] if $pbname;
return $bpath;
}
Modified: trunk/t/api/project.t
==============================================================================
--- trunk/t/api/project.t (original)
+++ trunk/t/api/project.t Sun Aug 31 08:06:52 2008
@@ -34,8 +34,8 @@
$svk->cp(-m => 'branch Foo', '//mirror/MyProject/trunk', '//mirror/MyProject/branches/Foo');
-is_deeply($proj->branches, ['Foo'], 'found 1 branch');
+is_deeply($proj->branches, [['Foo','']], 'found 1 branch');
$svk->cp(-pm => 'feature branch Bar', '//mirror/MyProject/trunk', '//mirror/MyProject/branches/feature/Bar');
-is_deeply($proj->branches, ['Foo', 'feature/Bar'], 'found deep branches');
+is_deeply($proj->branches, [['Foo', ''], ['feature/Bar','']], 'found deep branches');
Modified: trunk/t/bm/move.t
==============================================================================
--- trunk/t/bm/move.t (original)
+++ trunk/t/bm/move.t Sun Aug 31 08:06:52 2008
@@ -123,7 +123,7 @@
is_output ($svk, 'branch', ['--list'],
['feature/remotebar','feature/remotefoo', 'hasbugs/bar','hasbugs/mar'],
- 'Move feature/bar,mar to hasbugs/');
+ 'branch --list. check if feature/bar,mar moved to hasbugs/');
is_output ($svk, 'branch', ['--create', 'localbar', '--local'],
["Committed revision 21.",
More information about the svk-commit
mailing list