emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: VC, read-only buffers for writable files


From: Andre Spiegel
Subject: Re: VC, read-only buffers for writable files
Date: 22 Oct 2002 16:35:55 +0200

On Tue, 2002-10-22 at 15:31, Stefan Monnier wrote:

> Currently VC sometimes makes a file read-only because it thinks it's
> better that way for the user.  More specifically, it makes it read-only
> if the file seems to be locked by another user.

I have talked this over with Stefan several times, and we have reached
no agreement.  I'll be happy to let the general public (or Richard, for
that matter :-) decide.

> This special behavior used to apply to SCCS, RCS and CVS under Emacs-20
> and was silently changed in Emacs-21 to only apply to RCS and SCCS (it was
> changed as a side effect of another change).  Nobody complained about
> this change and I think we should go further and remove this hack
> altogether so it doesn't aply to RCS and SCCS either.

The behavior wasn't changed accidentally for CVS.  There are no locks
under CVS, and Emacs-21 handles that correctly by not assuming that a
file could be "locked" by anybody.  RCS and SCCS do have locks, and
Emacs-21 deliberately chooses to enforce the locking.  This is not a
"hack".  If people don't want that, so be it, then we'll change it.

Here is the relevant portion of code from vc-hooks.el, since the
comments may make it clearer to everybody.

    ;; If the file is locked by some other user, make
    ;; the buffer read-only.  Like this, even root
    ;; cannot modify a file that someone else has locked.
    (and (equal file (buffer-file-name))
         (stringp (vc-state file))
         (setq buffer-read-only t))
    ;; If the user is root, and the file is not owner-writable,
    ;; then pretend that we can't write it
    ;; even though we can (because root can write anything).
    ;; This way, even root cannot modify a file that isn't locked.
    (and (equal file (buffer-file-name))
         (not buffer-read-only)
         (zerop (user-real-uid))
         (zerop (logand (file-modes (buffer-file-name)) 128))
         (setq buffer-read-only t)))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]