emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master f82f3f1: API simplification: remove vc-workfile-unc


From: Eric S. Raymond
Subject: [Emacs-diffs] master f82f3f1: API simplification: remove vc-workfile-unchanged-p from pubic methods.
Date: Mon, 01 Dec 2014 13:26:05 +0000

branch: master
commit f82f3f1f177c1a9cc2c2236f51acd1be1809ae1f
Author: Eric S. Raymond <address@hidden>
Commit: Eric S. Raymond <address@hidden>

    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.
---
 lisp/ChangeLog      |    7 +++++++
 lisp/vc/vc-arch.el  |    4 ----
 lisp/vc/vc-bzr.el   |    3 ---
 lisp/vc/vc-dav.el   |    5 -----
 lisp/vc/vc-git.el   |    4 ----
 lisp/vc/vc-hg.el    |    5 -----
 lisp/vc/vc-hooks.el |   33 ---------------------------------
 lisp/vc/vc-mtn.el   |    3 ---
 lisp/vc/vc-rcs.el   |    4 ++--
 lisp/vc/vc-sccs.el  |    4 ++--
 lisp/vc/vc-src.el   |    4 ----
 lisp/vc/vc.el       |   18 ++++++------------
 12 files changed, 17 insertions(+), 77 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f775afe..66b671a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
 2014-12-01  Eric S. Raymond  <address@hidden>
 
+       * 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.
diff --git a/lisp/vc/vc-arch.el b/lisp/vc/vc-arch.el
index 6d2e472..eb6ea7d 100644
--- a/lisp/vc/vc-arch.el
+++ b/lisp/vc/vc-arch.el
@@ -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
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el
index afe8770..19a8299 100644
--- a/lisp/vc/vc-bzr.el
+++ b/lisp/vc/vc-bzr.el
@@ -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.
diff --git a/lisp/vc/vc-dav.el b/lisp/vc/vc-dav.el
index ff4d5e5..e6ab771 100644
--- a/lisp/vc/vc-dav.el
+++ b/lisp/vc/vc-dav.el
@@ -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.
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index ae1b356..f2cb997 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -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))
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 337107f..52d5ceb 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -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
@@ -531,10 +530,6 @@ REV is the revision to check out into WORKFILE."
 
 
 ;; 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
     (with-temp-buffer (vc-hg-command t 0 file "revert"))))
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 3a2ad40..7224aee 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -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."
diff --git a/lisp/vc/vc-mtn.el b/lisp/vc/vc-mtn.el
index f12ca0f..b32a1db 100644
--- a/lisp/vc/vc-mtn.el
+++ b/lisp/vc/vc-mtn.el
@@ -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
diff --git a/lisp/vc/vc-rcs.el b/lisp/vc/vc-rcs.el
index 572a83e..3028d7e 100644
--- a/lisp/vc/vc-rcs.el
+++ b/lisp/vc/vc-rcs.el
@@ -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)))
diff --git a/lisp/vc/vc-sccs.el b/lisp/vc/vc-sccs.el
index 46e191a..8c9595a 100644
--- a/lisp/vc/vc-sccs.el
+++ b/lisp/vc/vc-sccs.el
@@ -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
diff --git a/lisp/vc/vc-src.el b/lisp/vc/vc-src.el
index 186f73f..931dc5a 100644
--- a/lisp/vc/vc-src.el
+++ b/lisp/vc/vc-src.el
@@ -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
 ;;;
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 62e68e2..1ae3346 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -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



reply via email to

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