Sometimes, a file under the control of RCS gets modified while it is not locked (= checked out for modification by me).

(In these cases, it was actually set read-only by RCS to prevent such modifications; but it might have been a configuration file under /etc/ which was modified because I was upgrading packages.)

And then usually I want to nevertheless commit the new modifications, as if the last revision has been checked out before the modification.

How is it best to proceed then?

I usually use Emacs VC, and do C-x v v to check out and in. But if the file hasn't been checked out beforehand, this fails. Is there a way to proceed specifically from within Emacs? But answers with shell commands are also welcome.


Actually it's much simpler. You can just do rcs -l to lock it, then try check it back in again.

I assume the situation when you asked the question was something like this:

$ echo v1 >foo
$ ci -u -t-"Test file." foo
$ chmod u+w foo
$ echo v2 >foo

At this point, both ci and co will fail:

$ co -l foo
foo,v  -->  foo
revision 1.1 (locked)
writable foo exists; remove it? [ny](n): 

$ ci -u foo
foo,v  <--  foo
ci: foo,v: no lock set by username

This is how you can lock the file and commit the changes:

$ rcs -l foo
RCS file: foo,v
1.1 locked
$ ci -u -m"Second revision." foo
foo,v  <--  foo
new revision: 1.2; previous revision: 1.1
  • Thanks! You've described the situation precisely. I remembered there was a simple option like this, having found out about it before, but when I ran into this problem this time, I only looked into the manpage for co, and didn't read carefully the manpage for rcs, that's probably why I couldn't find the rcs -l option again. – imz -- Ivan Zakharyaschev Apr 6 '14 at 7:41

A special mode of RCS operation, which is mentioned in the Emacs manual (info) in the VC section, could be an option of how to overcome such problems: Options for RCS and SCCS

By default, RCS uses locking to coordinate the activities of several users, but there is a mode called "non-strict locking" in which you can check-in changes without locking the file first. Use rcs -U to switch to non-strict locking for a particular file, see the rcs manual page for details.

But, of course, one might not want to switch to the non-strict mode.


Basic Unix commands can be used to achieve the goal. So, actually, it's not a big problem at all.

  1. copy/move the modified file out the way of RCS (cp FILE FILE.new, mv FILE FILE.new, or C-x C-w FILE.new in Emacs);
  2. check out (and lock) the last revision from RCS (co -l FILE or in Emacs: C-x C-f FILE -- open it again, and C-x v v);
  3. overwrite it with the new modifications;
  4. commit it (ci ... or in Emacs: C-x v v).

(Besides this basic way, other simpler ways to achieve the goal might be interesting, too, i.e., with a specific option for this case.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.