]> git.eshelyaron.com Git - emacs.git/commitdiff
(vc-bzr-resolve-when-done, vc-bzr-find-file-hook): New functions.
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 6 Mar 2008 22:08:21 +0000 (22:08 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 6 Mar 2008 22:08:21 +0000 (22:08 +0000)
lisp/ChangeLog
lisp/vc-bzr.el

index 9dd876afbfacbbc8183f6468e02e1d03b128c799..b415c11303ba5a7cb93da08b56cd58496be8caf3 100644 (file)
@@ -1,5 +1,8 @@
 2008-03-06  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * vc-bzr.el (vc-bzr-resolve-when-done, vc-bzr-find-file-hook):
+       New functions.
+
        * info.el (Info-bookmark-make-cell): Don't use the info-node argument.
 
 2008-03-06  Lennart Borgman  <lennart.borgman@gmail.com>  (tiny change)
index e0ce72dd31f46e8d80bb15491d577ff36bea26af..e126296d77913ec9817035b52b5b39d448f22ae2 100644 (file)
@@ -232,6 +232,33 @@ If any error occurred in running `bzr status', then return nil."
                    (unknown . nil)
                    (unchanged . up-to-date)))))))
 
+(defun vc-bzr-resolve-when-done ()
+  "Call \"bzr resolve\" if the conflict markers have been removed."
+  (save-excursion
+    (goto-char (point-min))
+    (unless (re-search-forward "^<<<<<<< " nil t)
+      (vc-bzr-command "resolve" nil 0 buffer-file-name)
+      ;; Remove the hook so that it is not called multiple times.
+      (remove-hook 'after-save-hook 'vc-bzr-resolve-when-done t))))
+
+(defun vc-bzr-find-file-hook ()
+  (when (and buffer-file-name
+             ;; FIXME: We should check that "bzr status" says "conflict".
+             (file-exists-p (concat buffer-file-name ".BASE"))
+             (file-exists-p (concat buffer-file-name ".OTHER"))
+             (file-exists-p (concat buffer-file-name ".THIS"))
+             ;; If "bzr status" says there's a conflict but there are no
+             ;; conflict markers, it's not clear what we should do.
+             (save-excursion
+               (goto-char (point-min))
+               (re-search-forward "^<<<<<<< " nil t)))
+    ;; TODO: the merge algorithm used in `bzr merge' is nicely configurable,
+    ;; but the one in `bzr pull' isn't, so it would be good to provide an
+    ;; elisp function to remerge from the .BASE/OTHER/THIS files.
+    (smerge-start-session)
+    (add-hook 'after-save-hook 'vc-bzr-resolve-when-done nil t)
+    (message "There are unresolved conflicts in this file")))
+
 (defun vc-bzr-workfile-unchanged-p (file)
   (eq 'unchanged (car (vc-bzr-status file))))