emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r111101: Add conflict detection/resol


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111101: Add conflict detection/resolution to vc-hg (bug#10709)
Date: Tue, 04 Dec 2012 20:49:31 -0500
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111101
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Tue 2012-12-04 20:49:31 -0500
message:
  Add conflict detection/resolution to vc-hg (bug#10709)
  
  * lisp/vc/vc-hg.el (vc-hg-resolve-when-done, vc-hg-find-file-hook):
  New functions, for detecting and resolving conflicts.
modified:
  lisp/ChangeLog
  lisp/vc/vc-hg.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-12-04 21:13:47 +0000
+++ b/lisp/ChangeLog    2012-12-05 01:49:31 +0000
@@ -1,3 +1,8 @@
+2012-12-05  Glenn Morris  <address@hidden>
+
+       * vc/vc-hg.el (vc-hg-resolve-when-done, vc-hg-find-file-hook):
+       New functions, for detecting and resolving conflicts.  (Bug#10709)
+
 2012-12-04  Jambunathan K  <address@hidden>
 
        * hi-lock.el (hi-lock-auto-select-face): New user variable.

=== modified file 'lisp/vc/vc-hg.el'
--- a/lisp/vc/vc-hg.el  2012-12-01 02:10:53 +0000
+++ b/lisp/vc/vc-hg.el  2012-12-05 01:49:31 +0000
@@ -93,7 +93,7 @@
 ;; - clear-headers ()                          ??
 ;; - delete-file (file)                        TEST IT
 ;; - rename-file (old new)                     OK
-;; - find-file-hook ()                         PROBABLY NOT NEEDED
+;; - find-file-hook ()                         added for bug#10709
 
 ;; 2) Implement Stefan Monnier's advice:
 ;; vc-hg-registered and vc-hg-state
@@ -464,6 +464,35 @@
         (vc-hg-command t 0 file "cat" "-r" rev)
       (vc-hg-command t 0 file "cat")))))
 
+(defun vc-hg-resolve-when-done ()
+  "Call \"hg resolve -m\" if the conflict markers have been removed."
+  (save-excursion
+    (goto-char (point-min))
+    (unless (re-search-forward "^<<<<<<< " nil t)
+      (vc-hg-command nil 0 buffer-file-name "resolve" "-m")
+      ;; Remove the hook so that it is not called multiple times.
+      (remove-hook 'after-save-hook 'vc-hg-resolve-when-done t))))
+
+(defun vc-hg-find-file-hook ()
+  (when (and buffer-file-name
+             (file-exists-p (concat buffer-file-name ".orig"))
+             ;; Hg does not seem to have a "conflict" status, eg
+             ;; hg http://bz.selenic.com/show_bug.cgi?id=2724
+             (memq (vc-file-getprop buffer-file-name 'vc-state)
+                   '(edited conflict))
+             ;; Maybe go on to check that "hg resolve -l" says "U"?
+             ;; If "hg resolve -l" 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)))
+    ;; Hg may not recognize "conflict" as a state, but we can do better.
+    (vc-file-setprop buffer-file-name 'vc-state 'conflict)
+    (smerge-start-session)
+    (add-hook 'after-save-hook 'vc-hg-resolve-when-done nil t)
+    (message "There are unresolved conflicts in this file")))
+
+
 ;; Modeled after the similar function in vc-bzr.el
 (defun vc-hg-workfile-unchanged-p (file)
   (eq 'up-to-date (vc-hg-state file)))


reply via email to

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