comparison lib-src/rcs-checkin @ 2273:576b71164157

Initial revision
author Eric S. Raymond <esr@snark.thyrsus.com>
date Fri, 19 Mar 1993 23:01:33 +0000
parents
children c70f9af7c66a
comparison
equal deleted inserted replaced
2272:0e1b3507ee15 2273:576b71164157
1 #!/bin/sh
2
3 case $# in
4 0)
5 echo "rcs-checkin: usage: rcs-checkin file ..."
6 echo "rcs-checkin: function: checks file.~*~ and file into a new RCS file"
7 echo "rcs-checkin: function: uses the file's first line for the description"
8 esac
9
10 # expr pattern to extract owner from ls -l output
11 ls_owner_pattern='[^ ][^ ]* *[^ ][^ ]* *\([^ ][^ ]*\)'
12
13 for file
14 do
15 # Check that file is readable.
16 <$file || exit
17
18 # Make it easier to say `rcs-checkin *'
19 # by ignoring file names that already contain `~', or end in `,v'.
20 case $file in
21 *~* | *,v) continue
22 esac
23 # Ignore non-files too.
24 test -f "$file" || continue
25
26 # If the RCS file does not already exist,
27 # initialize it with a description from $file's first line.
28 rlog -R "$file" >/dev/null 2>&1 ||
29 rcs -i -q -t-"`sed 1q $file`" "$file" || exit
30
31 # Get list of old files.
32 oldfiles=`
33 ls $file.~[0-9]*~ 2>/dev/null |
34 sort -t~ -n +1
35 `
36
37 # Check that they are properly sorted by date.
38 case $oldfiles in
39 ?*)
40 oldfiles_by_date=`ls -rt $file $oldfiles`
41 test " $oldfiles
42 $file" = " $oldfiles_by_date" || {
43 echo >&2 "rcs-checkin: skipping $file, because its mod times are out of order.
44
45 Sorted by mod time:
46 $oldfiles_by_date
47
48 Sorted by name:
49 $oldfiles
50 $file"
51 continue
52 }
53 esac
54
55 echo >&2 rcs-checkin: checking in: $oldfiles $file
56
57 # Save $file as $file.~-~ temporarily.
58 mv "$file" "$file.~-~" || exit
59
60 # Rename each old file to $file, and check it in.
61 for oldfile in $oldfiles
62 do
63 mv "$oldfile" "$file" || exit
64 ls_l=`ls -l "$file"` || exit
65 owner=-w`expr " $ls_l" : " $ls_owner_pattern"` || owner=
66 ci -d -l -q $owner "$file" </dev/null || exit
67 done
68
69 # Bring $file back from $file.~-~, and check it in.
70 mv "$file.~-~" "$file" || exit
71 ls_l=`ls -l "$file"` || exit
72 owner=-w`expr " $ls_l" : " $ls_owner_pattern"` || owner=
73 ci -d -q -u $owner -m"entered into RCS" "$file" || exit
74 done
75