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