rcs-checkin 3.9 KB

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