[svk-commit] r2608 - in branches/bm/lib/SVK: .
nobody at bestpractical.com
nobody at bestpractical.com
Fri Nov 16 22:05:29 EST 2007
Author: clsung
Date: Fri Nov 16 22:05:28 2007
New Revision: 2608
Modified:
branches/bm/lib/SVK/Command/Branch.pm
branches/bm/lib/SVK/Project.pm
Log:
- implements that if we have set project meta data in property,
we can load project from property.
- the property store in '/', versioned.
Modified: branches/bm/lib/SVK/Command/Branch.pm
==============================================================================
--- branches/bm/lib/SVK/Command/Branch.pm (original)
+++ branches/bm/lib/SVK/Command/Branch.pm Fri Nov 16 22:05:28 2007
@@ -83,11 +83,12 @@
sub run {
my ( $self, $target, @options ) = @_;
+ my $proj = SVK::Project->load($target) if $target->isa('SVK::Path');
my $source = $target->source;
- my $proj = SVK::Project->create_from_path(
+ $proj = SVK::Project->create_from_path(
$source->depot,
$source->path
- );
+ ) unless $proj;
print loc("Project mapped. Project name: %1.\n", $proj->name);
@@ -101,11 +102,12 @@
sub run {
my ($self, $target) = @_;
+ my $proj = SVK::Project->load($target) if $target->isa('SVK::Path');
$target = $target->source if $target->isa('SVK::Path::Checkout');
- my $proj = SVK::Project->create_from_path(
+ $proj = SVK::Project->create_from_path(
$target->depot,
$target->path
- );
+ ) unless $proj;
if (!$proj) {
print loc("No project branch founded.\n");
@@ -144,11 +146,12 @@
sub run {
my ($self, $target, $branch_path) = @_;
+ my $proj = SVK::Project->load($target) if $target->isa('SVK::Path');
my $source = $target->source;
- my $proj = SVK::Project->create_from_path(
+ $proj = SVK::Project->create_from_path(
$source->depot,
$source->path
- );
+ ) unless $proj;
my $trunk_path = '/'.$proj->depot->depotname.'/'.$proj->trunk;
my $newbranch_path = '/'.$proj->depot->depotname.'/'.
@@ -203,11 +206,12 @@
sub run {
my ($self, $target, $dst, $src) = @_;
+ my $proj = SVK::Project->load($target) if $target->isa('SVK::Path');
my $source = $target->source;
- my $proj = SVK::Project->create_from_path(
+ $proj = SVK::Project->create_from_path(
$source->depot,
$source->path
- );
+ ) unless $proj;
my $branch_path = '/'.$proj->depot->depotname.'/'.$proj->branch_location;
my $src_branch_path = $branch_path.'/'.$src.'/';
@@ -273,11 +277,12 @@
sub run {
my ($self, $target, $dst_path) = @_;
+ my $proj = SVK::Project->load($target) if $target->isa('SVK::Path');
my $source = $target->source;
- my $proj = SVK::Project->create_from_path(
+ $proj = SVK::Project->create_from_path(
$source->depot,
$source->path
- );
+ ) unless $proj;
my $target_path = '/'.$proj->depot->depotname.'/'.
($self->{local} ?
@@ -330,11 +335,12 @@
sub run {
my ($self, $target, $dst, @srcs) = @_;
+ my $proj = SVK::Project->load($target) if $target->isa('SVK::Path');
my $source = $target->source;
- my $proj = SVK::Project->create_from_path(
+ $proj = SVK::Project->create_from_path(
$source->depot,
$source->path
- );
+ ) unless $proj;
@srcs = map { $self->expand_branch($proj, $_) } @srcs;
@@ -391,11 +397,12 @@
sub run {
my ($self, $target, $new_path) = @_;
+ my $proj = SVK::Project->load($target) if $target->isa('SVK::Path');
my $source = $target->source;
- my $proj = SVK::Project->create_from_path(
+ $proj = SVK::Project->create_from_path(
$source->depot,
$source->path
- );
+ ) unless $proj;
my $newtarget_path = '/'.$proj->depot->depotname.'/'.
($self->{local} ?
Modified: branches/bm/lib/SVK/Project.pm
==============================================================================
--- branches/bm/lib/SVK/Project.pm (original)
+++ branches/bm/lib/SVK/Project.pm Fri Nov 16 22:05:28 2007
@@ -72,6 +72,35 @@
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 ) = @_;
@@ -110,7 +139,6 @@
sub create_from_path {
my ($self, $depot, $path) = @_;
- my $root;
my $rev = undef;
my $path_obj = SVK::Path->real_new(
More information about the svk-commit
mailing list