mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
API simplification: remove vc-workfile-unchanged-p from pubic methods.
* vc/vc.el, vc-hooks.el, and all backends: API simplification; 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 computation). This method was redundant with vc-state and usually implemented as a trivial call to same. Fixes the failure mode described in bug#694.
This commit is contained in:
parent
2532d74a5f
commit
f82f3f1f17
12 changed files with 17 additions and 77 deletions
|
|
@ -1,5 +1,12 @@
|
|||
2014-12-01 Eric S. Raymond <esr@snark.thyrsus.com>
|
||||
|
||||
* vc/vc.el, vc-hooks.el, and all backends: API simplification;
|
||||
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
|
||||
computation). This method was redundant with vc-state and usually
|
||||
implemented as a trivial call to same. Fixes the failure mode
|
||||
described in bug#694.
|
||||
|
||||
* vc/vc.el and all backends: API simplification; init-revision is
|
||||
gone, and vc-registered functions no longer take an
|
||||
initial-revision argument.
|
||||
|
|
|
|||
|
|
@ -261,10 +261,6 @@ Only the value `maybe' can be trusted :-(."
|
|||
;; Strip the terminating newline.
|
||||
(buffer-substring (point-min) (1- (point-max)))))))))
|
||||
|
||||
(defun vc-arch-workfile-unchanged-p (_file)
|
||||
"Stub: arch workfiles are always considered to be in a changed state,"
|
||||
nil)
|
||||
|
||||
(defun vc-arch-state (file)
|
||||
;; There's no checkout operation and merging is not done from VC
|
||||
;; so the only operation that's state dependent that VC supports is commit
|
||||
|
|
|
|||
|
|
@ -493,9 +493,6 @@ in the branch repository (or whose status not be determined)."
|
|||
(add-hook 'after-save-hook 'vc-bzr-resolve-when-done nil t)
|
||||
(message "There are unresolved conflicts in this file")))
|
||||
|
||||
(defun vc-bzr-workfile-unchanged-p (file)
|
||||
(eq 'unchanged (car (vc-bzr-status file))))
|
||||
|
||||
(defun vc-bzr-working-revision (file)
|
||||
;; Together with the code in vc-state-heuristic, this makes it possible
|
||||
;; to get the initial VC state of a Bzr file even if Bzr is not installed.
|
||||
|
|
|
|||
|
|
@ -144,11 +144,6 @@ It should return a status of either 0 (no differences found), or
|
|||
"find the version control state of all files in DIR in a fast way."
|
||||
)
|
||||
|
||||
(defun vc-dav-workfile-unchanged-p (url)
|
||||
"Return non-nil if URL is unchanged from its current workfile version."
|
||||
;; Probably impossible with webdav
|
||||
)
|
||||
|
||||
(defun vc-dav-responsible-p (url)
|
||||
"Return non-nil if DAV considers itself `responsible' for URL."
|
||||
;; Check for DAV support on the web server.
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@
|
|||
;; * working-revision (file) OK
|
||||
;; - latest-on-branch-p (file) NOT NEEDED
|
||||
;; * checkout-model (files) OK
|
||||
;; - workfile-unchanged-p (file) OK
|
||||
;; - mode-line-string (file) OK
|
||||
;; STATE-CHANGING FUNCTIONS
|
||||
;; * create-repo () OK
|
||||
|
|
@ -248,9 +247,6 @@ matching the resulting Git log output, and KEYWORDS is a list of
|
|||
str)
|
||||
(vc-git--rev-parse "HEAD"))))
|
||||
|
||||
(defun vc-git-workfile-unchanged-p (file)
|
||||
(eq 'up-to-date (vc-git-state file)))
|
||||
|
||||
(defun vc-git-mode-line-string (file)
|
||||
"Return a string for `vc-mode-line' to put in the mode line for FILE."
|
||||
(let* ((rev (vc-working-revision file))
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@
|
|||
;; * working-revision (file) OK
|
||||
;; - latest-on-branch-p (file) ??
|
||||
;; * checkout-model (files) OK
|
||||
;; - workfile-unchanged-p (file) OK
|
||||
;; - mode-line-string (file) NOT NEEDED
|
||||
;; STATE-CHANGING FUNCTIONS
|
||||
;; * register (files &optional rev comment) OK
|
||||
|
|
@ -530,10 +529,6 @@ REV is the revision to check out into WORKFILE."
|
|||
(message "There are unresolved conflicts in this file")))
|
||||
|
||||
|
||||
;; Modeled after the similar function in vc-bzr.el
|
||||
(defun vc-hg-workfile-unchanged-p (file)
|
||||
(eq 'up-to-date (vc-hg-state file)))
|
||||
|
||||
;; Modeled after the similar function in vc-bzr.el
|
||||
(defun vc-hg-revert (file &optional contents-done)
|
||||
(unless contents-done
|
||||
|
|
|
|||
|
|
@ -576,39 +576,6 @@ It simply calls the real state computation function `vc-BACKEND-state'
|
|||
and does not employ any heuristic at all."
|
||||
(vc-call-backend backend 'state file))
|
||||
|
||||
(defun vc-workfile-unchanged-p (file)
|
||||
"Return non-nil if FILE has not changed since the last checkout."
|
||||
(let ((checkout-time (vc-file-getprop file 'vc-checkout-time))
|
||||
(lastmod (nth 5 (file-attributes file))))
|
||||
;; This is a shortcut for determining when the workfile is
|
||||
;; unchanged. It can fail under some circumstances; see the
|
||||
;; discussion in bug#694.
|
||||
(if (and checkout-time
|
||||
;; Tramp and Ange-FTP return this when they don't know the time.
|
||||
(not (equal lastmod '(0 0))))
|
||||
(equal checkout-time lastmod)
|
||||
(let ((unchanged (vc-call workfile-unchanged-p file)))
|
||||
(vc-file-setprop file 'vc-checkout-time (if unchanged lastmod 0))
|
||||
unchanged))))
|
||||
|
||||
(defun vc-default-workfile-unchanged-p (backend file)
|
||||
"Check if FILE is unchanged by diffing against the repository version.
|
||||
Return non-nil if FILE is unchanged."
|
||||
(zerop (condition-case err
|
||||
;; If the implementation supports it, let the output
|
||||
;; go to *vc*, not *vc-diff*, since this is an internal call.
|
||||
(vc-call-backend backend 'diff (list file) nil nil "*vc*")
|
||||
(wrong-number-of-arguments
|
||||
;; If this error came from the above call to vc-BACKEND-diff,
|
||||
;; try again without the optional buffer argument (for
|
||||
;; backward compatibility). Otherwise, resignal.
|
||||
(if (or (not (eq (cadr err)
|
||||
(indirect-function
|
||||
(vc-find-backend-function backend 'diff))))
|
||||
(not (eq (cl-caddr err) 4)))
|
||||
(signal (car err) (cdr err))
|
||||
(vc-call-backend backend 'diff (list file)))))))
|
||||
|
||||
(defun vc-working-revision (file &optional backend)
|
||||
"Return the repository version from which FILE was checked out.
|
||||
If FILE is not registered, this function always returns nil."
|
||||
|
|
|
|||
|
|
@ -154,9 +154,6 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
|
|||
(re-search-forward "\\(?:Current b\\|B\\)ranch: *\\(.*\\)\n?\nChanges against parent \\(.*\\)")
|
||||
(match-string 1))))
|
||||
|
||||
(defun vc-mtn-workfile-unchanged-p (file)
|
||||
(not (eq (vc-mtn-state file) 'edited)))
|
||||
|
||||
;; Mode-line rewrite code copied from vc-arch.el.
|
||||
|
||||
(defcustom vc-mtn-mode-line-rewrite
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ For a description of possible values, see `vc-check-master-templates'."
|
|||
'vc-working-revision))))
|
||||
(if (not (eq state 'up-to-date))
|
||||
state
|
||||
(if (vc-workfile-unchanged-p file)
|
||||
(if (vc-rcs-workfile-unchanged-p file)
|
||||
'up-to-date
|
||||
(if (eq (vc-rcs-checkout-model (list file)) 'locking)
|
||||
'unlocked-changes
|
||||
|
|
@ -248,7 +248,7 @@ When VERSION is given, perform check for that version."
|
|||
(vc-rcs-find-most-recent-rev (vc-branch-part version))))))
|
||||
|
||||
(defun vc-rcs-workfile-unchanged-p (file)
|
||||
"RCS-specific implementation of `vc-workfile-unchanged-p'."
|
||||
"Has FILE remained unchanged since last checkout?"
|
||||
;; Try to use rcsdiff --brief. If rcsdiff does not understand that,
|
||||
;; do a double take and remember the fact for the future
|
||||
(let* ((version (concat "-r" (vc-working-revision file)))
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ For a description of possible values, see `vc-check-master-templates'."
|
|||
(working-revision (vc-working-revision file))
|
||||
(locking-user (cdr (assoc working-revision locks))))
|
||||
(if (not locking-user)
|
||||
(if (vc-workfile-unchanged-p file)
|
||||
(if (vc-sccs-workfile-unchanged-p file)
|
||||
'up-to-date
|
||||
'unlocked-changes)
|
||||
(if (string= locking-user (vc-user-login-name file))
|
||||
|
|
@ -197,7 +197,7 @@ Optional string REV is a revision."
|
|||
(write-region nil nil outfile nil 'silent)))
|
||||
|
||||
(defun vc-sccs-workfile-unchanged-p (file)
|
||||
"SCCS-specific implementation of `vc-workfile-unchanged-p'."
|
||||
"Has FILE remained unchanged since last checkout?"
|
||||
(let ((tempfile (make-temp-file "vc-sccs")))
|
||||
(unwind-protect
|
||||
(progn
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
;; * working-revision (file) OK
|
||||
;; - latest-on-branch-p (file) ??
|
||||
;; * checkout-model (files) OK
|
||||
;; * workfile-unchanged-p (file) OK
|
||||
;; - mode-line-string (file) NOT NEEDED
|
||||
;; STATE-CHANGING FUNCTIONS
|
||||
;; * register (files &optional rev comment) OK
|
||||
|
|
@ -213,9 +212,6 @@ This function differs from vc-do-command in that it invokes `vc-src-program'."
|
|||
(vc-src-command standard-output file "list" "-f{1}" "@")))
|
||||
"0"))
|
||||
|
||||
(defun vc-src-workfile-unchanged-p (file)
|
||||
(eq 'up-to-date (vc-src-state file)))
|
||||
|
||||
;;;
|
||||
;;; State-changing functions
|
||||
;;;
|
||||
|
|
|
|||
|
|
@ -200,17 +200,6 @@
|
|||
;; Indicate whether FILES need to be "checked out" before they can be
|
||||
;; edited. See `vc-checkout-model' for a list of possible values.
|
||||
;;
|
||||
;; - workfile-unchanged-p (file)
|
||||
;;
|
||||
;; Return non-nil if FILE is unchanged from the working revision.
|
||||
;; This function should do a brief comparison of FILE's contents
|
||||
;; with those of the repository copy of the working revision. If
|
||||
;; the backend does not have such a brief-comparison feature, the
|
||||
;; default implementation of this function can be used, which
|
||||
;; delegates to a full vc-BACKEND-diff. (Note that vc-BACKEND-diff
|
||||
;; must not run asynchronously in this case, see variable
|
||||
;; `vc-disable-async-diff'.)
|
||||
;;
|
||||
;; - mode-line-string (file)
|
||||
;;
|
||||
;; If provided, this function should return the VC-specific mode
|
||||
|
|
@ -609,6 +598,11 @@
|
|||
;; take a first optional revision argument, since on no system since
|
||||
;; RCS has setting the initial revision been even possible, let alone
|
||||
;; sane.
|
||||
;;
|
||||
;; workfile-unchanged-p is no longer a public back-end method. It
|
||||
;; was redundant with vc-state and usually implemented with a trivial
|
||||
;; call to it. A few older back ends retain versions for internal use in
|
||||
;; their vc-state functions.
|
||||
|
||||
;;; Todo:
|
||||
|
||||
|
|
@ -1186,7 +1180,7 @@ For old-style locking-based version control systems, like RCS:
|
|||
;; For files with locking, if the file does not contain
|
||||
;; any changes, just let go of the lock, i.e. revert.
|
||||
(when (and (not (eq model 'implicit))
|
||||
(vc-workfile-unchanged-p file)
|
||||
(eq state 'up-to-date)
|
||||
;; If buffer is modified, that means the user just
|
||||
;; said no to saving it; in that case, don't revert,
|
||||
;; because the user might intend to save after
|
||||
|
|
|
|||
Loading…
Reference in a new issue