1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-24 06:20:43 -08:00

The vc-mistrust-permissions configuration variable is gone.

* vc/vc-cvs.el, vc/vc-hooks.el, vc/vc-rcs.el, vc/vc-sccs.el: Eliminate
vc-mistrust-permissions.  It was only relevant to the RCS and SCCS
back ends and defaulted to t. Code now always mistrusts permissions -
by actual measurement the effect on performance is negligible. As a
side effect bug#11490 is now irrelevant.
This commit is contained in:
Eric S. Raymond 2014-12-01 09:08:26 -05:00
parent f82f3f1f17
commit 33b4235db6
6 changed files with 21 additions and 113 deletions

View file

@ -1,5 +1,12 @@
2014-12-01 Eric S. Raymond <esr@snark.thyrsus.com> 2014-12-01 Eric S. Raymond <esr@snark.thyrsus.com>
* vc/vc-cvs.el, vc/vc-hooks.el, vc/vc-rcs.el, vc/vc-sccs.el:
Eliminate vc-mistrust-permissions. It was only relevant to the
RCS and SCCS back ends and defaulted to t. Code now always
mistrusts permissions - by actual measurement the effect on
performance is negligible. As a side effect bug#11490 is now
irrelevant.
* vc/vc.el, vc-hooks.el, and all backends: API simplification; * vc/vc.el, vc-hooks.el, and all backends: API simplification;
vc-workfile-unchanged-p is no longer a public method (but the RCS vc-workfile-unchanged-p is no longer a public method (but the RCS
and SCCS back ends retain it as a private method used in state and SCCS back ends retain it as a private method used in state

View file

@ -48,9 +48,9 @@
;; If the file is not writable (despite CVSREAD being ;; If the file is not writable (despite CVSREAD being
;; undefined), this is probably because the file is being ;; undefined), this is probably because the file is being
;; "watched" by other developers. ;; "watched" by other developers.
;; (If vc-mistrust-permissions was t, we actually shouldn't ;; (We actually shouldn't trust this, but there is
;; trust this, but there is no other way to learn this from ;; no other way to learn this from CVS at the
;; CVS at the moment (version 1.9).) ;; moment (version 1.9).)
(string-match "r-..-..-." (nth 8 attrib))) (string-match "r-..-..-." (nth 8 attrib)))
'announce 'announce
'implicit)))))) 'implicit))))))

View file

@ -170,22 +170,6 @@ control systems."
:type 'boolean :type 'boolean
:group 'vc) :group 'vc)
;; If you fix bug#11490, probably you can set this back to nil.
(defcustom vc-mistrust-permissions t
"If non-nil, don't assume permissions/ownership track version-control status.
If nil, do rely on the permissions.
See also variable `vc-consult-headers'."
:version "24.3" ; nil->t, bug#11490
:type 'boolean
:group 'vc)
(defun vc-mistrust-permissions (file)
"Internal access function to variable `vc-mistrust-permissions' for FILE."
(or (eq vc-mistrust-permissions 't)
(and vc-mistrust-permissions
(funcall vc-mistrust-permissions
(vc-backend-subdirectory-name file)))))
(defcustom vc-stay-local 'only-file (defcustom vc-stay-local 'only-file
"Non-nil means use local operations when possible for remote repositories. "Non-nil means use local operations when possible for remote repositories.
This avoids slow queries over the network and instead uses heuristics This avoids slow queries over the network and instead uses heuristics

View file

@ -155,51 +155,6 @@ For a description of possible values, see `vc-check-master-templates'."
'unlocked-changes 'unlocked-changes
'edited)))))) 'edited))))))
(defun vc-rcs-state-heuristic (file)
"State heuristic for RCS."
(let (vc-rcs-headers-result)
(if (and vc-consult-headers
(setq vc-rcs-headers-result
(vc-rcs-consult-headers file))
(eq vc-rcs-headers-result 'rev-and-lock))
(let ((state (vc-file-getprop file 'vc-state)))
;; If the headers say that the file is not locked, the
;; permissions can tell us whether locking is used for
;; the file or not.
(if (and (eq state 'up-to-date)
(not (vc-mistrust-permissions file))
(file-exists-p file))
(cond
((string-match ".rw..-..-." (nth 8 (file-attributes file)))
(vc-file-setprop file 'vc-checkout-model 'implicit)
(setq state
(if (vc-rcs-workfile-is-newer file)
'edited
'up-to-date)))
((string-match ".r-..-..-." (nth 8 (file-attributes file)))
(vc-file-setprop file 'vc-checkout-model 'locking))))
state)
(if (not (vc-mistrust-permissions file))
(let* ((attributes (file-attributes file 'string))
(owner-name (nth 2 attributes))
(permissions (nth 8 attributes)))
(cond ((and permissions (string-match ".r-..-..-." permissions))
(vc-file-setprop file 'vc-checkout-model 'locking)
'up-to-date)
((and permissions (string-match ".rw..-..-." permissions))
(if (eq (vc-rcs-checkout-model file) 'locking)
(if (file-ownership-preserved-p file)
'edited
owner-name)
(if (vc-rcs-workfile-is-newer file)
'edited
'up-to-date)))
(t
;; Strange permissions. Fall through to
;; expensive state computation.
(vc-rcs-state file))))
(vc-rcs-state file)))))
(autoload 'vc-expand-dirs "vc") (autoload 'vc-expand-dirs "vc")
(defun vc-rcs-dir-status (dir update-function) (defun vc-rcs-dir-status (dir update-function)
@ -1098,7 +1053,7 @@ Returns: nil if no headers were found
'rev-and-lock if revision and lock info was found" 'rev-and-lock if revision and lock info was found"
(cond (cond
((not (get-file-buffer file)) nil) ((not (get-file-buffer file)) nil)
((let (status version locking-user) ((let (status version)
(with-current-buffer (get-file-buffer file) (with-current-buffer (get-file-buffer file)
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
@ -1124,11 +1079,11 @@ Returns: nil if no headers were found
(cond (cond
;; unlocked revision ;; unlocked revision
((looking-at "\\$") ((looking-at "\\$")
(setq locking-user 'none) ;;(setq locking-user 'none)
(setq status 'rev-and-lock)) (setq status 'rev-and-lock))
;; revision is locked by some user ;; revision is locked by some user
((looking-at "\\([^ ]+\\) \\$") ((looking-at "\\([^ ]+\\) \\$")
(setq locking-user (match-string-no-properties 1)) ;;(setq locking-user (match-string-no-properties 1))
(setq status 'rev-and-lock)) (setq status 'rev-and-lock))
;; everything else: false ;; everything else: false
(nil))) (nil)))
@ -1146,39 +1101,19 @@ Returns: nil if no headers were found
(goto-char (point-min)) (goto-char (point-min))
(if (re-search-forward (concat "\\$" "Locker:") nil t) (if (re-search-forward (concat "\\$" "Locker:") nil t)
(cond ((looking-at " \\([^ ]+\\) \\$") (cond ((looking-at " \\([^ ]+\\) \\$")
(setq locking-user (match-string-no-properties 1)) ;;(setq locking-user (match-string-no-properties 1))
(setq status 'rev-and-lock)) (setq status 'rev-and-lock))
((looking-at " *\\$") ((looking-at " *\\$")
(setq locking-user 'none) ;;(setq locking-user 'none)
(setq status 'rev-and-lock)) (setq status 'rev-and-lock))
(t (t
(setq locking-user 'none) ;;(setq locking-user 'none)
(setq status 'rev-and-lock))) (setq status 'rev-and-lock)))
(setq status 'rev))) (setq status 'rev)))
;; else: nothing found ;; else: nothing found
;; ------------------- ;; -------------------
(t nil)))) (t nil))))
(if status (vc-file-setprop file 'vc-working-revision version)) (if status (vc-file-setprop file 'vc-working-revision version))
(and (eq status 'rev-and-lock)
(vc-file-setprop file 'vc-state
(cond
((eq locking-user 'none) 'up-to-date)
((string= locking-user (vc-user-login-name file))
'edited)
(t locking-user)))
;; If the file has headers, we don't want to query the
;; master file, because that would eliminate all the
;; performance gain the headers brought us. We therefore
;; use a heuristic now to find out whether locking is used
;; for this file. If we trust the file permissions, and the
;; file is not locked, then if the file is read-only we
;; assume that locking is used for the file, otherwise
;; locking is not used.
(not (vc-mistrust-permissions file))
(vc-up-to-date-p file)
(if (string-match ".r-..-..-." (nth 8 (file-attributes file)))
(vc-file-setprop file 'vc-checkout-model 'locking)
(vc-file-setprop file 'vc-checkout-model 'implicit)))
status)))) status))))
(defun vc-release-greater-or-equal (r1 r2) (defun vc-release-greater-or-equal (r1 r2)

View file

@ -132,29 +132,6 @@ For a description of possible values, see `vc-check-master-templates'."
locking-user))) locking-user)))
'up-to-date)))) 'up-to-date))))
(defun vc-sccs-state-heuristic (file)
"SCCS-specific state heuristic."
(if (not (vc-mistrust-permissions file))
;; This implementation assumes that any file which is under version
;; control and has -rw-r--r-- is locked by its owner. This is true
;; for both RCS and SCCS, which keep unlocked files at -r--r--r--.
;; We have to be careful not to exclude files with execute bits on;
;; scripts can be under version control too. Also, we must ignore the
;; group-read and other-read bits, since paranoid users turn them off.
(let* ((attributes (file-attributes file 'string))
(owner-name (nth 2 attributes))
(permissions (nth 8 attributes)))
(if (string-match ".r-..-..-." permissions)
'up-to-date
(if (string-match ".rw..-..-." permissions)
(if (file-ownership-preserved-p file)
'edited
owner-name)
;; Strange permissions.
;; Fall through to real state computation.
(vc-sccs-state file))))
(vc-sccs-state file)))
(autoload 'vc-expand-dirs "vc") (autoload 'vc-expand-dirs "vc")
(defun vc-sccs-dir-status (dir update-function) (defun vc-sccs-dir-status (dir update-function)

View file

@ -590,6 +590,11 @@
;; moves closer to emulating modern non-locking behavior even on very ;; moves closer to emulating modern non-locking behavior even on very
;; old VCSes. ;; old VCSes.
;; ;;
;; - the vc-mistrust-permissions configuration variable is gone; the
;; code no longer relies on permissions except in one corner case where
;; CVS leaves no alternative (which was not gated by this variable). The
;; only affected back ends were SCCS and RCS.
;;
;; - The init-revision function and the default-initial-revision ;; - The init-revision function and the default-initial-revision
;; variable are gone. These have't made sense on anything shipped ;; variable are gone. These have't made sense on anything shipped
;; since RCS, and using them was a dumb stunt even on RCS. ;; since RCS, and using them was a dumb stunt even on RCS.