[svk-commit] r2555 - branches/bm/lib/SVK
nobody at bestpractical.com
nobody at bestpractical.com
Fri Oct 19 21:51:59 EDT 2007
Author: clsung
Date: Fri Oct 19 21:51:59 2007
New Revision: 2555
Modified:
branches/bm/lib/SVK/Project.pm
Log:
- refine project create path finding
Modified: branches/bm/lib/SVK/Project.pm
==============================================================================
--- branches/bm/lib/SVK/Project.pm (original)
+++ branches/bm/lib/SVK/Project.pm Fri Oct 19 21:51:59 2007
@@ -120,20 +120,10 @@
);
$path_obj->refresh_revision;
- my $depotname = $depot->depotname;
- my ($mirror_path,$project_name) =
- $path_obj->depotpath =~ m{^/$depotname/(.*?)/([\w\-_]+(?=/(?:trunk|branches|tags))|[\w\-_]+$)};
-
- return 0 unless $project_name; # so? 0 means? need to deal with it.
-
- my ($trunk_path, $branch_path, $tag_path) =
- map { $mirror_path."/".$project_name."/".$_ } ('trunk', 'branches', 'tags');
- # check trunk, branch, tag, these should be metadata-ed
- for my $_path ($trunk_path, $branch_path, $tag_path) {
- # we check if the structure of mirror is correct
- # need more handle here
- die $! unless $SVN::Node::dir == $path_obj->root->check_path($_path);
- }
+ my ($project_name, $trunk_path, $branch_path, $tag_path) =
+ $self->_find_project_path($path_obj);
+
+ return undef unless $project_name;
return SVK::Project->new(
{
name => $project_name,
@@ -145,4 +135,32 @@
});
}
+sub _find_project_path {
+ my ($self, $path_obj) = @_;
+
+ my ($mirror_path,$project_name);
+ my ($trunk_path, $branch_path, $tag_path);
+ my $depotname = $path_obj->depot->depotname;
+ my ($path) = $path_obj->depotpath =~ m{^/$depotname/(.*)/?$};
+ while (!$project_name) {
+ ($mirror_path,$project_name) = # always assume the last entry the projectname
+ $path =~ m{^(.*)/([\w\-_]+)$};
+
+ return undef unless $project_name; # can' find any project_name
+
+ ($trunk_path, $branch_path, $tag_path) =
+ map { $mirror_path."/".$project_name."/".$_ } ('trunk', 'branches', 'tags');
+ # check trunk, branch, tag, these should be metadata-ed
+ # we check if the structure of mirror is correct, otherwise go again
+ for my $_path ($trunk_path, $branch_path, $tag_path) {
+ undef $project_name unless $SVN::Node::dir == $path_obj->root->check_path($_path);
+ }
+ # if not the last entry, then the mirror_path should contains
+ # trunk/branches/tags, otherwise no need to test
+ ($path) = $mirror_path =~ m{^(.+(?=/(?:trunk|branches|tags)))}
+ unless $project_name;
+ }
+ return ($project_name, $trunk_path, $branch_path, $tag_path);
+}
+
1;
More information about the svk-commit
mailing list