[svk-commit] r2884 - trunk/lib/SVK
nobody at bestpractical.com
nobody at bestpractical.com
Sat May 17 03:47:20 EDT 2008
Author: clsung
Date: Sat May 17 03:47:20 2008
New Revision: 2884
Modified:
trunk/lib/SVK/Project.pm
Log:
- for a given path object, check which project it belongs
Modified: trunk/lib/SVK/Project.pm
==============================================================================
--- trunk/lib/SVK/Project.pm (original)
+++ trunk/lib/SVK/Project.pm Sat May 17 03:47:20 2008
@@ -153,6 +153,13 @@
grep { $allprops->{$_} =~ /$depotroot/ } sort keys %{$allprops};
}
+sub _project_paths {
+ my ($self, $allprops) = @_;
+ return
+ map { $allprops->{$_} => $_ }
+ grep { $_ =~ m/^svk:project/ } sort keys %{$allprops};
+}
+
sub _create_from_prop {
my ($self, $pathobj, $root, $prop_path, $pname, $from_local) = @_;
my $allprops = $root->node_proplist($from_local ? '/' : $prop_path);
@@ -359,4 +366,30 @@
}
}
}
+
+sub in_which_project {
+ my ($self, $pathobj) = @_;
+
+ my $fs = $pathobj->depot->repos->fs;
+ my $root = $fs->revision_root( $fs->youngest_rev );
+ my @all_mirrors = split "\n", $root->node_prop('/','svm:mirror') || '';
+ my $prop_path = '/';
+ foreach my $m_path (@all_mirrors) {
+ if ($pathobj->path =~ m/^$m_path/) {
+ $prop_path = $m_path;
+ last;
+ }
+ }
+ my $from_local = $pathobj->_to_pclass("/local")->subsumes($pathobj->path);
+ my $allprops = $root->node_proplist($from_local ? '/' : $prop_path);
+ my %projpaths = $self->_project_paths($allprops);
+ for my $path (sort { $b ne $a } keys %projpaths) { # reverse sort to ensure subsume
+ if ($pathobj->_to_pclass($prop_path.$path)->subsumes($pathobj->path) or
+ $pathobj->_to_pclass($pathobj->path)->subsumes($prop_path.$path)) {
+ my ($pname) = $projpaths{$path} =~ m/^svk:project:(.*?):path/;
+ return $pname;
+ }
+ }
+ return;
+}
1;
More information about the svk-commit
mailing list