home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk1.iso
/
altsrc
/
articles
/
10862
< prev
next >
Wrap
Lisp/Scheme
|
1994-07-12
|
6KB
|
195 lines
Newsgroups: alt.sources
Path: wupost!sdd.hp.com!spool.mu.edu!howland.reston.ans.net!swrinde!news.dell.com!tadpole.com!uunet!news.iij.ad.jp!wnoc-tyo-news!aist-nara!newspost.aist-nara.ac.jp!youki-k
From: youki-k@is.aist-nara.ac.jp (Youki Kadobayashi)
Subject: gnu2rcs: convert gnu-style version control to RCS
Message-ID: <YOUKI-K.94Jul12215044@alpha201.is.aist-nara.ac.jp>
Sender: news@newspost.aist-nara.ac.jp (USENET News System)
Nntp-Posting-Host: alpha201.aist-nara.ac.jp
Organization: Nara Institute of Science and Technology, Japan
Date: Tue, 12 Jul 1994 12:50:43 GMT
Lines: 183
If you have some large source code trees, and if you frequently obtain
patches from other net folks then you might find this script useful.
I regularly use it to keep my BSD source tree latest, while keeping
all changes logged.
----------------
This script may be useful after patching large source tree, e.g., /sys.
It enables quasi-automatic version deposit in conjunction with an
environment variable VERSION_CONTROL set to 'numbered', which tells
GNU version of patch to make backups with numbered suffix such as
".~1~", ".~2~" ...
I regularly use this script in the following scenario:
1. apply patch to /sys
2. repeat 1. several times
3. run "gnu2rcs -v /sys" to get every changes logged into RCS
// Youki Kadobayashi <youki-k@is.aist-nara.ac.jp>
// Graduate School of Information Science
// Nara Institute of Science and Technology, Japan
#!/bin/sh
# This is a shell archive (produced by shar 3.50)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 07/12/1994 12:44 UTC by youki-k@dec221
# Source directory /auto/home/is/youki-k/work/rcshack
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 3411 -rw-r--r-- gnu2rcs.pl
#
# ============= gnu2rcs.pl ==============
if test -f 'gnu2rcs.pl' -a X"$1" != X"-c"; then
echo 'x - skipping gnu2rcs.pl (File already exists)'
else
echo 'x - extracting gnu2rcs.pl (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnu2rcs.pl' &&
#!/usr/local/bin/perl
#
$usg = "gnu2rcs: convert gnu-style version control to RCS
gnu2rcs [-lnpv] [-m message] directory...
X -l only checkin the oldest version (with .~1~ suffix)
X -m message for RCS checkin
X -n don't execute; just print commands instead
X -p preserve numbered backup files
X -v verbose
X
do 'setenv VERSION_CONTROL numbered' to use in conjunction with GNU patch.
";
# Author: Youki Kadobayashi <youki@wide.ad.jp>
# $Header: /auto/home/is/youki-k/work/rcshack/RCS/gnu2rcs.pl,v 1.13 1994/07/03 19:57:11 youki-k Exp youki-k $
#
# This script may be useful after patching large source tree, e.g., /sys.
# It enables quasi-automatic version deposit in conjunction with an
# environment variable VERSION_CONTROL set to 'numbered', which tells
# GNU version of patch to make backups with numbered suffix such as
# ".~1~", ".~2~" ...
#
# I regularly use this script in the following scenario:
# 1. apply patch to /sys
# 2. repeat 1. several times
# 3. run "gnu2rcs -v /sys" to get every changes logged into RCS
#
# It should also work with GNU emacs with (setq version-control t).
# I haven't tried it yet, so I don't know how it's useful.
# Maybe you can run this script periodically, say under cron, which
# is effectively a poor man's 3DFS...
#
require "find.pl";
require "getopts.pl";
do Getopts('lm:npv');
X
if ($#ARGV < $[) {
X die $usg;
}
X
$message = $opt_m ? $opt_m : "checked in by gnu2rcs";
$| = 1;
# Traverse desired filesystems
foreach $dir (@ARGV) {
X &find($dir);
}
X
# fake call to wanted and do the possibly remaining job.
$name = $_ = '/';
&wanted;
X
Xexit 0;
X
sub wanted {
X local ($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_);
X local ($e, $path, $version, $i, $v, $pwd);
X next if (-l $_);
X if (-d $_) {
X next if ($name =~ m|/RCS|);
X foreach $path (keys %v_from) {
X print "processing $path..." if $opt_v;
X &rename2($path, "$path.~new~");
X if ($opt_l) {
X print "$v_from{$path}..\n" if $opt_v;
X $version = "${path}.~${v_from{$path}}~";
X &rename2($version, $path);
X $e = &deposit($path);
X &rename2($path, $version) if $opt_p || $e;
X } else {
X for ($i = $v_from{$path}; $i <= $v_to{$path}; ++$i) {
X print "$i.." if $opt_v;
X $version = "${path}.~${i}~";
X &rename2($version, $path);
X $e = &deposit($path);
X &rename2($path, $version) if $opt_p || $e;
X }
X print "done\n" if $opt_v;
X }
X &rename2("$path.~new~", $path);
X &deposit($path);
X }
X undef %v_from;
X undef %v_to;
X }
X elsif (-f $_) {
X next if ($dir =~ m|/RCS|);
X if (/.~(\d+)~$/) {
X $v = $1;
X if (-f $`) {
X chop($pwd = `pwd`);
X $path = "$pwd/$`";
X print "found $name\n" if $opt_v;
X if (!defined($v_from{$path}) || $v < $v_from{$path}) {
X $v_from{$path} = $v;
X }
X if (!defined($v_to{$path}) || $v > $v_to{$path}) {
X $v_to{$path} = $v;
X }
X if (! -d "$pwd/RCS") {
X $opt_n ? print "mkdir $pwd/RCS\n" :
X mkdir("RCS", 0775) || die "mkdir RCS: $!";
X }
X }
X }
X }
}
X
sub rename2 {
X local ($from, $to) = @_;
X if ($opt_n) {
X print "mv $from $to\n";
X } else {
X rename ($from, $to) || warn "rename $from: $!";
X }
}
X
sub deposit {
X local ($path) = @_;
X local ($e);
X
X if ($opt_n) {
X print "ci -u -t/dev/null -m'$message' $path\n";
X print "co -l $path\n";
X return;
X }
X
X $e = system "ci -q -u -t/dev/null -m'$message' $path";
X $e /= 256; return $e if $e;
X $e = system "co -q -l $path";
X $e /= 256;
}
SHAR_EOF
chmod 0644 gnu2rcs.pl ||
echo 'restore of gnu2rcs.pl failed'
Wc_c="`wc -c < 'gnu2rcs.pl'`"
test 3411 -eq "$Wc_c" ||
echo 'gnu2rcs.pl: original size 3411, current size' "$Wc_c"
fi
exit 0
--
// $BLgNS(B $BM:4p(B <youki-k@is.aist-nara.ac.jp>
// $BBg:eBg3X4pAC9)3XIt>pJs9)3X2J(B / $BF`NI@hC<2J3X5;=QBg3X1!Bg3X(B