[svk-commit] r3079 - in trunk: lib/SVK lib/SVK/Command t/bm

nobody at bestpractical.com nobody at bestpractical.com
Tue Sep 2 11:31:40 EDT 2008


Author: clsung
Date: Tue Sep  2 11:31:38 2008
New Revision: 3079

Modified:
   trunk/   (props changed)
   trunk/lib/SVK/Command/Branch.pm
   trunk/lib/SVK/Project.pm
   trunk/t/bm/online-offline-trunk.t
   trunk/t/bm/online-offline.t

Log:
 r19475 at clsung-laptop:  clsung | 2008-09-02 22:49:11 +0800
 - implements http://task.hm/GVQ2
 r19476 at clsung-laptop:  clsung | 2008-09-02 23:17:21 +0800
 - more tests about --online/--offline to trunk


Modified: trunk/lib/SVK/Command/Branch.pm
==============================================================================
--- trunk/lib/SVK/Command/Branch.pm	(original)
+++ trunk/lib/SVK/Command/Branch.pm	Tue Sep  2 11:31:38 2008
@@ -72,6 +72,7 @@
      'export'           => 'export',
      'from=s'           => 'from',
      'from-tag=s'       => 'fromtag',
+     'list-projects'    => 'listprojects',
      'local'            => 'local',
      'lump'             => 'lump',
      'project=s'        => 'project',
@@ -243,6 +244,35 @@
     return;
 }
 
+package SVK::Command::Branch::listprojects;
+use base qw(SVK::Command::Branch);
+use SVK::I18N;
+use SVK::Logger;
+
+sub parse_arg {
+    my ($self, @arg) = @_;
+
+    return ('');
+}
+
+sub run {
+    my $self = shift;
+
+    my ($target, $proj);
+    my @depots =  sort keys %{ $self->{xd}{depotmap} };
+    my $fmt = "%s (depot: %s)\n"; # here to change layout
+    foreach my $depot (@depots) {
+	$depot =~ s{/}{}g;
+	$target = eval { $self->arg_depotpath("/$depot/") };
+	next if ($@);
+	my $projs = SVK::Project->allprojects($target);
+	foreach my $proj (@{$projs}) {
+	    $logger->info (sprintf $fmt, $proj->name, $depot);
+	}
+    }
+    return;
+}
+
 package SVK::Command::Branch::create;
 use base qw( SVK::Command::Copy SVK::Command::Switch SVK::Command::Branch );
 use SVK::I18N;
@@ -1044,6 +1074,7 @@
 =head1 OPTIONS
 
  -l [--list]        : list branches for this project
+ --listprojects     : list avaliable projects
  --create           : create a new branch
  --tag              : create in the tags directory
  --local            : targets in local branch

Modified: trunk/lib/SVK/Project.pm
==============================================================================
--- trunk/lib/SVK/Project.pm	(original)
+++ trunk/lib/SVK/Project.pm	Tue Sep  2 11:31:38 2008
@@ -142,6 +142,24 @@
     }
 }
 
+sub allprojects {
+    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 = '';
+    my @projects;
+
+    foreach my $m_path (@all_mirrors) {
+	if ($pathobj->path eq '/') {
+	    my $proj = $self->_create_from_prop($pathobj, $root, $m_path);
+	    push @projects, $proj if $proj;
+	}
+    }
+    return \@projects;
+}
+
 sub create_from_prop {
     my ($self, $pathobj, $pname) = @_;
 

Modified: trunk/t/bm/online-offline-trunk.t
==============================================================================
--- trunk/t/bm/online-offline-trunk.t	(original)
+++ trunk/t/bm/online-offline-trunk.t	Tue Sep  2 11:31:38 2008
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 use strict;
 use SVK::Test;
-plan tests => 6;
+plan tests => 10;
 our $output;
 
 my ($xd, $svk) = build_test('test');
@@ -46,5 +46,25 @@
     qr|U   A/be|);
 
 is_output_like ($svk, 'info', [],
-   qr|Depot Path: //mirror/myproj/trunk|);
+    qr|Depot Path: //mirror/myproj/trunk|);
 
+is_output_like ($svk, 'branch', ['--offline','foo'],
+    qr|Project branch created: foo .in local.|);
+
+is_output ($svk, 'branch', [],
+    ["Project name: myproj",
+     "Branch: foo (offline)",
+     "Revision: 10",
+     "Repository path: //local/myproj/foo",
+     'Copied From: trunk at 9',
+     'Merged From: trunk at 9']);
+
+is_output ($svk, 'branch', ['--online','-C'],
+    ["We will copy branch //local/myproj/foo to //mirror/myproj/branches/foo",
+     "Then do a smerge on //mirror/myproj/branches/foo",
+     "Finally delete the src branch //local/myproj/foo"]);
+
+is_output ($svk, 'branch', ['--online', 'trunk', '-C'],
+    ["Auto-merging (0, 10) /local/myproj/foo to /mirror/myproj/trunk (base /mirror/myproj/trunk:9).",
+    "===> Auto-merging (0, 10) /local/myproj/foo to /mirror/myproj/trunk (base /mirror/myproj/trunk:9).",
+    "Empty merge."]);

Modified: trunk/t/bm/online-offline.t
==============================================================================
--- trunk/t/bm/online-offline.t	(original)
+++ trunk/t/bm/online-offline.t	Tue Sep  2 11:31:38 2008
@@ -104,7 +104,7 @@
 
 # online with a new branch name
 
-$svk->br('--online', 'release/abc'); # online the release/abc branch
+$svk->br('--online', 'release/abc'); # online and rename to the release/abc branch
 
 is_output_like ($svk, 'info', [],
    qr|Depot Path: //mirror/MyProject/branches/release/abc|);


More information about the svk-commit mailing list