[svk-commit] r2611 - in branches/bm/lib/SVK: .

nobody at bestpractical.com nobody at bestpractical.com
Mon Nov 19 01:00:50 EST 2007


Author: clsung
Date: Mon Nov 19 01:00:47 2007
New Revision: 2611

Modified:
   branches/bm/lib/SVK/Command/Branch.pm
   branches/bm/lib/SVK/Project.pm

Log:
- rename load() to create_from_prop()
- all branch cmds now use load_project()

Modified: branches/bm/lib/SVK/Command/Branch.pm
==============================================================================
--- branches/bm/lib/SVK/Command/Branch.pm	(original)
+++ branches/bm/lib/SVK/Command/Branch.pm	Mon Nov 19 01:00:47 2007
@@ -83,12 +83,7 @@
 sub run {
     my ( $self, $target, @options ) = @_;
 
-    my $proj = SVK::Project->load($target) if $target->isa('SVK::Path');
-    my $source = $target->source;
-    $proj = SVK::Project->create_from_path(
-	$source->depot,
-	$source->path
-    ) unless $proj;
+    my $proj = $self->load_project($target);
 
     print loc("Project mapped.  Project name: %1.\n", $proj->name);
 
@@ -98,7 +93,8 @@
 sub load_project {
     my ($self, $target) = @_;
 
-    my $proj = SVK::Project->load($target) if $target->isa('SVK::Path');
+    Carp::cluck unless $target->isa('SVK::Path') or $target->isa('SVK::Path::Checkout');
+    my $proj = SVK::Project->create_from_prop($target) if $target->isa('SVK::Path');
     $target = $target->source if $target->isa('SVK::Path::Checkout');
     $proj = SVK::Project->create_from_path(
 	$target->depot,

Modified: branches/bm/lib/SVK/Project.pm
==============================================================================
--- branches/bm/lib/SVK/Project.pm	(original)
+++ branches/bm/lib/SVK/Project.pm	Mon Nov 19 01:00:47 2007
@@ -72,35 +72,6 @@
 
 use List::MoreUtils 'apply';
 
-sub load {
-    my ($self, $pathobj) = @_;
-
-    my $fs              = $pathobj->depot->repos->fs;
-    my $root            = $fs->revision_root( $fs->youngest_rev );
-    my $allprops        = $root->node_proplist($pathobj->depot->depotname);
-    my ($depotroot)     = $pathobj->path =~ m{^(/[^/]+/[^/]+).*$};
-    my @projnames = 
-#	grep { $_ ne $project_name && (($project_name) = $_) }
-	grep { $_ =~ s/^svk:project:([^:]+):.*$/$1/ }
-	grep { $allprops->{$_} =~ /$depotroot/ } sort keys %{$allprops};
-    
-    return undef unless @projnames;
-    
-    my $project_name = $projnames[0];
-    my %props = 
-	map { $_ => $allprops->{'svk:project:'.$project_name.':'.$_} }
-	    ('path_trunk', 'path_branches', 'path_tags');
-    return SVK::Project->new(
-	{   
-	    name            => $project_name,
-	    depot           => $pathobj->depot,
-	    trunk           => $props{path_trunk},
-	    branch_location => $props{path_branches},
-	    tag_location    => $props{path_tags},
-	    local_root      => "/local/${project_name}",
-	});
-}
-
 sub branches {
     my ( $self, $match ) = @_;
 
@@ -137,6 +108,35 @@
     return \@branches;
 }
 
+sub create_from_prop {
+    my ($self, $pathobj) = @_;
+
+    my $fs              = $pathobj->depot->repos->fs;
+    my $root            = $fs->revision_root( $fs->youngest_rev );
+    my $allprops        = $root->node_proplist($pathobj->depot->depotname);
+    my ($depotroot)     = $pathobj->path =~ m{^(/[^/]+/[^/]+).*$};
+    my @projnames = 
+#	grep { $_ ne $project_name && (($project_name) = $_) }
+	grep { $_ =~ s/^svk:project:([^:]+):.*$/$1/ }
+	grep { $allprops->{$_} =~ /$depotroot/ } sort keys %{$allprops};
+    
+    return undef unless @projnames;
+    
+    my $project_name = $projnames[0];
+    my %props = 
+	map { $_ => $allprops->{'svk:project:'.$project_name.':'.$_} }
+	    ('path_trunk', 'path_branches', 'path_tags');
+    return SVK::Project->new(
+	{   
+	    name            => $project_name,
+	    depot           => $pathobj->depot,
+	    trunk           => $props{path_trunk},
+	    branch_location => $props{path_branches},
+	    tag_location    => $props{path_tags},
+	    local_root      => "/local/${project_name}",
+	});
+}
+
 sub create_from_path {
     my ($self, $depot, $path) = @_;
     my $rev = undef;


More information about the svk-commit mailing list