line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 2007-2012 David Caldwell, All Rights Reserved. -*- perl -*- |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
2574
|
package Darcs::Inventory::Diff; use warnings; use strict; |
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
755
|
|
4
|
|
|
|
|
|
|
require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(darcs_inventory_diff); |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
*darcs_inventory_diff = \&diff; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub hashify($) { |
9
|
2
|
|
|
2
|
0
|
4
|
my $order = 0; |
10
|
2
|
50
|
|
|
|
8
|
return () unless defined $_[0]; |
11
|
7
|
|
|
|
|
27
|
map { |
12
|
2
|
|
|
|
|
14
|
my $diffable = $_->raw; |
13
|
7
|
|
|
|
|
195
|
$diffable =~ s/^hash:.*//m; # Hashes can change but still be the same patch (patches before it in the inventory may affect its line numbers) |
14
|
7
|
|
|
|
|
51
|
$diffable => { order => $order++, patch => $_ } |
15
|
|
|
|
|
|
|
} $_[0]->patches; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub unhashify($) { |
19
|
2
|
|
|
2
|
0
|
4
|
my ($h) = @_; |
20
|
2
|
|
|
|
|
10
|
map { $h->{$_}->{patch} } sort { $h->{$a}->{order} <=> $h->{$b}->{order} } keys %$h; |
|
1
|
|
|
|
|
12
|
|
|
0
|
|
|
|
|
0
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub diff($$) { |
24
|
1
|
|
|
1
|
0
|
580
|
my ($a, $b) = @_; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
5
|
my %a = hashify $a; |
27
|
1
|
|
|
|
|
5
|
my %b = hashify $b; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
8
|
my %not_in_b = %a; |
30
|
1
|
|
|
|
|
5
|
my %not_in_a = %b; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
7
|
foreach my $k (keys %a) { |
33
|
4
|
|
|
|
|
10
|
delete $not_in_a{$k}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
4
|
foreach my $k (keys %b) { |
37
|
3
|
|
|
|
|
6
|
delete $not_in_b{$k}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
5
|
return ([unhashify \%not_in_a], |
41
|
|
|
|
|
|
|
[unhashify \%not_in_b]); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
__END__ |