diff options
| author | Stefan Monnier | 2003-05-08 18:31:21 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2003-05-08 18:31:21 +0000 |
| commit | fd14074395bec445243f6b1f129f67a57e9c3ada (patch) | |
| tree | 1909afe2fde3c8513c9fa4cdabeb2f85e5908aba | |
| parent | 1207c9d2549cd6a58482fdd2b5afdceecdd2905b (diff) | |
| download | emacs-fd14074395bec445243f6b1f129f67a57e9c3ada.tar.gz emacs-fd14074395bec445243f6b1f129f67a57e9c3ada.zip | |
(vc-svn-dired-state-info): Use `added' for added files and
don't use `concat' unnecessarily. Remove impossible cases.
(vc-svn-register, vc-svn-find-version, vc-svn-diff-tree):
Use vc-switches.
(vc-svn-checkin): Use vc-switches. Fix up regexp.
(vc-svn-diff): Use vc-switches.
Don't return 0 for newly added empty files.
Don't use svn's return status.
(vc-svn-parse-status): Recognize copied files as well.
Use the last-modified revision for workfile-version.
| -rw-r--r-- | lisp/vc-svn.el | 132 |
1 files changed, 58 insertions, 74 deletions
diff --git a/lisp/vc-svn.el b/lisp/vc-svn.el index e5cf1fbd0ff..449aa08e56b 100644 --- a/lisp/vc-svn.el +++ b/lisp/vc-svn.el | |||
| @@ -32,10 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | ;;; Bugs: | 33 | ;;; Bugs: |
| 34 | 34 | ||
| 35 | ;; - VC-dired is either not working or (really) dog slow. | 35 | ;; - VC-dired is (really) slow. |
| 36 | ;; - vc-print-log does not always jump to the proper log entry because | ||
| 37 | ;; it tries to jump to version 1234 even if there's only an entry | ||
| 38 | ;; for 1232 (because the file hasn't changed since). | ||
| 39 | 36 | ||
| 40 | ;;; Code: | 37 | ;;; Code: |
| 41 | 38 | ||
| @@ -198,15 +195,12 @@ committed and support display of sticky tags." | |||
| 198 | 195 | ||
| 199 | (defun vc-svn-dired-state-info (file) | 196 | (defun vc-svn-dired-state-info (file) |
| 200 | "SVN-specific version of `vc-dired-state-info'." | 197 | "SVN-specific version of `vc-dired-state-info'." |
| 201 | (let* ((svn-state (vc-state file)) | 198 | (let ((svn-state (vc-state file))) |
| 202 | (state (cond ((eq svn-state 'edited) "modified") | 199 | (cond ((eq svn-state 'edited) |
| 203 | ((eq svn-state 'needs-patch) "patch") | 200 | (if (equal (vc-workfile-version file) "0") |
| 204 | ((eq svn-state 'needs-merge) "merge") | 201 | "(added)" "(modified)")) |
| 205 | ;; FIXME: those two states cannot occur right now | 202 | ((eq svn-state 'needs-patch) "(patch)") |
| 206 | ((eq svn-state 'unlocked-changes) "conflict") | 203 | ((eq svn-state 'needs-merge) "(merge)")))) |
| 207 | ((eq svn-state 'locally-added) "added") | ||
| 208 | ))) | ||
| 209 | (if state (concat "(" state ")")))) | ||
| 210 | 204 | ||
| 211 | 205 | ||
| 212 | ;;; | 206 | ;;; |
| @@ -219,19 +213,11 @@ COMMENT can be used to provide an initial description of FILE. | |||
| 219 | 213 | ||
| 220 | `vc-register-switches' and `vc-svn-register-switches' are passed to | 214 | `vc-register-switches' and `vc-svn-register-switches' are passed to |
| 221 | the SVN command (in that order)." | 215 | the SVN command (in that order)." |
| 222 | (let ((switches (append | 216 | (apply 'vc-svn-command nil 0 file |
| 223 | (if (stringp vc-register-switches) | 217 | "add" |
| 224 | (list vc-register-switches) | 218 | ;; (and comment (string-match "[^\t\n ]" comment) |
| 225 | vc-register-switches) | 219 | ;; (concat "-m" comment)) |
| 226 | (if (stringp vc-svn-register-switches) | 220 | (vc-switches 'SVN 'register))) |
| 227 | (list vc-svn-register-switches) | ||
| 228 | vc-svn-register-switches)))) | ||
| 229 | |||
| 230 | (apply 'vc-svn-command nil 0 file | ||
| 231 | "add" | ||
| 232 | ;; (and comment (string-match "[^\t\n ]" comment) | ||
| 233 | ;; (concat "-m" comment)) | ||
| 234 | switches))) | ||
| 235 | 221 | ||
| 236 | (defun vc-svn-responsible-p (file) | 222 | (defun vc-svn-responsible-p (file) |
| 237 | "Return non-nil if SVN thinks it is responsible for FILE." | 223 | "Return non-nil if SVN thinks it is responsible for FILE." |
| @@ -246,18 +232,14 @@ This is only possible if SVN is responsible for FILE's directory.") | |||
| 246 | 232 | ||
| 247 | (defun vc-svn-checkin (file rev comment) | 233 | (defun vc-svn-checkin (file rev comment) |
| 248 | "SVN-specific version of `vc-backend-checkin'." | 234 | "SVN-specific version of `vc-backend-checkin'." |
| 249 | (let ((switches (if (stringp vc-checkin-switches) | 235 | (let ((status (apply 'vc-svn-command nil 1 file |
| 250 | (list vc-checkin-switches) | 236 | "ci" (list* "-m" comment (vc-switches 'SVN 'checkin))))) |
| 251 | vc-checkin-switches)) | ||
| 252 | status) | ||
| 253 | (setq status (apply 'vc-svn-command nil 1 file | ||
| 254 | "ci" (list* "-m" comment switches))) | ||
| 255 | (set-buffer "*vc*") | 237 | (set-buffer "*vc*") |
| 256 | (goto-char (point-min)) | 238 | (goto-char (point-min)) |
| 257 | (unless (equal status 0) | 239 | (unless (equal status 0) |
| 258 | ;; Check checkin problem. | 240 | ;; Check checkin problem. |
| 259 | (cond | 241 | (cond |
| 260 | ((re-search-forward "Up-to-date check failed" nil t) | 242 | ((search-forward "Transaction is out of date" nil t) |
| 261 | (vc-file-setprop file 'vc-state 'needs-merge) | 243 | (vc-file-setprop file 'vc-state 'needs-merge) |
| 262 | (error (substitute-command-keys | 244 | (error (substitute-command-keys |
| 263 | (concat "Up-to-date check failed: " | 245 | (concat "Up-to-date check failed: " |
| @@ -279,17 +261,12 @@ This is only possible if SVN is responsible for FILE's directory.") | |||
| 279 | "cat" | 261 | "cat" |
| 280 | (and rev (not (string= rev "")) | 262 | (and rev (not (string= rev "")) |
| 281 | (concat "-r" rev)) | 263 | (concat "-r" rev)) |
| 282 | (if (stringp vc-checkout-switches) | 264 | (vc-switches 'SVN 'checkout))) |
| 283 | (list vc-checkout-switches) | ||
| 284 | vc-checkout-switches))) | ||
| 285 | 265 | ||
| 286 | (defun vc-svn-checkout (file &optional editable rev) | 266 | (defun vc-svn-checkout (file &optional editable rev) |
| 287 | (message "Checking out %s..." file) | 267 | (message "Checking out %s..." file) |
| 288 | (with-current-buffer (or (get-file-buffer file) (current-buffer)) | 268 | (with-current-buffer (or (get-file-buffer file) (current-buffer)) |
| 289 | (let ((switches (if (stringp vc-checkout-switches) | 269 | (vc-call update file editable rev (vc-switches 'SVN 'checkout))) |
| 290 | (list vc-checkout-switches) | ||
| 291 | vc-checkout-switches))) | ||
| 292 | (vc-call update file editable rev switches))) | ||
| 293 | (vc-mode-line file) | 270 | (vc-mode-line file) |
| 294 | (message "Checking out %s...done" file)) | 271 | (message "Checking out %s...done" file)) |
| 295 | 272 | ||
| @@ -403,34 +380,36 @@ The changes are between FIRST-VERSION and SECOND-VERSION." | |||
| 403 | 380 | ||
| 404 | (defun vc-svn-diff (file &optional oldvers newvers) | 381 | (defun vc-svn-diff (file &optional oldvers newvers) |
| 405 | "Get a difference report using SVN between two versions of FILE." | 382 | "Get a difference report using SVN between two versions of FILE." |
| 406 | (let (status (diff-switches-list (vc-diff-switches-list 'SVN))) | 383 | (if (string= (vc-workfile-version file) "0") |
| 407 | (if (string= (vc-workfile-version file) "0") | 384 | ;; This file is added but not yet committed; there is no master file. |
| 408 | ;; This file is added but not yet committed; there is no master file. | 385 | (if (or oldvers newvers) |
| 409 | (if (or oldvers newvers) | 386 | (error "No revisions of %s exist" file) |
| 410 | (error "No revisions of %s exist" file) | 387 | ;; We regard this as "changed". |
| 411 | ;; We regard this as "changed". | 388 | ;; Diff it against /dev/null. |
| 412 | ;; Diff it against /dev/null. | 389 | ;; Note: this is NOT a "svn diff". |
| 413 | ;; Note: this is NOT a "svn diff". | 390 | (apply 'vc-do-command "*vc-diff*" |
| 414 | (apply 'vc-do-command "*vc-diff*" | 391 | 1 "diff" file |
| 415 | 1 "diff" file | 392 | (append (vc-switches nil 'diff) '("/dev/null"))) |
| 416 | (append diff-switches-list '("/dev/null")))) | 393 | ;; Even if it's empty, it's locally modified. |
| 417 | (setq status | 394 | 1) |
| 418 | (apply 'vc-svn-command "*vc-diff*" | 395 | (let* ((switches (vc-switches 'SVN 'diff)) |
| 419 | (if (and (vc-svn-stay-local-p file) | 396 | (async (and (vc-svn-stay-local-p file) |
| 420 | (or oldvers newvers) ; Svn diffs those locally. | 397 | (or oldvers newvers) ; Svn diffs those locally. |
| 421 | (fboundp 'start-process)) | 398 | (fboundp 'start-process))) |
| 422 | 'async | 399 | (status |
| 423 | 1) | 400 | (apply 'vc-svn-command "*vc-diff*" |
| 424 | file "diff" | 401 | (if async 'async 1) |
| 402 | file "diff" | ||
| 425 | (append | 403 | (append |
| 404 | (when switches | ||
| 405 | (list "-x" (mapconcat 'identity switches " "))) | ||
| 426 | (when oldvers | 406 | (when oldvers |
| 427 | (list "-r" | 407 | (list "-r" (if newvers (concat oldvers ":" newvers) |
| 428 | (if newvers (concat oldvers ":" newvers) oldvers))) | 408 | oldvers))))))) |
| 429 | (when diff-switches-list | 409 | (if async 1 ; async diff => pessimistic assumption |
| 430 | (list "-x" (mapconcat 'identity diff-switches-list " ")))))) | 410 | ;; For some reason `svn diff' does not return a useful |
| 431 | (if (vc-svn-stay-local-p file) | 411 | ;; status w.r.t whether the diff was empty or not. |
| 432 | 1 ;; async diff, pessimistic assumption | 412 | (buffer-size (get-buffer "*vc-diff*")))))) |
| 433 | status)))) | ||
| 434 | 413 | ||
| 435 | (defun vc-svn-diff-tree (dir &optional rev1 rev2) | 414 | (defun vc-svn-diff-tree (dir &optional rev1 rev2) |
| 436 | "Diff all files at and below DIR." | 415 | "Diff all files at and below DIR." |
| @@ -450,14 +429,13 @@ The changes are between FIRST-VERSION and SECOND-VERSION." | |||
| 450 | (vc-diff-internal ',f ',rev1 ',rev2)))))) | 429 | (vc-diff-internal ',f ',rev1 ',rev2)))))) |
| 451 | ;; svn diff: use a single call for the entire tree | 430 | ;; svn diff: use a single call for the entire tree |
| 452 | (let ((coding-system-for-read (or coding-system-for-read 'undecided)) | 431 | (let ((coding-system-for-read (or coding-system-for-read 'undecided)) |
| 453 | (diff-switches-list (vc-diff-switches-list 'SVN))) | 432 | (switches (vc-switches 'SVN 'diff))) |
| 454 | (apply 'vc-svn-command "*vc-diff*" 1 nil "diff" | 433 | (apply 'vc-svn-command "*vc-diff*" 1 nil "diff" |
| 455 | (append | 434 | (append |
| 456 | (when rev1 | 435 | (when rev1 |
| 457 | (list "-r" | 436 | (list "-r" (if rev2 (concat rev1 ":" rev2) rev1))) |
| 458 | (if rev2 (concat rev1 ":" rev2) rev1))) | 437 | (when switches |
| 459 | (when diff-switches-list | 438 | (list "-x" (mapconcat 'identity switches " "))))))))) |
| 460 | (list "-x" (mapconcat 'identity diff-switches-list " "))))))))) | ||
| 461 | 439 | ||
| 462 | ;;; | 440 | ;;; |
| 463 | ;;; Snapshot system | 441 | ;;; Snapshot system |
| @@ -586,7 +564,9 @@ See `vc-svn-stay-local'." | |||
| 586 | (setq stay-local (not stay-local))) | 564 | (setq stay-local (not stay-local))) |
| 587 | (if stay-local | 565 | (if stay-local |
| 588 | 'yes | 566 | 'yes |
| 589 | 'no)))))))))))))) | 567 | 'no)))))))) |
| 568 | ;; vc-svn-stay-local is neither nil nor list nor string. | ||
| 569 | (t 'yes))))))) | ||
| 590 | (if (eq prop 'yes) t nil)))) | 570 | (if (eq prop 'yes) t nil)))) |
| 591 | 571 | ||
| 592 | (defun vc-svn-parse-status (localp) | 572 | (defun vc-svn-parse-status (localp) |
| @@ -596,13 +576,15 @@ essential information." | |||
| 596 | (let (file status) | 576 | (let (file status) |
| 597 | (goto-char (point-min)) | 577 | (goto-char (point-min)) |
| 598 | (while (re-search-forward | 578 | (while (re-search-forward |
| 599 | "^[ ADMCI?!~][ MC][ L][ +][ S]..\\([ *]\\) +\\([0-9]+\\) +\\([0-9?]+\\) +\\([^ ]+\\) +" nil t) | 579 | "^[ ADMCI?!~][ MC][ L][ +][ S]..\\([ *]\\) +\\([-0-9]+\\) +\\([0-9?]+\\) +\\([^ ]+\\) +" nil t) |
| 600 | (setq file (expand-file-name | 580 | (setq file (expand-file-name |
| 601 | (buffer-substring (point) (line-end-position)))) | 581 | (buffer-substring (point) (line-end-position)))) |
| 602 | (setq status (char-after (line-beginning-position))) | 582 | (setq status (char-after (line-beginning-position))) |
| 603 | (unless (eq status ??) | 583 | (unless (eq status ??) |
| 604 | (vc-file-setprop file 'vc-backend 'SVN) | 584 | (vc-file-setprop file 'vc-backend 'SVN) |
| 605 | (vc-file-setprop file 'vc-workfile-version (match-string 2)) | 585 | ;; Use the last-modified revision, so that searching in vc-print-log |
| 586 | ;; output works. | ||
| 587 | (vc-file-setprop file 'vc-workfile-version (match-string 3)) | ||
| 606 | (vc-file-setprop | 588 | (vc-file-setprop |
| 607 | file 'vc-state | 589 | file 'vc-state |
| 608 | (cond | 590 | (cond |
| @@ -613,6 +595,8 @@ essential information." | |||
| 613 | (nth 5 (file-attributes file))) | 595 | (nth 5 (file-attributes file))) |
| 614 | 'up-to-date)) | 596 | 'up-to-date)) |
| 615 | ((eq status ?A) | 597 | ((eq status ?A) |
| 598 | ;; If the file was actually copied, (match-string 2) is "-". | ||
| 599 | (vc-file-setprop file 'vc-workfile-version "0") | ||
| 616 | (vc-file-setprop file 'vc-checkout-time 0) | 600 | (vc-file-setprop file 'vc-checkout-time 0) |
| 617 | 'edited) | 601 | 'edited) |
| 618 | ((memq status '(?M ?C)) | 602 | ((memq status '(?M ?C)) |