aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvapier <vapier@gentoo.org>2009-11-30 22:58:51 +0000
committervapier <vapier@gentoo.org>2009-11-30 22:58:51 +0000
commit659534ea4af9dd22ec5650f84e47ec8b1f8b1485 (patch)
treeb5d3bc7d98c923282a755ad7e5b1f3d6d347f368
parentFix bug 292932, thanks to Alexis Ballier <aballier@gentoo.org>. (diff)
downloadgentoolkit-659534ea4af9dd22ec5650f84e47ec8b1f8b1485.tar.gz
gentoolkit-659534ea4af9dd22ec5650f84e47ec8b1f8b1485.tar.bz2
gentoolkit-659534ea4af9dd22ec5650f84e47ec8b1f8b1485.zip
ekeyword: store keywords internally rather than using external diff to better handle multiline changes and output control simpler
svn path=/trunk/gentoolkit-dev/; revision=701
-rwxr-xr-xsrc/ekeyword/ekeyword25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/ekeyword/ekeyword b/src/ekeyword/ekeyword
index 244a054..e38801d 100755
--- a/src/ekeyword/ekeyword
+++ b/src/ekeyword/ekeyword
@@ -7,11 +7,8 @@
# ekeyword: Update the KEYWORDS in an ebuild. For example:
#
# $ ekeyword ~alpha oaf-0.6.8-r1.ebuild
-# 12c12
-# < KEYWORDS="ppc sparc x86"
-# ---
-# > KEYWORDS="~alpha ppc sparc x86"
-
+# - ppc sparc x86
+# + ~alpha ppc sparc x86
my ($kw_re) = '^(?:([-~^]?)(\w[\w-]*)|([-^]\*))$';
my (@kw);
@@ -43,6 +40,8 @@ for my $f (@ARGV) {
open O, ">$f.new" or die "Can't create $f.new: $!\n";
select O;
+ my $keys_before;
+ my $keys_after;
while (<I>) {
if (/^\s*KEYWORDS=/) {
@@ -53,6 +52,7 @@ for my $f (@ARGV) {
$_ = join " ", $_, $next;
}
(my $quoted = $_) =~ s/^.*?["'](.*?)["'].*/$1/s;
+ $keys_before = $quoted;
# replace -* with -STAR for our convenience below
$quoted =~ s/-\*/-STAR/;
@@ -109,6 +109,8 @@ for my $f (@ARGV) {
$sa cmp $sb;
} split " ", $quoted;
+ $keys_after = $quoted;
+
# re-insert quoted to KEYWORDS
s/(["']).*?["']/$1$quoted$1/;
@@ -122,7 +124,18 @@ for my $f (@ARGV) {
close O;
select STDOUT;
- system "diff -U 0 $f $f.new | sed -n '/KEYWORDS=/s:^: :p'";
+ if ($keys_before ne $keys_after) {
+ # This gives uniform output, but actually seems to make
+ # it harder to pick out differences, and doesn't work so
+ # well when adding/removing keywords
+ #$keys_before =~ s/(^| )/ /g;
+ #$keys_before =~ s/ ([-~])/$1/g;
+ #$keys_after =~ s/(^| )/ /g;
+ #$keys_after =~ s/ ([-~])/$1/g;
+ print " - $keys_before\n + $keys_after\n";
+ #system "diff -U 0 $f $f.new | sed -n -r 's:^(.)[[:space:]]*KEYWORDS=\"(.*)\": \\1 \\2:p'";
+ #system "diff -U 0 $f $f.new | sed -n '/KEYWORDS=/s:^: :p'";
+ }
rename "$f.new", "$f" or die "Can't rename: $!\n";
$files++;
}