From 2fb8b146f74791d7cbe702292b8197913d437c75 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 1 Dec 2014 23:49:35 -0500 Subject: [PATCH] Remove clear-headers from VC's public method set. * vc/vc.el and all backends: API simplification; clear-headers is no longer a public method. It is now local to the one place it's used, in the RCS steal-lock method. --- lisp/ChangeLog | 6 ++++++ lisp/vc/vc-git.el | 1 - lisp/vc/vc-hg.el | 1 - lisp/vc/vc-rcs.el | 19 +++++++++++++++++-- lisp/vc/vc-src.el | 1 - lisp/vc/vc.el | 31 ------------------------------- 6 files changed, 23 insertions(+), 36 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6c2b33ea566..d005cbef920 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2014-12-02 Eric S. Raymond + + * vc/vc.el and all backends: API simplification; clear-headers + is no longer a public method. It is now local to the one place + it's used, in the RCS steal-lock method. + 2014-12-01 Eric S. Raymond * vc/vc.el and all backends: API simplification; could-register diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 93c5ff805f6..3538f2c3828 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -95,7 +95,6 @@ ;; - previous-revision (file rev) OK ;; - next-revision (file rev) OK ;; - check-headers () COULD BE SUPPORTED -;; - clear-headers () NOT NEEDED ;; - delete-file (file) OK ;; - rename-file (old new) OK ;; - find-file-hook () OK diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index b5be8d5f04c..35f5354da65 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -85,7 +85,6 @@ ;; - previous-revision (file rev) OK ;; - next-revision (file rev) OK ;; - check-headers () ?? -;; - clear-headers () ?? ;; - delete-file (file) TEST IT ;; - rename-file (old new) OK ;; - find-file-hook () added for bug#10709 diff --git a/lisp/vc/vc-rcs.el b/lisp/vc/vc-rcs.el index c9e4d409924..40a102789b9 100644 --- a/lisp/vc/vc-rcs.el +++ b/lisp/vc/vc-rcs.el @@ -528,7 +528,22 @@ Needs RCS 5.6.2 or later for -M." (vc-do-command "*vc*" 0 "rcs" (vc-master-name file) "-M" (concat "-u" rev)) ;; Do a real checkout after stealing the lock, so that we see ;; expanded headers. - (vc-do-command "*vc*" 0 "co" (vc-master-name file) "-f" (concat "-l" rev)))) + (vc-do-command "*vc*" 0 "co" (vc-master-name file) "-f" (concat "-l" rev)) + ;; Must clear any headers here because they wouldn't + ;; show that the file is locked now. + (let* ((filename (or file buffer-file-name)) + (visited (find-buffer-visiting filename))) + (if visited + (let ((context (vc-buffer-context))) + ;; save-excursion may be able to relocate point and mark + ;; properly. If it fails, vc-restore-buffer-context + ;; will give it a second try. + (save-excursion + (vc-rcs-clear-headers)) + (vc-restore-buffer-context context)) + (set-buffer (find-file-noselect filename)) + (vc-rcs-clear-headers) + (kill-buffer filename))))) (defun vc-rcs-modify-change-comment (files rev comment) "Modify the change comments change on FILES on a specified REV. If FILE is a @@ -943,7 +958,7 @@ Uses `rcs2log' which only works for RCS and CVS." \\(: [\t -#%-\176\240-\377]*\\)?\\$" nil t))) (defun vc-rcs-clear-headers () - "Implementation of vc-clear-headers for RCS." + "Clear RCS header value parts." (let ((case-fold-search nil)) (goto-char (point-min)) (while (re-search-forward diff --git a/lisp/vc/vc-src.el b/lisp/vc/vc-src.el index c93ff96fd29..f3d0585b30c 100644 --- a/lisp/vc/vc-src.el +++ b/lisp/vc/vc-src.el @@ -73,7 +73,6 @@ ;; - previous-revision (file rev) ?? ;; - next-revision (file rev) ?? ;; - check-headers () ?? -;; - clear-headers () ?? ;; - delete-file (file) ?? ;; * rename-file (old new) OK ;; - find-file-hook () NOT NEEDED diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 9e6b049e084..52deb13e4dd 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -514,15 +514,6 @@ ;; ;; Return non-nil if the current buffer contains any version headers. ;; -;; - clear-headers () -;; -;; In the current buffer, reset all version headers to their unexpanded -;; form. This function should be provided if the state-querying code -;; for this backend uses the version headers to determine the state of -;; a file. This function will then be called whenever VC changes the -;; version control state in such a way that the headers would give -;; wrong information. -;; ;; - delete-file (file) ;; ;; Delete FILE and mark it as deleted in the repository. If this @@ -1287,9 +1278,6 @@ For old-style locking-based version control systems, like RCS: "Claim lock retaining changes? "))) (progn (vc-call-backend backend 'steal-lock file) (clear-visited-file-modtime) - ;; Must clear any headers here because they wouldn't - ;; show that the file is locked now. - (vc-clear-headers file) (write-file buffer-file-name) (vc-mode-line file backend)) (if (not (yes-or-no-p @@ -2001,25 +1989,6 @@ the variable `vc-BACKEND-header'." (when (string-match (car f) buffer-file-name) (insert (format (cdr f) (car hdstrings))))))))))) -(defun vc-clear-headers (&optional file) - "Clear all version headers in the current buffer (or FILE). -The headers are reset to their non-expanded form." - (let* ((filename (or file buffer-file-name)) - (visited (find-buffer-visiting filename)) - (backend (vc-backend filename))) - (when (vc-find-backend-function backend 'clear-headers) - (if visited - (let ((context (vc-buffer-context))) - ;; save-excursion may be able to relocate point and mark - ;; properly. If it fails, vc-restore-buffer-context - ;; will give it a second try. - (save-excursion - (vc-call-backend backend 'clear-headers)) - (vc-restore-buffer-context context)) - (set-buffer (find-file-noselect filename)) - (vc-call-backend backend 'clear-headers) - (kill-buffer filename))))) - (defun vc-modify-change-comment (files rev oldcomment) "Edit the comment associated with the given files and revision." ;; Less of a kluge than it looks like; log-view mode only passes -- 2.39.5