rcs-checkin 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #! /bin/sh
  2. # This script accepts any number of file arguments and checks them into RCS.
  3. # Copyright (C) 1993-1995, 2001-2012 Free Software Foundation, Inc.
  4. # This file is part of GNU Emacs.
  5. # GNU Emacs is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. # GNU Emacs is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. # You should have received a copy of the GNU General Public License
  14. # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  15. # Arguments which are detectably either RCS masters (with names ending in ,v)
  16. # or Emacs version files (with names of the form foo.~<number>~) are ignored.
  17. # For each file foo, the script looks for Emacs version files related to it.
  18. # These files are checked in as deltas, oldest first, so that the contents of
  19. # the file itself becomes the latest revision in the master.
  20. #
  21. # The first line of each file is used as its description text. The file itself
  22. # is not deleted, as under VC with vc-keep-workfiles at its default of t, but
  23. # all the version files are.
  24. #
  25. # If an argument file is already version-controlled under RCS, any version
  26. # files are added to the list of deltas and deleted, and then the workfile
  27. # is checked in again as the latest version. This is probably not quite
  28. # what was wanted, and is the main reason VC doesn't simply call this to
  29. # do checkins.
  30. #
  31. # This script is intended to be used to convert files with an old-Emacs-style
  32. # version history for use with VC (the Emacs 19 version-control interface),
  33. # which likes to use RCS as its back end. It was written by Paul Eggert
  34. # and revised/documented for use with VC by Eric S. Raymond, Mar 19 1993.
  35. case $# in
  36. 0)
  37. echo "rcs-checkin: usage: rcs-checkin file ..."
  38. echo "rcs-checkin: function: checks file.~*~ and file into a new RCS file"
  39. echo "rcs-checkin: function: uses the file's first line for the description"
  40. esac
  41. # expr pattern to extract owner from ls -l output
  42. ls_owner_pattern='[^ ][^ ]* *[^ ][^ ]* *\([^ ][^ ]*\)'
  43. for file
  44. do
  45. # Make it easier to say `rcs-checkin *'
  46. # by ignoring file names that already contain `~', or end in `,v'.
  47. case $file in
  48. *~* | *,v) continue
  49. esac
  50. # Ignore non-files too.
  51. test -f "$file" || continue
  52. # Check that file is readable.
  53. test -r "$file" || exit
  54. # If the RCS file does not already exist,
  55. # initialize it with a description from $file's first line.
  56. rlog -R "$file" >/dev/null 2>&1 ||
  57. rcs -i -q -t-"`sed 1q $file`" "$file" || exit
  58. # Get list of old files.
  59. oldfiles=`
  60. ls $file.~[0-9]*~ 2>/dev/null |
  61. sort -t~ -n -k 2
  62. `
  63. # Check that they are properly sorted by date.
  64. case $oldfiles in
  65. ?*)
  66. oldfiles_by_date=`ls -rt $file $oldfiles`
  67. test " $oldfiles
  68. $file" = " $oldfiles_by_date" || {
  69. echo >&2 "rcs-checkin: skipping $file, because its mod times are out of order.
  70. Sorted by mod time:
  71. $oldfiles_by_date
  72. Sorted by name:
  73. $oldfiles
  74. $file"
  75. continue
  76. }
  77. esac
  78. echo >&2 rcs-checkin: checking in: $oldfiles $file
  79. # Save $file as $file.~-~ temporarily.
  80. mv "$file" "$file.~-~" || exit
  81. # Rename each old file to $file, and check it in.
  82. for oldfile in $oldfiles
  83. do
  84. mv "$oldfile" "$file" || exit
  85. ls_l=`ls -l "$file"` || exit
  86. owner=-w`expr " $ls_l" : " $ls_owner_pattern"` || owner=
  87. echo "Formerly ${oldfile}" | ci -d -l -q $owner "$file" || exit
  88. done
  89. # Bring $file back from $file.~-~, and check it in.
  90. mv "$file.~-~" "$file" || exit
  91. ls_l=`ls -l "$file"` || exit
  92. owner=-w`expr " $ls_l" : " $ls_owner_pattern"` || owner=
  93. ci -d -q -u $owner -m"entered into RCS" "$file" || exit
  94. done