summaryrefslogtreecommitdiff
path: root/Documentation/BK-usage/csets-to-patches
blob: e2b81c35883f225a61b69fe3c9621d88de64f0ec (plain)
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
#!/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;

	system("bk export -tpatch -du -r $rev > /tmp/rev-$rev.patch");

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

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