line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
# Copyright (c) 2007-2009 David Caldwell, All Rights Reserved. -*- perl -*- |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
2116
|
package Darcs::Notify; use base qw(Class::Accessor::Fast); use strict; use warnings; |
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
1599
|
|
|
1
|
|
|
|
|
4359
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
26
|
|
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
60
|
|
5
|
|
|
|
|
|
|
our $VERSION = '2.0.1'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Darcs::Notify->mk_accessors(qw(repo repo_name)); |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
926
|
use Darcs::Inventory; |
|
1
|
|
|
|
|
112914
|
|
|
1
|
|
|
|
|
18
|
|
10
|
1
|
|
|
1
|
|
1772
|
use Darcs::Inventory::Diff; |
|
1
|
|
|
|
|
883
|
|
|
1
|
|
|
|
|
83
|
|
11
|
1
|
|
|
1
|
|
8
|
use Cwd; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
68
|
|
12
|
1
|
|
|
1
|
|
7
|
use File::Basename; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
13
|
1
|
|
|
1
|
|
1867
|
use File::Copy "cp"; |
|
1
|
|
|
|
|
4008
|
|
|
1
|
|
|
|
|
837
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new($%) { |
16
|
0
|
|
|
0
|
1
|
|
my ($class, %option) = @_; |
17
|
0
|
|
0
|
|
|
|
my $self = bless { repo => $option{repo} || '.' }, $class; |
18
|
0
|
0
|
0
|
|
|
|
$self->{repo_name} ||= basename $self->{repo} eq '.' ? cwd : $self->{repo}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Remove the options we used from our options hash. What's left should only be notifiers. |
21
|
0
|
|
|
|
|
|
delete $option{$_} for keys %$self; |
22
|
0
|
|
|
|
|
|
for (keys %option) { |
23
|
0
|
|
|
|
|
|
my $class = "Darcs::Notify::$_"; |
24
|
0
|
0
|
0
|
|
|
|
$class->isa('Darcs::Notify::Base') or eval "use $class; 1" or die "Couldn't load $_ ($class): $!\n"; |
25
|
0
|
|
|
|
|
|
push @{$self->{notifier}}, $class->new(%{$option{$_}}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
} |
27
|
0
|
0
|
|
|
|
|
die "No notifiers passed to $class->new()! Please read the perldoc Darcs::Notify.\n" unless scalar @{$self->{notifier}}; |
|
0
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub notify($){ |
32
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
33
|
0
|
|
|
|
|
|
mkdir "$self->{repo}/_darcs/third-party"; |
34
|
0
|
|
|
|
|
|
mkdir "$self->{repo}/_darcs/third-party/darcs-notify"; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# This path is only here for legacy repos. |
37
|
0
|
|
|
|
|
|
my $old_inventory = "$self->{repo}/_darcs/third-party/darcs-notify-old-inventory"; |
38
|
|
|
|
|
|
|
# http://www.mail-archive.com/darcs-users@darcs.net/msg01347.html |
39
|
0
|
0
|
|
|
|
|
$old_inventory = "$self->{repo}/_darcs/third-party/darcs-notify/old-inventory" unless -f $old_inventory; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $pre = Darcs::Inventory->load($old_inventory); |
42
|
0
|
0
|
|
|
|
|
my $post = Darcs::Inventory->new($self->{repo}) or die "Couldn't get inventory from $self->{repo}"; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my ($new, $unpull) = Darcs::Inventory::Diff::diff($pre, $post); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
cp($post->file, $old_inventory); |
47
|
0
|
0
|
|
|
|
|
if (!$pre) { |
48
|
0
|
|
|
|
|
|
warn "Not sending any patch notifications on first run.\n". |
49
|
|
|
|
|
|
|
"'echo > \"$old_inventory\"' and re-run darcs-notify if you want notifications for your current ". |
50
|
|
|
|
|
|
|
scalar $post->patches, " patches.\n"; |
51
|
0
|
|
|
|
|
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
for (@{$self->{notifier}}) { |
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$_->notify($self, $new, $unpull); |
56
|
|
|
|
|
|
|
} |
57
|
0
|
0
|
|
|
|
|
scalar @$new || scalar @$unpull; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
__END__ |