changeset 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 fbe123a50f74
children e7a2828a162d
files lisp/ChangeLog lisp/vc-svn.el
diffstat 2 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Sep 28 05:36:04 2007 +0000
+++ b/lisp/ChangeLog	Fri Sep 28 18:45:43 2007 +0000
@@ -1,5 +1,10 @@
 2007-09-28  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+	* vc-svn.el (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.
+
 	* newcomment.el (comment-choose-indent): New function extracted
 	from comment-indent.  Improve the alignment algorithm.
 	(comment-indent): Use it.
--- a/lisp/vc-svn.el	Fri Sep 28 05:36:04 2007 +0000
+++ b/lisp/vc-svn.el	Fri Sep 28 18:45:43 2007 +0000
@@ -493,6 +493,33 @@
       ;; behavior for different modules on the same server.
       (match-string 1))))
 
+(defun vc-svn-resolve-when-done ()
+  "Call \"svn resolved\" if the conflict markers have been removed."
+  (save-excursion
+    (goto-char (point-min))
+    (if (not (re-search-forward "^<<<<<<< " nil t))
+        (vc-svn-command nil 0 buffer-file-name "resolved"))))
+
+;; Inspired by vc-arch-find-file-hook.
+(defun vc-svn-find-file-hook ()
+  (when (eq ?C (vc-file-getprop buffer-file-name 'vc-svn-status))
+    ;; If the file is marked as "conflicted", then we should try and call
+    ;; "svn resolved" when applicable.
+    (if (save-excursion
+          (goto-char (point-min))
+          (re-search-forward "^<<<<<<< " nil t))
+        ;; There are conflict markers.
+        (progn
+          (smerge-mode 1)
+          (add-hook 'after-save-hook 'vc-svn-resolve-when-done nil t))
+      ;; There are no conflict markers.  This is problematic: maybe it means
+      ;; the conflict has been resolved and we should immediately call "svn
+      ;; resolved", or it means that the file's type does not allow Svn to
+      ;; use conflict markers in which case we don't really know what to do.
+      ;; So let's just punt for now.
+      nil)
+    (message "There are unresolved conflicts in this file")))
+
 (defun vc-svn-parse-status (&optional filename)
   "Parse output of \"svn status\" command in the current buffer.
 Set file properties accordingly.  Unless FILENAME is non-nil, parse only
@@ -515,6 +542,8 @@
 	;; Use the last-modified revision, so that searching in vc-print-log
 	;; output works.
 	(vc-file-setprop file 'vc-workfile-version (match-string 3))
+        ;; Remember Svn's own status.
+        (vc-file-setprop file 'vc-svn-status status)
 	(vc-file-setprop
 	 file 'vc-state
 	 (cond