Gentoo Archives: gentoo-commits

From: Kent Fredric <kentfredric@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/perl-overlay:master commit in: scripts/
Date: Tue, 31 Jul 2012 03:04:46
Message-Id: 1343694948.077c56991ca754e120779d002824ba6cff99ddea.kent@gentoo
1 commit: 077c56991ca754e120779d002824ba6cff99ddea
2 Author: Kent Fredric <kentfredric <AT> gmail <DOT> com>
3 AuthorDate: Tue Jul 31 00:35:48 2012 +0000
4 Commit: Kent Fredric <kentfredric <AT> gmail <DOT> com>
5 CommitDate: Tue Jul 31 00:35:48 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/perl-overlay.git;a=commit;h=077c5699
7
8 [scripts] add my diff itemization scripts Ive been using for a while
9
10 ---
11 scripts/itemise_diff_distinfo.pl | 44 +++++++++++
12 scripts/itemise_diff_distmap.pl | 150 ++++++++++++++++++++++++++++++++++++++
13 2 files changed, 194 insertions(+), 0 deletions(-)
14
15 diff --git a/scripts/itemise_diff_distinfo.pl b/scripts/itemise_diff_distinfo.pl
16 new file mode 100644
17 index 0000000..ad9819f
18 --- /dev/null
19 +++ b/scripts/itemise_diff_distinfo.pl
20 @@ -0,0 +1,44 @@
21 +#!/usr/bin/env perl
22 +
23 +use strict;
24 +use warnings;
25 +use 5.12.1;
26 +
27 +# FILENAME: itemise_diff.pl
28 +# CREATED: 17/04/12 04:06:11 by Kent Fredric (kentnl) <kentfredric@×××××.com>
29 +# ABSTRACT: Show the relevant parts from git diff
30 +
31 +my $fh;
32 +if ( not @ARGV ) {
33 + $fh = *STDIN;
34 +}
35 +else {
36 + open $fh, '<', $ARGV[0] or die;
37 +}
38 +
39 +my @seen;
40 +my @seen_status;
41 +
42 +my $archive;
43 +
44 +while ( defined( my $line = <$fh> ) ) {
45 + chomp $line;
46 + push @seen, $line;
47 + if ( $line =~ /^([+-]|)\s+"archive_canon"\s+:\s+"([^"]+)"/ ) {
48 + my $polarity = $1;
49 + $archive = $2;
50 + say "new: $archive" if $polarity eq '+';
51 + }
52 + if ( $line =~ /^([+-])\s+"status"\s+:\s+"([^"]+)"/ ) {
53 + my ( $stat, $value ) = ( "$1", "$2" );
54 + my $current = [ $stat, $value , $archive];
55 + push @seen_status, $current;
56 + my $has_prev = exists $seen_status[-2];
57 + my $prev;
58 + $prev = $seen_status[-2] if $has_prev;
59 +
60 + if ( $has_prev and $current->[1] eq 'backpan' and $prev->[1] ne 'backpan' and $prev->[2] eq $current->[2] and $current->[0] eq '+' and $prev->[0] eq '-' ) {
61 + say "del: $archive";
62 + }
63 + }
64 +}
65
66 diff --git a/scripts/itemise_diff_distmap.pl b/scripts/itemise_diff_distmap.pl
67 new file mode 100644
68 index 0000000..b69bad2
69 --- /dev/null
70 +++ b/scripts/itemise_diff_distmap.pl
71 @@ -0,0 +1,150 @@
72 +#!/usr/bin/env perl
73 +
74 +use strict;
75 +use warnings;
76 +use 5.12.1;
77 +
78 +# FILENAME: itemise_diff.pl
79 +# CREATED: 17/04/12 04:06:11 by Kent Fredric (kentnl) <kentfredric@×××××.com>
80 +# ABSTRACT: Show the relevant parts from git diff
81 +
82 +my $fh;
83 +if ( not @ARGV ) {
84 + $fh = *STDIN;
85 +}
86 +else {
87 + open $fh, '<', $ARGV[0] or die;
88 +}
89 +
90 +my @seen;
91 +my @seen_status;
92 +
93 +my $category = "";
94 +my $package = "";
95 +my $repo = "";
96 +
97 +my $dstash = {};
98 +my $stash_key = "";
99 +my $in_versions;
100 +
101 +sub process_stash {
102 + my ( $key ) = @_;
103 + #say "* $key";
104 + if ( not exists $dstash->{$key} ) {
105 + #say "-- no stash";
106 + return;
107 + }
108 + if ( not keys %{$dstash->{$key}} ) {
109 + #say "-- no keys";
110 + return;
111 + }
112 + for my $keyname ( keys %{$dstash->{$key}} ) {
113 + my $value = $dstash->{$key}->{$keyname};
114 + if ( $value eq '+' ) {
115 + say "newversion $key @ $keyname";
116 + } else {
117 + say "removed $key @ $keyname";
118 + }
119 + }
120 +}
121 +sub set_package {
122 + my ( $polarity, $_package ) = @_;
123 + $package = $_package;
124 + $in_versions = undef;
125 +}
126 +
127 +sub set_repo {
128 + my ( $polarity, $_repo ) = @_;
129 + $repo = $_repo;
130 + say "\nADD $category/${package}::$repo\n" if $polarity eq '+';
131 + say "\nTREECLEAN $category/${package}::$repo\n" if $polarity eq '-';
132 +
133 +}
134 +
135 +sub set_category {
136 + my ( $_category ) = @_;
137 + $category = $_category;
138 + $package = "";
139 + $in_versions = undef;
140 +}
141 +
142 +sub set_version_plus {
143 + my ( $key, $version ) = @_;
144 + if ( not exists $dstash->{$key} ){
145 + $dstash->{$key} = {};
146 + }
147 + if ( not exists $dstash->{$key}->{$version} ) {
148 + $dstash->{$key}->{$version} = '+';
149 + return;
150 + }
151 + if ( $dstash->{$key}->{$version} eq '-' ) {
152 + delete $dstash->{$key}->{$version};
153 + return;
154 + }
155 + die "Wut";
156 +}
157 +sub set_version_minus {
158 + my ( $key, $version ) = @_;
159 + if ( not exists $dstash->{$key} ){
160 + $dstash->{$key} = {};
161 + }
162 + if ( not exists $dstash->{$key}->{$version} ) {
163 + $dstash->{$key}->{$version} = '-';
164 + return;
165 + }
166 + if ( $dstash->{$key}->{$version} eq '+' ) {
167 + delete $dstash->{$key}->{$version};
168 + return;
169 + }
170 + die "Wut";
171 +}
172 +
173 +
174 +while ( defined( my $line = <$fh> ) ) {
175 + chomp $line;
176 + push @seen, $line;
177 + my $last_pkg = $package;
178 +
179 + $stash_key = "$category/${package}::$repo";
180 +
181 + if ( $line =~ /^([+-]|)\s+"category"\s+:\s+"([^"]+)"/ ) {
182 + set_category($2);
183 + }
184 + if ( $line =~ /^([+-]|)\s+"package"\s+:\s+"([^"]+)"/ ) {
185 + set_package( $1, $2 );
186 + }
187 + if ( $line =~ /^([+-]|)\s+"repository"\s+:\s+"([^"]+)"/ ) {
188 + set_repo($1, $2 );
189 + }
190 +
191 + if ( $last_pkg ne $package and $last_pkg ne "" ) {
192 + process_stash( $stash_key );
193 + next;
194 + }
195 +
196 +
197 + if ( $line =~ /^([+-]|)\s+"versions_gentoo"\s+:\s+\[/ ) {
198 + $in_versions = 1;
199 + next;
200 + }
201 + if ( $in_versions && $line =~ /^([+-]|)\s+\]/ ){
202 + $in_versions = undef;
203 + next;
204 + }
205 +
206 + next if not $in_versions;
207 +
208 + if ( $in_versions && $line =~ /^([+-])\s+"([^"]+)"/ ){
209 + my $polarity = $1;
210 + my $version = $2;
211 + if ( $polarity eq '+' ) {
212 + set_version_plus( $stash_key, $version );
213 + next;
214 + } else {
215 + set_version_minus( $stash_key, $version );
216 + next;
217 + }
218 + }
219 +
220 +}
221 +process_stash($stash_key);