add 0.2.2.27-beta changelog to master
[tor.git] / contrib / findMergedChanges.pl
blob460424f309a2597fe304226661371d0aa769664a
1 #!/usr/bin/perl
3 use warnings;
4 use strict;
6 sub nChanges {
7 my ($branches, $fname) = @_;
8 local *F;
9 # requires perl 5.8. Avoids shell issues if we ever get a changes
10 # file named by the parents of Little Johnny Tables.
11 open F, "-|", "git", "log", "--pretty=format:%H", $branches, "--", $fname
12 or die "$!";
13 my @changes = <F>;
14 return scalar @changes
17 my $look_for_type = "merged";
19 if (! @ARGV) {
20 print <<EOF
21 Usage:
22 findMergedChanges.pl [--merged/--unmerged/--weird/--list] changes/*
24 A change is "merged" if it has ever been merged to release-0.2.2 and it has had
25 no subsequent changes in master.
27 A change is "unmerged" if it has never been merged to release-0.2.2 and it
28 has had changes in master.
30 A change is "weird" if it has been merged to release-0.2.2 and it *has* had
31 subsequent changes in master.
33 Suggested application:
34 findMergedChanges.pl --merged changes/* | xargs -n 1 git rm
36 EOF
39 while (@ARGV and $ARGV[0] =~ /^--/) {
40 my $flag = shift @ARGV;
41 if ($flag =~ /^--(weird|merged|unmerged|list)/) {
42 $look_for_type = $1;
43 } else {
44 die "Unrecognized flag $flag";
48 for my $changefile (@ARGV) {
49 my $n_merged = nChanges("origin/release-0.2.2", $changefile);
50 my $n_postmerged = nChanges("origin/release-0.2.2..origin/master", $changefile);
51 my $type;
53 if ($n_merged != 0 and $n_postmerged == 0) {
54 $type = "merged";
55 } elsif ($n_merged == 0 and $n_postmerged != 0) {
56 $type = "unmerged";
57 } else {
58 $type = "weird";
61 if ($type eq $look_for_type) {
62 print "$changefile\n";
63 } elsif ($look_for_type eq 'list') {
64 printf "% 8s: %s\n", $type, $changefile;