[svk-commit] r2548 - in branches/bm: lib/SVK t/api

nobody at bestpractical.com nobody at bestpractical.com
Fri Oct 19 04:18:08 EDT 2007


Author: clkao
Date: Fri Oct 19 04:18:05 2007
New Revision: 2548

Added:
   branches/bm/lib/SVK/Project.pm
   branches/bm/t/api/project.t
Modified:
   branches/bm/MANIFEST

Log:
Basic SVK::Project class.

Modified: branches/bm/MANIFEST
==============================================================================
--- branches/bm/MANIFEST	(original)
+++ branches/bm/MANIFEST	Fri Oct 19 04:18:05 2007
@@ -135,6 +135,7 @@
 lib/SVK/Path/Checkout.pm
 lib/SVK/Path/Txn.pm
 lib/SVK/Path/View.pm
+lib/SVK/Project.pm
 lib/SVK/Resolve.pm
 lib/SVK/Resolve/AraxisMerge.pm
 lib/SVK/Resolve/Emacs.pm
@@ -289,6 +290,7 @@
 t/76ignore.t
 t/77floating.t
 t/api/mirror.t
+t/api/project.t
 t/api/root.t
 t/copy-escape.t
 t/copy-replace.t

Added: branches/bm/lib/SVK/Project.pm
==============================================================================
--- (empty file)
+++ branches/bm/lib/SVK/Project.pm	Fri Oct 19 04:18:05 2007
@@ -0,0 +1,78 @@
+# BEGIN BPS TAGGED BLOCK {{{
+# COPYRIGHT:
+# 
+# This software is Copyright (c) 2007 Best Practical Solutions, LLC
+#                                          <clkao at bestpractical.com>
+# 
+# (Except where explicitly superseded by other copyright notices)
+# 
+# 
+# LICENSE:
+# 
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of either:
+# 
+#   a) Version 2 of the GNU General Public License.  You should have
+#      received a copy of the GNU General Public License along with this
+#      program.  If not, write to the Free Software Foundation, Inc., 51
+#      Franklin Street, Fifth Floor, Boston, MA 02110-1301 or visit
+#      their web page on the internet at
+#      http://www.gnu.org/copyleft/gpl.html.
+# 
+#   b) Version 1 of Perl's "Artistic License".  You should have received
+#      a copy of the Artistic License with this package, in the file
+#      named "ARTISTIC".  The license is also available at
+#      http://opensource.org/licenses/artistic-license.php.
+# 
+# This work is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+# 
+# CONTRIBUTION SUBMISSION POLICY:
+# 
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of the
+# GNU General Public License and is only of importance to you if you
+# choose to contribute your changes and enhancements to the community
+# by submitting them to Best Practical Solutions, LLC.)
+# 
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with SVK,
+# to Best Practical Solutions, LLC, you confirm that you are the
+# copyright holder for those contributions and you grant Best Practical
+# Solutions, LLC a nonexclusive, worldwide, irrevocable, royalty-free,
+# perpetual, license to use, copy, create derivative works based on
+# those contributions, and sublicense and distribute those contributions
+# and any derivatives thereof.
+# 
+# END BPS TAGGED BLOCK }}}
+package SVK::Project;
+use strict;
+use SVK::Version;  our $VERSION = $SVK::VERSION;
+use base 'Class::Accessor::Fast';
+
+__PACKAGE__->mk_accessors(qw(name trunk branch_location tag_location local_root));
+
+=head1 NAME
+
+SVK::Project - SVK project class
+
+=head1 SYNOPSIS
+
+ See below
+
+=head1 DESCRIPTION
+
+The class represents a project within svk.
+
+=cut
+
+sub branches {
+    my ($self, $match) = @_;
+
+    return [];
+}
+
+1;

Added: branches/bm/t/api/project.t
==============================================================================
--- (empty file)
+++ branches/bm/t/api/project.t	Fri Oct 19 04:18:05 2007
@@ -0,0 +1,40 @@
+#!/usr/bin/perl -w
+use strict;
+use SVK::Test;
+plan tests => 5;
+our $output;
+
+use_ok('SVK::Project');
+
+my ($xd, $svk) = build_test('test');
+
+$svk->mkdir(-m => 'trunk', '/test/trunk');
+$svk->mkdir(-m => 'trunk', '/test/branches');
+$svk->mkdir(-m => 'trunk', '/test/tags');
+my $tree = create_basic_tree($xd, '/test/trunk');
+
+my $depot = $xd->find_depot('test');
+my $uri = uri($depot->repospath);
+
+$svk->mirror('//mirror/MyProject', $uri);
+
+my $proj = SVK::Project->new(
+    {   name            => 'MyProject',
+        depot           => $xd->find_depot(''),
+        trunk           => '/mirror/MyProject/trunk',
+        branch_location => '/mirror/MyProject/branches',
+        tag_location    => '/mirror/MyProject/tags',
+        local_root      => '/local/MyProject',
+    });
+
+isa_ok($proj, 'SVK::Project');
+
+is_deeply($proj->branches, [], 'no branches yet');
+
+$svk->cp(-m => 'branch Foo', '//mirror/MyProject', '//mirror/branches/Foo');
+
+is_deeply($proj->branches, ['Foo'], 'found 1 branch');
+
+$svk->cp(-pm => 'feature branch Bar', '//mirror/MyProject', '//mirror/branches/feature/Bar');
+
+is_deeply($proj->branches, ['Foo', 'feature/Bar'], 'found deep branches');


More information about the svk-commit mailing list