How to commit a modified file if it wasn’t locked by RCS beforehand (and I’m using Emacs VC mode)

emacs

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.

Best Answer

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
done
$ ci -u -m"Second revision." foo
foo,v  <--  foo
new revision: 1.2; previous revision: 1.1
done