comparison lisp/vc-svn.el @ 78914:9eca5b992f1f

(vc-svn-resolve-when-done, vc-svn-find-file-hook): New funs. Used to try and automatically enabled smerge-mode in the presence of conflicts and to call `svn resolved' when the conflicts are gone. (vc-svn-parse-status): Remember the svn-specific status.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 28 Sep 2007 18:45:43 +0000
parents 9355f9b7bbff
children 73661ddc7ac7 5039706521c9
comparison
equal deleted inserted replaced
78913:fbe123a50f74 78914:9eca5b992f1f
491 ;; This is not a hostname but a URL. This may actually be considered 491 ;; This is not a hostname but a URL. This may actually be considered
492 ;; as a feature since it allows vc-svn-stay-local to specify different 492 ;; as a feature since it allows vc-svn-stay-local to specify different
493 ;; behavior for different modules on the same server. 493 ;; behavior for different modules on the same server.
494 (match-string 1)))) 494 (match-string 1))))
495 495
496 (defun vc-svn-resolve-when-done ()
497 "Call \"svn resolved\" if the conflict markers have been removed."
498 (save-excursion
499 (goto-char (point-min))
500 (if (not (re-search-forward "^<<<<<<< " nil t))
501 (vc-svn-command nil 0 buffer-file-name "resolved"))))
502
503 ;; Inspired by vc-arch-find-file-hook.
504 (defun vc-svn-find-file-hook ()
505 (when (eq ?C (vc-file-getprop buffer-file-name 'vc-svn-status))
506 ;; If the file is marked as "conflicted", then we should try and call
507 ;; "svn resolved" when applicable.
508 (if (save-excursion
509 (goto-char (point-min))
510 (re-search-forward "^<<<<<<< " nil t))
511 ;; There are conflict markers.
512 (progn
513 (smerge-mode 1)
514 (add-hook 'after-save-hook 'vc-svn-resolve-when-done nil t))
515 ;; There are no conflict markers. This is problematic: maybe it means
516 ;; the conflict has been resolved and we should immediately call "svn
517 ;; resolved", or it means that the file's type does not allow Svn to
518 ;; use conflict markers in which case we don't really know what to do.
519 ;; So let's just punt for now.
520 nil)
521 (message "There are unresolved conflicts in this file")))
522
496 (defun vc-svn-parse-status (&optional filename) 523 (defun vc-svn-parse-status (&optional filename)
497 "Parse output of \"svn status\" command in the current buffer. 524 "Parse output of \"svn status\" command in the current buffer.
498 Set file properties accordingly. Unless FILENAME is non-nil, parse only 525 Set file properties accordingly. Unless FILENAME is non-nil, parse only
499 information about FILENAME and return its status." 526 information about FILENAME and return its status."
500 (let (file status) 527 (let (file status)
513 ;; which is instead set in vc-registered. 540 ;; which is instead set in vc-registered.
514 (unless filename (vc-file-setprop file 'vc-backend 'SVN)) 541 (unless filename (vc-file-setprop file 'vc-backend 'SVN))
515 ;; Use the last-modified revision, so that searching in vc-print-log 542 ;; Use the last-modified revision, so that searching in vc-print-log
516 ;; output works. 543 ;; output works.
517 (vc-file-setprop file 'vc-workfile-version (match-string 3)) 544 (vc-file-setprop file 'vc-workfile-version (match-string 3))
545 ;; Remember Svn's own status.
546 (vc-file-setprop file 'vc-svn-status status)
518 (vc-file-setprop 547 (vc-file-setprop
519 file 'vc-state 548 file 'vc-state
520 (cond 549 (cond
521 ((eq status ?\ ) 550 ((eq status ?\ )
522 (if (eq (char-after (match-beginning 1)) ?*) 551 (if (eq (char-after (match-beginning 1)) ?*)