sccscheck: see if backup files appear in SCCS history
authorTony Finch <dot@dotat.at>
Tue, 28 Oct 2014 17:05:07 +0000 (17:05 +0000)
committerTony Finch <dot@dotat.at>
Tue, 28 Oct 2014 17:05:07 +0000 (17:05 +0000)
sccscheck

index fd5612c..dfef881 100755 (executable)
--- a/sccscheck
+++ b/sccscheck
@@ -6,6 +6,7 @@ use strict;
 use feature 'switch';
 
 use File::Find;
+use POSIX;
 
 unless (@ARGV) {
        die <<USAGE;
@@ -39,8 +40,24 @@ sub found {
                        }
                }
                when (m{^(.*)/([^/]+)(\.orig|~)$}s) {
-                       if (-f "$1/SCCS/s.$2") {
-                               print "BACKSCCS $_\n";
+                       my $sccs = "$1/SCCS/s.$2";
+                       when (-f $sccs) {
+                               # was the backup checked in?
+                               my $mtime = strftime "%Y-%m-%d.%H:%M:%S%z",
+                                   localtime((stat)[9]);
+                               my $qsccs = quotemeta $sccs;
+                               my $qback = quotemeta $_;
+                               my @revs = qx{sccs prs -e -d:I: $qsccs};
+                               for my $rev (@revs) {
+                                       chomp $rev;
+                                       system "sccs get -s -k -p -r$rev $qsccs | diff -u - $qback >/dev/null";
+                                       if ($? == 0) {
+                                               print "BACKSCCS $rev $_\n";
+                                               break;
+                                       }
+                               }
+                               print "BACKSCCS NOMATCH $mtime $_\n";
+                               continue;
                        }
                        when (-f "$1/$2") {
                                my $qback = quotemeta $_;
@@ -65,13 +82,13 @@ sub found {
                }
                default {
                        m{^(.*)/([^/]+)$}s;
-                       my $sccs = "$1/SCCS/S.$2";
+                       my $sccs = "$1/SCCS/s.$2";
                        when (! -f $sccs) {
                                print "NO SCCS $_\n";
                        }
                        my $qsccs = quotemeta $sccs;
                        my $qfile = quotemeta $_;
-                       system "sccs get -k -p $qsccs | diff -u - $qfile";
+                       system "sccs get -s -k -p $qsccs | diff -u - $qfile";
                        print "DIFF $_\n" if $?;
                }
        }