[svk-commit] r2814 - in trunk/lib/SVK: .

nobody at bestpractical.com nobody at bestpractical.com
Wed May 7 00:36:59 EDT 2008


Author: clsung
Date: Wed May  7 00:36:56 2008
New Revision: 2814

Modified:
   trunk/lib/SVK/Command/Branch.pm
   trunk/lib/SVK/Project.pm

Log:
- add info() in Project.pm
  - try to verbose the infomation for br 
- fix http://task.hm/E9YA/

Modified: trunk/lib/SVK/Command/Branch.pm
==============================================================================
--- trunk/lib/SVK/Command/Branch.pm	(original)
+++ trunk/lib/SVK/Command/Branch.pm	Wed May  7 00:36:56 2008
@@ -98,7 +98,8 @@
     my $proj = $self->load_project($target);
 
     if ($proj) {
-        $logger->info( loc("Project mapped.  Project name: %1.\n", $proj->name));
+        $logger->info( loc("Project mapped."));
+        $proj->info($target);
     } else {
         $target->root->check_path($target->path)
             or die loc("Path %1 does not exist.\n", $target->depotpath);
@@ -228,7 +229,7 @@
 	$self->SVK::Command::Switch::run(
 	    $self->arg_uri_maybe($newbranch_path),
 	    $target
-	) if $self->{switch};
+	) if $self->{switch} and !$self->{check_only};
     }
     return;
 }
@@ -680,11 +681,24 @@
 # --offline (at checkout of branch FOO
 #   --create FOO --from FOO --local
 
+sub parse_arg {
+    my ($self, @arg) = @_;
+
+    push @arg, '' unless @arg;
+    return $self->SUPER::parse_arg(@arg);
+}
+
 sub run {
-    my ($self, $target, $branch_path) = @_;
+    my ($self, $target, $branch_name) = @_;
+
+    if (!$branch_name) { # no branch_name means using current branch(trunk) as src
+	my $proj = $self->load_project($target);
+	$branch_name = $proj->branch_name($target->path);
+	$self->{from} = $branch_name;
+    }
     $self->{local} = 1;
     $self->{switch} = 1;
-    $self->SUPER::run($target, $branch_path);
+    $self->SUPER::run($target, $branch_name);
 }
 
 1;

Modified: trunk/lib/SVK/Project.pm
==============================================================================
--- trunk/lib/SVK/Project.pm	(original)
+++ trunk/lib/SVK/Project.pm	Wed May  7 00:36:56 2008
@@ -52,6 +52,8 @@
 use strict;
 use SVK::Version;  our $VERSION = $SVK::VERSION;
 use Path::Class;
+use SVK::Logger;
+use SVK::I18N;
 use base 'Class::Accessor::Fast';
 
 __PACKAGE__->mk_accessors(
@@ -282,6 +284,13 @@
     return ;
 }
 
+sub branch_name {
+    my ($self, $bpath, $is_local) = @_;
+    my $branch_location = $is_local ? $self->local_root : $self->branch_location;
+    $bpath =~ s{^\Q$branch_location\E/}{};
+    return $bpath;
+}
+
 sub branch_path {
     my ($self, $bname, $is_local) = @_;
     my $branch_path = '/'.$self->depot->depotname.'/'.
@@ -294,4 +303,31 @@
     return $branch_path;
 }
 
+sub info {
+    my ($self, $target) = @_;
+
+    $logger->info ( loc("Project name: %1.\n", $self->name));
+    if ($target) {
+	my $where;
+	my $bname;
+	if (dir($self->trunk)->subsumes($target->path)) {
+	    $where = 'trunk';
+	    $bname = 'trunk';
+	} elsif (dir($self->branch_location)->subsumes($target->path)) {
+	    $where = 'branch';
+	    $bname = $target->_to_pclass($target->path)->relative($self->branch_location)->dir_list(0);
+	} elsif (dir($self->tag_location)->subsumes($target->path)) {
+	    $where = 'tag';
+	    $bname = $target->_to_pclass($target->path)->relative($self->tag_location)->dir_list(0);
+	}
+
+	$logger->info ( loc("Current Branch: %1 (%2)\n", $bname, $where ));
+	$logger->info ( loc("Depot Path: (%1)\n", $target->depotpath ));
+	if ($where ne 'trunk') { # project trunk should not have Copied info
+	    for ($target->copy_ancestors) {
+		$logger->info( loc("Copied From: %1, Rev. %2\n", $_->[0], $_->[1]));
+	    }
+	}
+    }
+}
 1;


More information about the svk-commit mailing list