Skip to contentSkip to conversation

BK-kernel-tools/shortlog update

PATCH Matthias Andree 1 participant 1 message Mar 26, 2003

lore
Share & tools
lore
#0 lore raw

Hello Linus,

you can either use bk receive to patch this mail, you can pull from bk://krusty.dt.e-technik.uni-dortmund.de (NOTE: no trailing slash) or you can apply the patch below.

Patch description:
Update to upstream version 0.88:
* Add regexp support for address -> name resolution. (0.86)
* Add selftest mode to figure addresses that can be removed because they are also matched by regexps (0.88).

Matthias
##### DIFFSTAT #####

# shortlog |   77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
# 1 files changed, 66 insertions(+), 11 deletions(-)

##### GNUPATCH #####
# This is a BitKeeper generated patch for the following project:
# Project Name: BK kernel tools
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.43 -> 1.44
# shortlog 1.19 -> 1.20
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/03/26 [email protected] 1.44
# Update to upstream version 0.88:
# * Add regexp support for address -> name resolution. (0.86)
# * Add selftest mode to figure addresses that can be removed because they
# are also matched by regexps (0.88).
# --------------------------------------------
#

shortlog +66 -11
diff -Nru a/shortlog b/shortlog
@@ -8,7 +8,7 @@
 #			Tomas Szepe <[email protected]>
 #			Vitezslav Samel <[email protected]>
 #
-# $Id: lk-changelog.pl,v 0.85 2003/03/26 08:22:11 vita Exp $
+# $Id: lk-changelog.pl,v 0.88 2003/03/26 21:12:23 emma Exp $
 # ----------------------------------------------------------------------
 # Distribution of this script is permitted under the terms of the
 # GNU General Public License (GNU GPL) v2.
@@ -53,6 +53,8 @@
 use Text::Tabs;
 use Text::Wrap;
 
+sub selftest();
+
 # --------------------------------------------------------------------
 # customize the following line to change the indentation of the change
 # lines, $indent1 is used for the first line of an entry, $indent for
@@ -63,6 +65,11 @@
 my $debug = 0;
 # --------------------------------------------------------------------
 
+# Perl syntax magic here, "=>" is equivalent to ","
+my @addrregexps = (
+[ 'alan@.*\.swansea\.linux\.org\.uk' => 'Alan Cox', ],
+[ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' => '~~~~~~~~' ]);
+
 # the key is the email address in ALL LOWER CAPS!
 # the value is the real name of the person
 #
@@ -101,8 +108,6 @@
 '[email protected]' => 'Andrew Morton',
 '[email protected]' => 'Andrew Morton',
 '[email protected]' => 'Adam Kropelin', # lbdb
-'[email protected]' => 'Alan Cox',
-'[email protected]' => 'Alan Cox',
 '[email protected]' => 'Alan Cox',
 '[email protected]' => 'Alan Cox',
 '[email protected]' => 'Alexander Atanasov',
@@ -889,12 +894,27 @@
 
 my %address_unknown;
 
-# get name associated to an email address
-sub rmap_address {
-  my @o = map {defined $addresses{$_} ? $addresses{$_} :
-		 scalar (($address_unknown{$_} = 1), $_); }
-          map { lc; } @_;
-  return wantarray ? @o : $o[0];
+# get name associated with an "email address" formatted
+# BK_USER,BK_HOST tuple
+sub rmap_address($) {
+    my $in = shift;
+    my $key = lc $in;
+    # try hash lookup first, return result if any
+    if (defined $addresses{$key}) {
+	return $addresses{$key};
+    }
+    # try matching against all regexps in listed order
+    # return result if any
+    foreach my $ar (@addrregexps) {
+	if ($in =~ m/$ar->[0]/) {
+	    return $ar->[1];
+	}
+    }
+    # when the address is unknown, return the unchanged input
+    # and mark the address as unknown (so it can be printed in --warn
+    # mode).
+    $address_unknown{$key} = 1;
+    return $in;
 }
 
 # case insensitive string comparison
@@ -1274,12 +1294,26 @@
   return print $opt{width} ? expand(wrap("", "", ($a))) : $a, "\n";
 }
 
+sub selftest() {
+    my $rc = 0;
+    foreach my $address (keys %addresses) {
+	foreach my $ar (@addrregexps) {
+	    if ($address =~ m/$ar->[0]/) {
+		print STDERR "Warning: address '$address'\n";
+		print STDERR "  shadows regexp '$ar->[0]'\n";
+		$rc = 1;
+	    }
+	}
+    }
+    return $rc;
+}
+
 # === MAIN PROGRAM ===============================================
 # Command line arguments
 # What options do we support?
 my @opts = ("help|?|h", "man", "mode=s", "compress!", "count!", "width:i",
 	    "swap!", "merge!", "warn!", "multi!", "abbreviate-names!",
-	    "by-surname!");
+	    "by-surname!", "selftest");
 #	    "bitkeeper|bk!");
 
 # How do we parse them?
@@ -1311,7 +1345,8 @@
   unless defined $table{$opt{mode}};
 pod2usage(-verbose => 0,
 	  -message => "$0: No files given, refusing to read from a TTY.")
-  if (not $opt{bitkeeper} and (@ARGV == 0) and (-t STDIN));
+  if (not $opt{selftest} and not $opt{bitkeeper}
+	  and (@ARGV == 0) and (-t STDIN));
 pod2usage(-verbose => 0,
 	  -message => "$0: Must have one or two arguments in --bitkeeper mode.")
   if ($opt{bitkeeper} && (@ARGV < 1 || @ARGV > 2));
@@ -1358,6 +1393,10 @@
   foreach (@ARGV) { print STDERR "DEBUG:   '$_'\n"; }
 }
 
+if ($opt{selftest}) {
+    exit selftest;
+}
+
 # Main program
 my @prolog;
 my %log;
@@ -1406,6 +1445,18 @@
 __END__
 # --------------------------------------------------------------------
 # $Log: lk-changelog.pl,v $
+# Revision 0.88  2003/03/26 21:12:23  emma
+# Add selftest mode check:
+# * check all addresses against all regexps to find addresses shadowing
+#   regular expressions.
+#
+# Revision 0.87  2003/03/26 21:02:53  emma
+# Fix broken regexp for Alan's swansea.linux.org.uk addresses. Add some comments.
+#
+# Revision 0.86  2003/03/26 20:57:49  emma
+# Support regexp queries (but try hash lookups first for efficiency).
+# Requested by Linus Torvalds.
+#
 # Revision 0.85  2003/03/26 08:22:11  vita
 # Added 6 names for new addresses.
 #
@@ -1737,6 +1788,8 @@
      --width[=WIDTH] specify the line length, if omitted: $COLUMNS or 80.
                      text lines will not exceed this length.
 
+     --selftest      perform some self tests (for developers of this script)
+
 Warning: Neither --compress nor --count are currently functional with
 --mode=full.
 
@@ -1825,6 +1878,8 @@
 =head1 TODO
 
 =over
+
+=item * OBFUSCATE ADDRESSES (requested by Solar Designer)
 
 =item * --compress-me-harder
 

##### BKPATCH #####
This BitKeeper patch contains the following changesets:
1.44
## Wrapped with gzip_uu ##

begin 600 bkpatch306 M'XL(`-$9@CX``^U7VW+:2!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