[Top][All Lists]

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

Re: vc-svn and "resolved"

From: Stefan Monnier
Subject: Re: vc-svn and "resolved"
Date: Tue, 18 Sep 2007 23:33:20 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

> After an "svn update", sometimes a file will have a conflict.  With
> svn, unlike cvs, you must run "svn resolved" on a file after resolving
> conflicts.

> I think vc-svn should do this for me.  Ideally this would happen
> automatically when I edit out the conflict markers and save the file.

The patch below might be a good starting point.  Could you try it out?


--- vc-svn.el   28 jui 2007 16:22:17 -0400
+++ vc-svn.el   18 sep 2007 23:26:14 -0400      
@@ -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)
         file 'vc-state

reply via email to

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