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

nobody at bestpractical.com nobody at bestpractical.com
Tue May 6 20:23:31 EDT 2008


Author: clsung
Date: Tue May  6 20:23:30 2008
New Revision: 2810

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

Log:
- use Path::Class to handle directories
  - should use more :)
- fix t/api/project_from_path.t

Modified: trunk/lib/SVK/Command/Branch.pm
==============================================================================
--- trunk/lib/SVK/Command/Branch.pm	(original)
+++ trunk/lib/SVK/Command/Branch.pm	Tue May  6 20:23:30 2008
@@ -362,6 +362,7 @@
 use base qw( SVK::Command::Smerge SVK::Command::Branch);
 use SVK::I18N;
 use SVK::Util qw( is_uri abs_path );
+use Path::Class;
 
 use constant narg => 1;
 
@@ -411,7 +412,7 @@
 
     for my $src (@srcs) {
 	my $src_branch_path = $proj->depotpath_in_branch_or_tag($src);
-	$src_branch_path =  '/'.$proj->depot->depotname.'/'.$proj->trunk
+	$src_branch_path =  '/'.dir($proj->depot->depotname,$proj->trunk)
 	    if $src eq 'trunk';
 	$src = $self->arg_depotpath($src_branch_path);
 

Modified: trunk/lib/SVK/Project.pm
==============================================================================
--- trunk/lib/SVK/Project.pm	(original)
+++ trunk/lib/SVK/Project.pm	Tue May  6 20:23:30 2008
@@ -51,6 +51,7 @@
 package SVK::Project;
 use strict;
 use SVK::Version;  our $VERSION = $SVK::VERSION;
+use Path::Class;
 use base 'Class::Accessor::Fast';
 
 __PACKAGE__->mk_accessors(
@@ -240,11 +241,12 @@
             return ($project_name, $trunk_path, $branch_path, $tag_path) if $result > 0;
         }
         $project_name = '';
+        $path = '';
     }
     # not found in inverse layout, else 
-    ($path) = $current_path =~ m{^/(.*?)(?:/(?:trunk|branches/.*?|tags/.*?))?/?$};
+    ($path) = $current_path =~ m{^(.*?)(?:/(?:trunk|branches/.*?|tags/.*?))?/?$};
 
-    if ($path =~ m{^local/([^/]+)/?}) { # guess if in local branch
+    if ($path =~ m{^/local/([^/]+)/?}) { # guess if in local branch
 	# should only be 1 entry
 	($path) = grep {/\/$1$/} $path_obj->depot->mirror->entries;
 	$path =~ s#^/##;
@@ -264,6 +266,7 @@
 	($path) = $mirror_path =~ m{^(.+(?=/(?:trunk|branches|tags)))}
 	    unless $result != 0;
 	$tag_path = '' if $result == 2;
+	$project_name = '' unless $result;
 	return undef unless $path;
     }
     return ($project_name, $trunk_path, $branch_path, $tag_path);
@@ -272,9 +275,9 @@
 sub depotpath_in_branch_or_tag {
     my ($self, $name) = @_;
     # return 1 for branch, 2 for tag, others => 0
-    return '/'.$self->depot->depotname.'/'.$self->branch_location.'/'.$name
+    return '/'.dir($self->depot->depotname,$self->branch_location,$name)
 	if grep { $_ eq $name } @{$self->branches};
-    return '/'.$self->depot->depotname.'/'.$self->tag_location.'/'.$name
+    return '/'.dir($self->depot->depotname,$self->tag_location,$name)
 	if grep { $_ eq $name } @{$self->tags};
     return ;
 }


More information about the svk-commit mailing list