[Bps-public-commit] wifty branch, master, updated. fcbe984f29797a2388880e963c444798ae657460
Thomas Sibley
trs at bestpractical.com
Sat Aug 14 00:16:40 EDT 2010
The branch, master has been updated
via fcbe984f29797a2388880e963c444798ae657460 (commit)
from 7943ee80731022b101abb303c2887bf725160383 (commit)
Summary of changes:
bin/grep-revisions | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
create mode 100755 bin/grep-revisions
- Log -----------------------------------------------------------------
commit fcbe984f29797a2388880e963c444798ae657460
Author: Thomas Sibley <trs at bestpractical.com>
Date: Sat Aug 14 00:18:14 2010 -0400
Add a tool for finding the first revision that includes a string
diff --git a/bin/grep-revisions b/bin/grep-revisions
new file mode 100755
index 0000000..01cff30
--- /dev/null
+++ b/bin/grep-revisions
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use Jifty;
+BEGIN { Jifty->new }
+
+my $pagename = shift;
+my $text = shift;
+
+unless ( defined $pagename and defined $text ) {
+ print "usage: $0 page string\n";
+ exit 1;
+}
+
+use Wifty::CurrentUser;
+use Wifty::Model::Page;
+use Wifty::Model::RevisionCollection;
+
+my $superuser = Wifty::CurrentUser->superuser;
+
+my $page = Wifty::Model::Page->new( $superuser );
+$page->load_by_cols( name => $pagename );
+
+die "Unable to find page '$pagename'\n" unless $page->id;
+
+my $revs = $page->revisions;
+$revs->limit(
+ column => 'content',
+ operator => 'MATCHES',
+ value => $text,
+);
+$revs->order_by( column => 'created', order => 'asc' );
+$revs->set_page_info( current_page => 1, per_page => 1 );
+
+my $match = $revs->first;
+
+print "No matches" unless $match and $match->id;
+
+print "Created: ", $match->created, "\n";
+print "Author: ", $match->created_by->friendly_name, "\n\n";
+
+my $diff = $match->diff_from( $match->previous, STYLE => 'Text::Diff::Unified' );
+
+# Workaround a bug in Text::Diff when there are trailing newline differences
+$diff =~ s/^-(.+?) ?\+\1\r$/$1/m;
+
+print "$diff\n";
+
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list