aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/BK-usage/cset-to-linus
blob: d28a96f8c61803e928e32630a435a8f6b4404f82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl -w

use strict;

my ($lhs, $rev, $tmp, $rhs, $s);
my @cset_text = ();
my @pipe_text = ();
my $have_cset = 0;

while (<>) {
	next if /^---/;

	if (($lhs, $tmp, $rhs) = (/^(ChangeSet\@)([^,]+)(, .*)$/)) {
		&cset_rev if ($have_cset);

		$rev = $tmp;
		$have_cset = 1;

		push(@cset_text, $_);
	}

	elsif ($have_cset) {
		push(@cset_text, $_);
	}
}
&cset_rev if ($have_cset);
exit(0);


sub cset_rev {
	my $empty_cset = 0;

	open PIPE, "bk export -tpatch -hdu -r $rev | diffstat -p1 2>/dev/null |" or die;
	while ($s = <PIPE>) {
		$empty_cset = 1 if ($s =~ /0 files changed/);
		push(@pipe_text, $s);
	}
	close(PIPE);

	if (! $empty_cset) {
		print @cset_text;
		print @pipe_text;
		print "\n\n";
	}

	@pipe_text = ();
	@cset_text = ();
}