[Bps-public-commit] r10876 - in svb: lib

jesse at bestpractical.com jesse at bestpractical.com
Mon Feb 18 15:17:54 EST 2008


Author: jesse
Date: Mon Feb 18 15:17:47 2008
New Revision: 10876

Added:
   svb/bin/
   svb/bin/svb-create
   svb/bin/svb-ls
   svb/lib/
   svb/lib/SVB.pm

Log:
* This is not code you should be playing with yet

Added: svb/bin/svb-create
==============================================================================
--- (empty file)
+++ svb/bin/svb-create	Mon Feb 18 15:17:47 2008
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use SVB;
+
+my %args = @ARGV;
+my %props;
+for my $name (keys %args) {
+    die "$name doesn't look like --prop-name" if ($name !~ /^--/);
+
+    $name =~ /^--(.*)$/;
+  
+    $props{$1} = $args{$name};
+
+}
+
+
+my $svb = SVB->new();
+my $bug = SVN::PropDB::Record->new(handle => $svb->handle, type => 'bug');
+$bug->create( props =>{%props});
+print "Created bug ".$bug->uuid."\n";

Added: svb/bin/svb-ls
==============================================================================
--- (empty file)
+++ svb/bin/svb-ls	Mon Feb 18 15:17:47 2008
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use SVB;
+
+my $regex;
+unless  ($regex = shift @ARGV) {
+   die "Specify a regular expression and we'll search for bugs matching that regex"
+}
+
+
+my $svb = SVB->new();
+
+my $bugs = SVN::PropDB::Collection->new(handle => $svb->handle, type => 'bug');
+$bugs->matching( sub {
+            my $item = shift; 
+            map { return 1 if $item->prop(name => $_) =~ $regex} keys %{ $item->get_props};
+            return 0
+            });
+
+for (@{$bugs->as_array_ref}) {
+    printf ("%s %s %s \n", $_->uuid, $_->prop(name => 'subject')||"(no subject)", $_->prop(name => 'status')||'(no summary)');
+
+}

Added: svb/lib/SVB.pm
==============================================================================
--- (empty file)
+++ svb/lib/SVB.pm	Mon Feb 18 15:17:47 2008
@@ -0,0 +1,28 @@
+use warnings;
+use strict;
+
+package SVB;
+
+use SVN::PropDB;
+use SVN::PropDB::Handle;
+use SVN::PropDB::Collection;
+use Path::Class;
+
+use base qw/Class::Accessor/;
+__PACKAGE__->mk_accessors(qw/handle/);
+
+sub new {
+    my $class = shift;
+    my $self = {};
+    bless $self, $class;
+    $self->_init();
+    return $self;
+
+}
+
+sub _init {
+    my $self = shift;
+    $self->handle( SVN::PropDB::Handle->new( repository => dir($ENV{'HOME'},'.svb'), db_root => '_svb'));
+
+};
+1;



More information about the Bps-public-commit mailing list