diff options
| author | Eric S. Raymond | 2014-12-01 09:41:54 -0500 |
|---|---|---|
| committer | Eric S. Raymond | 2014-12-01 09:41:54 -0500 |
| commit | 578d91ac509a9856cf854bea75b6328cf40d1d03 (patch) | |
| tree | 6b4b584ddf5e09861f0fe1c8544c5f9ba0dbebb2 | |
| parent | 33b4235db671a6c5644a9ce73a8901f073cb0ecc (diff) | |
| download | emacs-578d91ac509a9856cf854bea75b6328cf40d1d03.tar.gz emacs-578d91ac509a9856cf854bea75b6328cf40d1d03.zip | |
Remove vc-state-heuristic from the set of public methods.
* vc/vc.el, vc-hooks.el, and all backends: API simplification;
vc-state-heuristic is no longer a public method, having been removed
where it is redundant, unnecessary, or known buggy. This eliminated
all backends except CVS. Eliminates bug#7850.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/vc/vc-bzr.el | 111 | ||||
| -rw-r--r-- | lisp/vc/vc-dav.el | 4 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 1 | ||||
| -rw-r--r-- | lisp/vc/vc-hg.el | 1 | ||||
| -rw-r--r-- | lisp/vc/vc-hooks.el | 8 | ||||
| -rw-r--r-- | lisp/vc/vc-src.el | 1 | ||||
| -rw-r--r-- | lisp/vc/vc-svn.el | 21 | ||||
| -rw-r--r-- | lisp/vc/vc.el | 14 |
9 files changed, 12 insertions, 154 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6f5bb465c31..d6691f51d17 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2014-12-01 Eric S. Raymond <esr@snark.thyrsus.com> | 1 | 2014-12-01 Eric S. Raymond <esr@snark.thyrsus.com> |
| 2 | 2 | ||
| 3 | * vc/vc.el, vc-hooks.el, and all backends: API simplification; | ||
| 4 | vc-state-heuristic is no longer a public method, having been | ||
| 5 | removed where it is redundant, unnecessary, or known buggy. This | ||
| 6 | eliminated all backends except CVS. Eliminates bug#7850. | ||
| 7 | |||
| 3 | * vc/vc-cvs.el, vc/vc-hooks.el, vc/vc-rcs.el, vc/vc-sccs.el: | 8 | * vc/vc-cvs.el, vc/vc-hooks.el, vc/vc-rcs.el, vc/vc-sccs.el: |
| 4 | Eliminate vc-mistrust-permissions. It was only relevant to the | 9 | Eliminate vc-mistrust-permissions. It was only relevant to the |
| 5 | RCS and SCCS back ends and defaulted to t. Code now always | 10 | RCS and SCCS back ends and defaulted to t. Code now always |
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index 19a8299485d..34a7c7be786 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el | |||
| @@ -178,113 +178,6 @@ in the repository root directory of FILE." | |||
| 178 | (insert-file-contents-literally file) | 178 | (insert-file-contents-literally file) |
| 179 | (sha1 (current-buffer)))) | 179 | (sha1 (current-buffer)))) |
| 180 | 180 | ||
| 181 | (defun vc-bzr-state-heuristic (file) | ||
| 182 | "Like `vc-bzr-state' but hopefully without running Bzr." | ||
| 183 | ;; `bzr status' could be slow with large histories and pending merges, | ||
| 184 | ;; so this tries to avoid calling it if possible. bzr status is | ||
| 185 | ;; faster now, so this is not as important as it was. | ||
| 186 | ;; | ||
| 187 | ;; This function tries first to parse Bzr internal file | ||
| 188 | ;; `checkout/dirstate', but it may fail if Bzr internal file format | ||
| 189 | ;; has changed. As a safeguard, the `checkout/dirstate' file is | ||
| 190 | ;; only parsed if it contains the string `#bazaar dirstate flat | ||
| 191 | ;; format 3' in the first line. | ||
| 192 | ;; If the `checkout/dirstate' file cannot be parsed, fall back to | ||
| 193 | ;; running `vc-bzr-state'." | ||
| 194 | ;; | ||
| 195 | ;; The format of the dirstate file is explained in bzrlib/dirstate.py | ||
| 196 | ;; in the bzr distribution. Basically: | ||
| 197 | ;; header-line giving the version of the file format in use. | ||
| 198 | ;; a few lines of stuff | ||
| 199 | ;; entries, one per line, with null-separated fields. Each line: | ||
| 200 | ;; entry_key = dirname (may be empty), basename, file-id | ||
| 201 | ;; current = common ( = kind, fingerprint, size, executable ) | ||
| 202 | ;; + working ( = packed_stat ) | ||
| 203 | ;; parent = common ( as above ) + history ( = rev_id ) | ||
| 204 | ;; kinds = (r)elocated, (a)bsent, (d)irectory, (f)ile, (l)ink | ||
| 205 | (let* ((root (vc-bzr-root file)) | ||
| 206 | (dirstate (expand-file-name vc-bzr-admin-dirstate root))) | ||
| 207 | (when root ; Short cut. | ||
| 208 | (condition-case err | ||
| 209 | (with-temp-buffer | ||
| 210 | (insert-file-contents dirstate) | ||
| 211 | (goto-char (point-min)) | ||
| 212 | (if (not (looking-at "#bazaar dirstate flat format 3")) | ||
| 213 | (vc-bzr-state file) ; Some other unknown format? | ||
| 214 | (let* ((relfile (file-relative-name file root)) | ||
| 215 | (reldir (file-name-directory relfile))) | ||
| 216 | (cond | ||
| 217 | ((not | ||
| 218 | (re-search-forward | ||
| 219 | (concat "^\0" | ||
| 220 | (if reldir (regexp-quote | ||
| 221 | (directory-file-name reldir))) | ||
| 222 | "\0" | ||
| 223 | (regexp-quote (file-name-nondirectory relfile)) | ||
| 224 | "\0" | ||
| 225 | "[^\0]*\0" ;id? | ||
| 226 | "\\([^\0]*\\)\0" ;"a/f/d", a=removed? | ||
| 227 | "\\([^\0]*\\)\0" ;sha1 (empty if conflicted)? | ||
| 228 | "\\([^\0]*\\)\0" ;size?p | ||
| 229 | ;; y/n. Whether or not the current copy | ||
| 230 | ;; was executable the last time bzr checked? | ||
| 231 | "[^\0]*\0" | ||
| 232 | "[^\0]*\0" ;? | ||
| 233 | ;; Parent information. Absent in a new repo. | ||
| 234 | "\\(?:\\([^\0]*\\)\0" ;"a/f/d" a=added? | ||
| 235 | "\\([^\0]*\\)\0" ;sha1 again? | ||
| 236 | "\\([^\0]*\\)\0" ;size again? | ||
| 237 | ;; y/n. Whether or not the repo thinks | ||
| 238 | ;; the file should be executable? | ||
| 239 | "\\([^\0]*\\)\0" | ||
| 240 | "[^\0]*\0\\)?" ;last revid? | ||
| 241 | ;; There are more fields when merges are pending. | ||
| 242 | ) | ||
| 243 | nil t)) | ||
| 244 | 'unregistered) | ||
| 245 | ;; Apparently the second sha1 is the one we want: when | ||
| 246 | ;; there's a conflict, the first sha1 is absent (and the | ||
| 247 | ;; first size seems to correspond to the file with | ||
| 248 | ;; conflict markers). | ||
| 249 | ((eq (char-after (match-beginning 1)) ?a) 'removed) | ||
| 250 | ;; If there is no parent, this must be a new repo. | ||
| 251 | ;; If file is in dirstate, can only be added (b#8025). | ||
| 252 | ((or (not (match-beginning 4)) | ||
| 253 | (eq (char-after (match-beginning 4)) ?a)) 'added) | ||
| 254 | ((or (and (eq (string-to-number (match-string 3)) | ||
| 255 | (nth 7 (file-attributes file))) | ||
| 256 | (equal (match-string 5) | ||
| 257 | (save-match-data (vc-bzr-sha1 file))) | ||
| 258 | ;; For a file, does the executable state match? | ||
| 259 | ;; (Bug#7544) | ||
| 260 | (or (not | ||
| 261 | (eq (char-after (match-beginning 1)) ?f)) | ||
| 262 | (let ((exe | ||
| 263 | (memq | ||
| 264 | ?x | ||
| 265 | (mapcar | ||
| 266 | 'identity | ||
| 267 | (nth 8 (file-attributes file)))))) | ||
| 268 | (if (eq (char-after (match-beginning 7)) | ||
| 269 | ?y) | ||
| 270 | exe | ||
| 271 | (not exe))))) | ||
| 272 | (and | ||
| 273 | ;; It looks like for lightweight | ||
| 274 | ;; checkouts \2 is empty and we need to | ||
| 275 | ;; look for size in \6. | ||
| 276 | (eq (match-beginning 2) (match-end 2)) | ||
| 277 | (eq (string-to-number (match-string 6)) | ||
| 278 | (nth 7 (file-attributes file))) | ||
| 279 | (equal (match-string 5) | ||
| 280 | (vc-bzr-sha1 file)))) | ||
| 281 | 'up-to-date) | ||
| 282 | (t 'edited))))) | ||
| 283 | ;; The dirstate file can't be read, or some other problem. | ||
| 284 | (error | ||
| 285 | (message "Falling back on \"slow\" status detection (%S)" err) | ||
| 286 | (vc-bzr-state file)))))) | ||
| 287 | |||
| 288 | ;; This is a cheap approximation that is autoloaded. If it finds a | 181 | ;; This is a cheap approximation that is autoloaded. If it finds a |
| 289 | ;; possible match it loads this file and runs the real function. | 182 | ;; possible match it loads this file and runs the real function. |
| 290 | ;; It requires vc-bzr-admin-checkout-format-file to be autoloaded too. | 183 | ;; It requires vc-bzr-admin-checkout-format-file to be autoloaded too. |
| @@ -296,7 +189,7 @@ in the repository root directory of FILE." | |||
| 296 | 189 | ||
| 297 | (defun vc-bzr-registered (file) | 190 | (defun vc-bzr-registered (file) |
| 298 | "Return non-nil if FILE is registered with bzr." | 191 | "Return non-nil if FILE is registered with bzr." |
| 299 | (let ((state (vc-bzr-state-heuristic file))) | 192 | (let ((state (vc-bzr-state file))) |
| 300 | (not (memq state '(nil unregistered ignored))))) | 193 | (not (memq state '(nil unregistered ignored))))) |
| 301 | 194 | ||
| 302 | (defconst vc-bzr-state-words | 195 | (defconst vc-bzr-state-words |
| @@ -494,8 +387,6 @@ in the branch repository (or whose status not be determined)." | |||
| 494 | (message "There are unresolved conflicts in this file"))) | 387 | (message "There are unresolved conflicts in this file"))) |
| 495 | 388 | ||
| 496 | (defun vc-bzr-working-revision (file) | 389 | (defun vc-bzr-working-revision (file) |
| 497 | ;; Together with the code in vc-state-heuristic, this makes it possible | ||
| 498 | ;; to get the initial VC state of a Bzr file even if Bzr is not installed. | ||
| 499 | (let* ((rootdir (vc-bzr-root file)) | 390 | (let* ((rootdir (vc-bzr-root file)) |
| 500 | (branch-format-file (expand-file-name vc-bzr-admin-branch-format-file | 391 | (branch-format-file (expand-file-name vc-bzr-admin-branch-format-file |
| 501 | rootdir)) | 392 | rootdir)) |
diff --git a/lisp/vc/vc-dav.el b/lisp/vc/vc-dav.el index e6ab771ed81..dd1841df401 100644 --- a/lisp/vc/vc-dav.el +++ b/lisp/vc/vc-dav.el | |||
| @@ -133,10 +133,6 @@ It should return a status of either 0 (no differences found), or | |||
| 133 | 133 | ||
| 134 | 134 | ||
| 135 | ;;; Optional functions | 135 | ;;; Optional functions |
| 136 | ;; Should be faster than vc-dav-state - but how? | ||
| 137 | (defun vc-dav-state-heuristic (url) | ||
| 138 | "Estimate the version control state of URL at visiting time." | ||
| 139 | (vc-dav-state url)) | ||
| 140 | 136 | ||
| 141 | ;; This should use url-dav-get-properties with a depth of `1' to get | 137 | ;; This should use url-dav-get-properties with a depth of `1' to get |
| 142 | ;; all the properties. | 138 | ;; all the properties. |
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index f2cb99733ba..0aceb5537cb 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el | |||
| @@ -50,7 +50,6 @@ | |||
| 50 | ;; STATE-QUERYING FUNCTIONS | 50 | ;; STATE-QUERYING FUNCTIONS |
| 51 | ;; * registered (file) OK | 51 | ;; * registered (file) OK |
| 52 | ;; * state (file) OK | 52 | ;; * state (file) OK |
| 53 | ;; - state-heuristic (file) NOT NEEDED | ||
| 54 | ;; * working-revision (file) OK | 53 | ;; * working-revision (file) OK |
| 55 | ;; - latest-on-branch-p (file) NOT NEEDED | 54 | ;; - latest-on-branch-p (file) NOT NEEDED |
| 56 | ;; * checkout-model (files) OK | 55 | ;; * checkout-model (files) OK |
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 52d5ceb12ca..9bb79a74e94 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el | |||
| @@ -43,7 +43,6 @@ | |||
| 43 | ;; STATE-QUERYING FUNCTIONS | 43 | ;; STATE-QUERYING FUNCTIONS |
| 44 | ;; * registered (file) OK | 44 | ;; * registered (file) OK |
| 45 | ;; * state (file) OK | 45 | ;; * state (file) OK |
| 46 | ;; - state-heuristic (file) NOT NEEDED | ||
| 47 | ;; - dir-status (dir update-function) OK | 46 | ;; - dir-status (dir update-function) OK |
| 48 | ;; - dir-status-files (dir files ds uf) OK | 47 | ;; - dir-status-files (dir files ds uf) OK |
| 49 | ;; - dir-extra-headers (dir) OK | 48 | ;; - dir-extra-headers (dir) OK |
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index 46a6b3194b9..39c18d4b57b 100644 --- a/lisp/vc/vc-hooks.el +++ b/lisp/vc/vc-hooks.el | |||
| @@ -548,18 +548,12 @@ status of this file. Otherwise, the value returned is one of: | |||
| 548 | "Quickly recompute the `state' of FILE." | 548 | "Quickly recompute the `state' of FILE." |
| 549 | (vc-file-setprop | 549 | (vc-file-setprop |
| 550 | file 'vc-state | 550 | file 'vc-state |
| 551 | (vc-call-backend backend 'state-heuristic file))) | 551 | (vc-call-backend backend 'state file))) |
| 552 | 552 | ||
| 553 | (defsubst vc-up-to-date-p (file) | 553 | (defsubst vc-up-to-date-p (file) |
| 554 | "Convenience function that checks whether `vc-state' of FILE is `up-to-date'." | 554 | "Convenience function that checks whether `vc-state' of FILE is `up-to-date'." |
| 555 | (eq (vc-state file) 'up-to-date)) | 555 | (eq (vc-state file) 'up-to-date)) |
| 556 | 556 | ||
| 557 | (defun vc-default-state-heuristic (backend file) | ||
| 558 | "Default implementation of vc-BACKEND-state-heuristic. | ||
| 559 | It simply calls the real state computation function `vc-BACKEND-state' | ||
| 560 | and does not employ any heuristic at all." | ||
| 561 | (vc-call-backend backend 'state file)) | ||
| 562 | |||
| 563 | (defun vc-working-revision (file &optional backend) | 557 | (defun vc-working-revision (file &optional backend) |
| 564 | "Return the repository version from which FILE was checked out. | 558 | "Return the repository version from which FILE was checked out. |
| 565 | If FILE is not registered, this function always returns nil." | 559 | If FILE is not registered, this function always returns nil." |
diff --git a/lisp/vc/vc-src.el b/lisp/vc/vc-src.el index 931dc5a2a93..046222304c4 100644 --- a/lisp/vc/vc-src.el +++ b/lisp/vc/vc-src.el | |||
| @@ -31,7 +31,6 @@ | |||
| 31 | ;; STATE-QUERYING FUNCTIONS | 31 | ;; STATE-QUERYING FUNCTIONS |
| 32 | ;; * registered (file) OK | 32 | ;; * registered (file) OK |
| 33 | ;; * state (file) OK | 33 | ;; * state (file) OK |
| 34 | ;; - state-heuristic (file) NOT NEEDED | ||
| 35 | ;; * dir-status (dir update-function) OK | 34 | ;; * dir-status (dir update-function) OK |
| 36 | ;; - dir-status-files (dir files ds uf) ?? | 35 | ;; - dir-status-files (dir files ds uf) ?? |
| 37 | ;; - dir-extra-headers (dir) NOT NEEDED | 36 | ;; - dir-extra-headers (dir) NOT NEEDED |
diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el index fa584fac5c7..0479519bde9 100644 --- a/lisp/vc/vc-svn.el +++ b/lisp/vc/vc-svn.el | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | ;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| 10 | 10 | ||
| 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
| 12 | ;; it under the terms of the GNU General Public License as published by | 12 | ;; it under the` terms of the GNU General Public License as published by |
| 13 | ;; the Free Software Foundation, either version 3 of the License, or | 13 | ;; the Free Software Foundation, either version 3 of the License, or |
| 14 | ;; (at your option) any later version. | 14 | ;; (at your option) any later version. |
| 15 | 15 | ||
| @@ -162,25 +162,6 @@ If you want to force an empty list of arguments, use t." | |||
| 162 | (vc-svn-command t 0 file "status" (if localp "-v" "-u")) | 162 | (vc-svn-command t 0 file "status" (if localp "-v" "-u")) |
| 163 | (vc-svn-parse-status file)))) | 163 | (vc-svn-parse-status file)))) |
| 164 | 164 | ||
| 165 | ;; NB this does not handle svn properties, which can be changed | ||
| 166 | ;; without changing the file timestamp. | ||
| 167 | ;; Note that unlike vc-cvs-state-heuristic, this is not called from | ||
| 168 | ;; vc-svn-state. AFAICS, it is only called from vc-state-refresh via | ||
| 169 | ;; vc-after-save (bug#7850). Therefore the fact that it ignores | ||
| 170 | ;; properties is irrelevant. If you want to make vc-svn-state call | ||
| 171 | ;; this, it should be extended to handle svn properties. | ||
| 172 | (defun vc-svn-state-heuristic (file) | ||
| 173 | "SVN-specific state heuristic." | ||
| 174 | ;; If the file has not changed since checkout, consider it `up-to-date'. | ||
| 175 | ;; Otherwise consider it `edited'. Copied from vc-cvs-state-heuristic. | ||
| 176 | (let ((checkout-time (vc-file-getprop file 'vc-checkout-time)) | ||
| 177 | (lastmod (nth 5 (file-attributes file)))) | ||
| 178 | (cond | ||
| 179 | ((equal checkout-time lastmod) 'up-to-date) | ||
| 180 | ((string= (vc-working-revision file) "0") 'added) | ||
| 181 | ((null checkout-time) 'unregistered) | ||
| 182 | (t 'edited)))) | ||
| 183 | |||
| 184 | ;; FIXME it would be better not to have the "remote" argument, | 165 | ;; FIXME it would be better not to have the "remote" argument, |
| 185 | ;; but to distinguish the two output formats based on content. | 166 | ;; but to distinguish the two output formats based on content. |
| 186 | (defun vc-svn-after-dir-status (callback &optional remote) | 167 | (defun vc-svn-after-dir-status (callback &optional remote) |
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 0d0639ba86c..54fb9cd5016 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el | |||
| @@ -128,16 +128,7 @@ | |||
| 128 | ;; Return the current version control state of FILE. For a list of | 128 | ;; Return the current version control state of FILE. For a list of |
| 129 | ;; possible values, see `vc-state'. This function should do a full and | 129 | ;; possible values, see `vc-state'. This function should do a full and |
| 130 | ;; reliable state computation; it is usually called immediately after | 130 | ;; reliable state computation; it is usually called immediately after |
| 131 | ;; C-x v v. If you want to use a faster heuristic when visiting a | 131 | ;; C-x v v. |
| 132 | ;; file, put that into `state-heuristic' below. Note that under most | ||
| 133 | ;; VCSes this won't be called at all, dir-status is used instead. | ||
| 134 | ;; | ||
| 135 | ;; - state-heuristic (file) | ||
| 136 | ;; | ||
| 137 | ;; If provided, this function is used to estimate the version control | ||
| 138 | ;; state of FILE at visiting time. It should be considerably faster | ||
| 139 | ;; than the implementation of `state'. For a list of possible values, | ||
| 140 | ;; see the doc string of `vc-state'. | ||
| 141 | ;; | 132 | ;; |
| 142 | ;; - dir-status (dir update-function) | 133 | ;; - dir-status (dir update-function) |
| 143 | ;; | 134 | ;; |
| @@ -590,6 +581,9 @@ | |||
| 590 | ;; moves closer to emulating modern non-locking behavior even on very | 581 | ;; moves closer to emulating modern non-locking behavior even on very |
| 591 | ;; old VCSes. | 582 | ;; old VCSes. |
| 592 | ;; | 583 | ;; |
| 584 | ;; - vc-state-heuristic is no longer a public method (the CVS backend | ||
| 585 | ;; retains it as a private one). | ||
| 586 | ;; | ||
| 593 | ;; - the vc-mistrust-permissions configuration variable is gone; the | 587 | ;; - the vc-mistrust-permissions configuration variable is gone; the |
| 594 | ;; code no longer relies on permissions except in one corner case where | 588 | ;; code no longer relies on permissions except in one corner case where |
| 595 | ;; CVS leaves no alternative (which was not gated by this variable). The | 589 | ;; CVS leaves no alternative (which was not gated by this variable). The |