Author: timbo
Date: Mon Jun 11 05:49:27 2007
New Revision: 9637

Added:
   dbi/trunk/dbixs_rev.h
   dbi/trunk/dbixs_rev.pl
Modified:
   dbi/trunk/Changes
   dbi/trunk/DBIXS.h
   dbi/trunk/MANIFEST
   dbi/trunk/Makefile.PL

Log:
Added DBIXS_REVISION macro and mechanism to update it


Modified: dbi/trunk/Changes
==============================================================================
--- dbi/trunk/Changes   (original)
+++ dbi/trunk/Changes   Mon Jun 11 05:49:27 2007
@@ -37,9 +37,7 @@
 Add trace modules that just records the last N trace messages into an array
 and prepends them to any error message.
 
-=head2 Changes in DBI 1.57 (svn rev XXX),  XX May 2007
-
-XXX Add a DBI_REVISION macro that drivers can use
+=head2 Changes in DBI 1.57 (svn rev XXX),  XX June 2007
 
   Fixed XS versions of select*_*() methods to call execute()
     fetch() etc., with inner handle instead of outer.
@@ -53,6 +51,7 @@
   Added support for !Time and !Time~N to DBI::Profile Path.
   Added extra trace info to connect_cached thanks to Walery Studennikov.
   Added non-random (deterministic) mode to DBI_GOFER_RANDOM mechanism.
+  Added DBIXS_REVISION macro that drivers can use.
 
   DBI::ProfileDumper changes:
     Don't write file if there's no profile data.

Modified: dbi/trunk/DBIXS.h
==============================================================================
--- dbi/trunk/DBIXS.h   (original)
+++ dbi/trunk/DBIXS.h   Mon Jun 11 05:49:27 2007
@@ -27,6 +27,9 @@
 #undef std
 #endif
 
+/* define DBIXS_REVISION */
+#include "dbixs_rev.h"
+
 /* Perl backwards compatibility definitions */
 #include "dbipport.h"
 
@@ -41,6 +44,7 @@
  * and learns from the needs of various drivers.  See also the
  * DBISTATE_VERSION macro below. You can think of DBIXS_VERSION as
  * being a compile time check and DBISTATE_VERSION as a runtime check.
+ * By contract, DBIXS_REVISION is a driver source compatibility tool.
  */
 #define DBIXS_VERSION 93
 

Modified: dbi/trunk/MANIFEST
==============================================================================
--- dbi/trunk/MANIFEST  (original)
+++ dbi/trunk/MANIFEST  Mon Jun 11 05:49:27 2007
@@ -18,6 +18,8 @@
 dbiprof.PL
 dbiproxy.PL                    Frontend for DBI::ProxyServer
 dbivport.h                     DBI version portability macros (for drivers to 
copy)
+dbixs_rev.h                    Defines DBIXS_REVISION macro holding DBIXS.h 
subversion revision number
+dbixs_rev.pl                   Utility to write dbixs_rev.h
 ex/perl_dbi_nulls_test.pl      A test script for forms of IS NULL 
qualification in SQL
 ex/profile.pl                   A test script for DBI::Profile
 lib/Bundle/DBI.pm              A bundle for automatic installation via CPAN.
@@ -94,3 +96,4 @@
 t/pod.t
 test.pl                        Assorted informal tests, including tests for 
memory leaks
 typemap
+META.yml                                 Module meta-data (added by MakeMaker)

Modified: dbi/trunk/Makefile.PL
==============================================================================
--- dbi/trunk/Makefile.PL       (original)
+++ dbi/trunk/Makefile.PL       Mon Jun 11 05:49:27 2007
@@ -297,6 +297,9 @@
     my $xst = main::dbd_postamble();
     $xst =~ s/\$\(BASEEXT\)/Perl/g;
     $xst .= '
+dbixs_rev.h: DBIXS.h Driver_xst.h dbipport.h dbivport.h dbixs_rev.pl
+       $(PERL) dbixs_rev.pl
+
 DBI.c: Perl$(OBJ_EXT)
 
 # make Changes file available as installed pod docs "perldoc DBI::Changes"

Added: dbi/trunk/dbixs_rev.h
==============================================================================
--- (empty file)
+++ dbi/trunk/dbixs_rev.h       Mon Jun 11 05:49:27 2007
@@ -0,0 +1,2 @@
+/* Code modified since last checkin */
+#define DBIXS_REVISION 9632

Added: dbi/trunk/dbixs_rev.pl
==============================================================================
--- (empty file)
+++ dbi/trunk/dbixs_rev.pl      Mon Jun 11 05:49:27 2007
@@ -0,0 +1,42 @@
+#!perl -w
+use strict;
+
+my $file = "dbixs_rev.h";
+my $svnversion = `svnversion -n`;
+my $is_make_dist;
+
+if ($svnversion eq 'exported') {
+    $svnversion = `svnversion -n ..`;
+    if (-f "../MANIFEST.SKIP") {
+        # presumably we're in a subdirectory because the user is doing a 'make 
dist'
+        $is_make_dist = 1;
+    }
+    else {
+        # presumably we're being run by an end-user because their file 
timestamps
+        # got messed up
+        print "Skipping regeneration of $file\n";
+        utime(time(), time(), $file); # update modification time
+        exit 0;
+    }
+}
+
+my @warn;
+die "Neither current directory nor parent directory are an svn working copy\n"
+    unless $svnversion and $svnversion =~ m/^\d+/;
+push @warn, "Mixed revision working copy"
+    if $svnversion =~ s/:\d+//;
+push @warn, "Code modified since last checkin"
+    if $svnversion =~ s/[MS]+$//;
+warn "$file warning: $_\n" for @warn;
+die "$0 failed\n" if $is_make_dist && @warn;
+
+write_header($file, DBIXS_REVISION => $svnversion, [EMAIL PROTECTED]);
+
+sub write_header {
+    my ($file, $macro, $version, $comments_ref) = @_;
+    open my $fh, ">$file" or die "Can't open $file: $!\n";
+    print $fh "/* $_ */\n" for @$comments_ref;
+    print $fh "#define $macro $version\n";
+    close $fh or die "Error closing $file: $!\n";
+    print "Wrote $macro $version to $file\n";
+}

Reply via email to