changeset 93956:bfc762f0b49c

* vc-hooks.el (vc-state): Add new state `conflict'. (vc-after-save): Use when not if. (vc-default-mode-line-string): Deal with the conflict state. (vc-prefix-map): (vc-menu-map): Bind vc-status instead of vc-directory. * vc.el (vc-editable-p): (vc-default-status-printer): (vc-next-action): Deal with the conflict state. (vc-mark-resolved): New function. (vc-status-mode): Fix mode name. (vc-default-comment-history): Use when not if. (Todo): Add new entries, remove old ones. * vc-cvs.el (vc-cvs-merge, vc-cvs-merge-news): Set conflict state. (vc-cvs-parse-status): (vc-cvs-after-dir-status): * vc-svn.el (vc-svn-after-dir-status, vc-svn-parse-status): Detect the conflict state.
author Dan Nicolaescu <dann@ics.uci.edu>
date Thu, 10 Apr 2008 07:32:25 +0000
parents 758c5f9b9633
children 139a888c8649
files lisp/ChangeLog lisp/vc-cvs.el lisp/vc-hooks.el lisp/vc-svn.el lisp/vc.el
diffstat 5 files changed, 107 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Apr 10 05:20:15 2008 +0000
+++ b/lisp/ChangeLog	Thu Apr 10 07:32:25 2008 +0000
@@ -1,3 +1,25 @@
+2008-04-10  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc-hooks.el (vc-state): Add new state `conflict'.
+	(vc-after-save): Use when not if.
+	(vc-default-mode-line-string): Deal with the conflict state.
+	(vc-prefix-map):
+	(vc-menu-map): Bind vc-status instead of vc-directory.
+
+	* vc.el (vc-editable-p):
+	(vc-default-status-printer):
+	(vc-next-action): Deal with the conflict state.
+	(vc-mark-resolved): New function.
+	(vc-status-mode): Fix mode name.
+	(vc-default-comment-history): Use when not if.
+	(Todo): Add new entries, remove old ones.
+
+	* vc-cvs.el (vc-cvs-merge, vc-cvs-merge-news): Set conflict state.
+	(vc-cvs-parse-status):
+	(vc-cvs-after-dir-status):
+	* vc-svn.el (vc-svn-after-dir-status, vc-svn-parse-status):
+	Detect the conflict state.
+
 2008-04-10  Glenn Morris  <rgm@gnu.org>
 
 	* Makefile.in (MH_E_DIR): New variable.
--- a/lisp/vc-cvs.el	Thu Apr 10 05:20:15 2008 +0000
+++ b/lisp/vc-cvs.el	Thu Apr 10 07:32:25 2008 +0000
@@ -436,8 +436,13 @@
   (with-current-buffer (get-buffer "*vc*")
     (goto-char (point-min))
     (if (re-search-forward "conflicts during merge" nil t)
-        1				; signal error
-      0)))				; signal success
+	(progn 
+	  (vc-file-setprop file 'vc-state 'conflict)
+	  ;; signal error
+	  1)
+      (vc-file-setprop file 'vc-state 'edited)
+      ;; signal success
+      0)))
 
 (defun vc-cvs-merge-news (file)
   "Merge in any new changes made to FILE."
@@ -478,7 +483,7 @@
                 0);; indicate success to the caller
                ;; Conflicts detected!
                (t
-                (vc-file-setprop file 'vc-state 'edited)
+                (vc-file-setprop file 'vc-state 'conflict)
                 1);; signal the error to the caller
                )
             (pop-to-buffer "*vc*")
@@ -814,11 +819,11 @@
 	(if (not (re-search-forward "\\=[ \t]+Status: \\(.*\\)" nil t))
 	    (setq status "Unknown")
 	  (setq status (match-string 1)))
-	(if (and full
-		 (re-search-forward
-		  "\\(RCS Version\\|RCS Revision\\|Repository revision\\):\
+	(when (and full
+		   (re-search-forward
+		    "\\(RCS Version\\|RCS Revision\\|Repository revision\\):\
 \[\t ]+\\([0-9.]+\\)"
-		  nil t))
+		    nil t))
 	    (vc-file-setprop file 'vc-latest-revision (match-string 2)))
 	(vc-file-setprop
 	 file 'vc-state
@@ -833,6 +838,7 @@
 	   (if missing 'missing 'needs-patch))
 	  ((string-match "Locally Added" status)                'added)
 	  ((string-match "Locally Removed" status)              'removed)
+	  ((string-match "File had conflicts " status)          'conflict)
 	  (t 'edited))))))))
 
 (defun vc-cvs-dir-state-heuristic (dir)
@@ -897,6 +903,7 @@
 		    (if missing 'missing 'needs-patch))
 		   ((string-match "Locally Added" status-str) 'added)
 		   ((string-match "Locally Removed" status-str) 'removed)
+		   ((string-match "File had conflicts " status-str) 'conflict)
 		   (t 'edited)))
 	    (unless (eq status 'up-to-date)
 	      (push (list file status) result))))))
--- a/lisp/vc-hooks.el	Thu Apr 10 05:20:15 2008 +0000
+++ b/lisp/vc-hooks.el	Thu Apr 10 07:32:25 2008 +0000
@@ -517,6 +517,11 @@
 
   'removed           Scheduled to be deleted from the repository on next commit.
 
+  'conflict          The file contains conflicts as the result of a merge.
+                     For now the conflicts are text conflicts.  In the 
+                     futures this might be extended to deal with metadata
+                     conflicts too.
+
   'missing           The file is not present in the file system, but the VC 
                      system still tracks it.
 
@@ -775,10 +780,10 @@
          (eq (vc-checkout-model file) 'implicit)
          (vc-file-setprop file 'vc-state 'edited)
 	 (vc-mode-line file)
-	 (if (featurep 'vc)
-	     ;; If VC is not loaded, then there can't be
-	     ;; any VC Dired buffer to synchronize.
-	     (vc-dired-resynch-file file)))))
+	 (when (featurep 'vc)
+	   ;; If VC is not loaded, then there can't be
+	   ;; any VC Dired buffer to synchronize.
+	   (vc-dired-resynch-file file)))))
 
 (defvar vc-menu-entry
   '(menu-item "Version Control" vc-menu-map
@@ -861,6 +866,9 @@
            ((eq state 'added)
             (setq state-echo "Locally added file")
             (concat backend "@" rev))
+           ((eq state 'conflict)
+            (setq state-echo "File contains conflicts after the last merge")
+            (concat backend "!" rev))
            ((eq state 'removed)
             (setq state-echo "File removed from the VC system")
             (concat backend "!" rev))
@@ -981,7 +989,7 @@
     (define-key map "a" 'vc-update-change-log)
     (define-key map "b" 'vc-switch-backend)
     (define-key map "c" 'vc-rollback)
-    (define-key map "d" 'vc-directory)
+    (define-key map "d" 'vc-status)
     (define-key map "g" 'vc-annotate)
     (define-key map "h" 'vc-insert-headers)
     (define-key map "i" 'vc-register)
@@ -1010,11 +1018,6 @@
     (define-key map [vc-create-snapshot]
       '(menu-item "Create Snapshot" vc-create-snapshot
 		  :help "Create Snapshot"))
-    (define-key map [vc-directory]
-      '(menu-item "VC Directory Listing"  vc-directory
-		  :help "Show the VC status of files in a directory"))
-    ;; `vc-status' is a not-quite-ready replacement for `vc-directory'
-    ;; (define-key map [vc-status] '("VC Status" . vc-status))
     (define-key map [separator1] '("----"))
     (define-key map [vc-annotate]
       '(menu-item "Annotate" vc-annotate
@@ -1054,6 +1057,9 @@
     (define-key map [vc-register]
       '(menu-item "Register" vc-register
 		  :help "Register file set into a version control system"))
+    (define-key map [vc-status]
+      '(menu-item "VC Status"  vc-status
+		  :help "Show the VC status of files in a directory"))
     map))
 
 (defalias 'vc-menu-map vc-menu-map)
--- a/lisp/vc-svn.el	Thu Apr 10 05:20:15 2008 +0000
+++ b/lisp/vc-svn.el	Thu Apr 10 07:32:25 2008 +0000
@@ -160,7 +160,7 @@
 
 (defun vc-svn-after-dir-status (callback buffer)
   (let ((state-map '((?A . added)
-                    (?C . edited)
+                    (?C . conflict)
                     (?D . removed)
                     (?I . ignored)
                     (?M . edited)
@@ -636,7 +636,9 @@
 	   (vc-file-setprop file 'vc-working-revision "0")
 	   (vc-file-setprop file 'vc-checkout-time 0)
 	   'added)
-	  ((memq status '(?M ?C))
+	  ((eq status ?C)
+	   (vc-file-setprop file 'vc-state 'conflict))
+	  ((eq status '?M)
 	   (if (eq (char-after (match-beginning 1)) ?*)
 	       'needs-merge
 	     'edited))
--- a/lisp/vc.el	Thu Apr 10 05:20:15 2008 +0000
+++ b/lisp/vc.el	Thu Apr 10 07:32:25 2008 +0000
@@ -37,10 +37,11 @@
 ;;   Martin Lorentzson <martinl@gnu.org>
 ;;   Dave Love <fx@gnu.org>
 ;;   Stefan Monnier <monnier@cs.yale.edu>
+;;   Thien-Thi Nguyen <ttn@gnu.org>
+;;   Dan Nicolaescu <dann@ics.uci.edu>
 ;;   J.D. Smith <jdsmith@alum.mit.edu>
 ;;   Andre Spiegel <spiegel@gnu.org>
 ;;   Richard Stallman <rms@gnu.org>
-;;   Thien-Thi Nguyen <ttn@gnu.org>
 ;;
 ;; In July 2007 ESR returned and redesigned the mode to cope better
 ;; with modern version-control systems that do commits by fileset
@@ -199,7 +200,7 @@
 ;;   If a backend needs to show more information than the default FILE
 ;;   and STATE in the vc-status listing, it can store that extra
 ;;   information in `vc-status-fileinfo->extra'.  This function can be
-;;   used to display that extra information in the vc-status buffer.
+;;   used to display that extra information in the *vc-status* buffer.
 ;;
 ;; - status-fileinfo-extra (file)
 ;;
@@ -362,6 +363,11 @@
 ;;   Modify the change comments associated with the files at the
 ;;   given revision.  This is optional, many backends do not support it.
 ;;
+;; - mark-resolved (files)
+;;
+;;   Mark conflicts as resolved.  Some VC systems need to run a
+;;   command to mark conflicts as resolved.
+;;
 ;; HISTORY FUNCTIONS
 ;;
 ;; * print-log (files &optional buffer)
@@ -583,20 +589,21 @@
 ;;
 ;; - "snapshots" should be renamed to "branches", and thoroughly reworked.
 ;;
-;; - the backend sometimes knows when a file it opens has been marked
-;;   by the VCS as having a "conflict". Find a way to pass this info -
-;;   to VC so that it can turn on smerge-mode when opening such a
-;;   file.
+;; - when a file is in `conflict' state, turn on smerge-mode.
+;;
+;; - figure out what to do with conflicts that are not caused by the
+;;   file contents, but by metadata or other causes.
 ;;
 ;; - add a generic mechanism for remembering the current branch names,
 ;;   display the branch name in the mode-line. Replace
 ;;   vc-cvs-sticky-tag with that.
 ;;
 ;; - vc-diff should be able to show the diff for all files in a
-;;   changeset, especially for VC systems that have per repository version numbers.
-;;   log-view should take advantage of this.
-;;
-;; - a way to do repository wide log (instead of just per file/fileset) is needed.
+;;   changeset, especially for VC systems that have per repository
+;;   version numbers.  log-view should take advantage of this.
+;;
+;; - a way to do repository wide log (instead of just per
+;;   file/fileset) is needed.
 ;;
 ;; - the *VC-log* buffer needs font-locking.
 ;;
@@ -615,7 +622,14 @@
 ;; - vc-next-action should do something about 'missing files. Maybe
 ;;   just warn, or offer to checkout.
 ;;
-;; - decide if vc-status should replace vc-dired.
+;; - display the directory names in vc-status, similar to what PCL-CVS
+;;   does.
+;;
+;; - most vc-status backends need more work.  They might need to
+;;   provide custom headers, use the `extra' field and deal with all
+;;   possible VC states.
+;;
+;; - add function that calls vc-status to `find-directory-functions'.
 ;;
 ;; - vc-status needs mouse bindings.
 ;;
@@ -623,12 +637,13 @@
 ;;
 ;; - vc-status toolbar needs more icons.
 ;;
+;; - vc-status needs a command to insert a file entry in the status
+;;   display, similar to `cvs-mode-insert'.
+;;
 ;; - the dir-status backend function should take as an argument an
-;;   optional fileset.  and return the results just for that fileset.
-;;   This can be used to speed up status buffer updates after VC
-;;   operations.
-;;
-;; - keep the *vc-status* buffer sorted by file name.
+;;   optional fileset, and should return the results just for that
+;;   fileset.  This can be used to speed up status buffer updates
+;;   after VC operations.
 ;;
 ;; - vc-status: refresh should not completely wipe out the current
 ;;   contents of the vc-status buffer.
@@ -646,6 +661,7 @@
 
 (require 'vc-hooks)
 (require 'tool-bar)
+(require 'ewoc)
 
 (eval-when-compile
   (require 'cl)
@@ -1478,7 +1494,7 @@
 (defsubst vc-editable-p (file)
   "Return non-nil if FILE can be edited."
   (or (eq (vc-checkout-model file) 'implicit)
-      (memq (vc-state file) '(edited needs-merge))))
+      (memq (vc-state file) '(edited needs-merge conflict))))
 
 (defun vc-revert-buffer-internal (&optional arg no-confirm)
   "Revert buffer, keeping point and mark where user expects them.
@@ -1667,6 +1683,9 @@
                   (read-string (format "%s revision to steal: " file))
                 (vc-working-revision file))
          state)))
+     ;; conflict
+     ((eq state 'conflict)
+      (vc-mark-resolved files))
      ;; needs-patch
      ((eq state 'needs-patch)
       (dolist (file files)
@@ -1901,6 +1920,13 @@
   (vc-resynch-buffer file t t)
   (run-hooks 'vc-checkout-hook))
 
+(defun vc-mark-resolved (files)
+  (with-vc-properties
+   files
+   (vc-call mark-resolved files)
+   ;; XXX: Is this TRTD?  Might not be.
+   `((vc-state . edited))))
+
 (defun vc-steal-lock (file rev owner)
   "Steal the lock on FILE."
   (let (file-description)
@@ -2673,9 +2699,7 @@
                               vc-dired-switches
                               'vc-dired-mode))))
 
-;;; Experimental code for the vc-dired replacement
-(require 'ewoc)
-
+;; VC status implementation
 
 ;; Used to store information for the files displayed in the *VC status* buffer.
 ;; Each item displayed corresponds to one of these defstructs.
@@ -2722,7 +2746,7 @@
      (propertize
       (format "%-20s" state)
       'face (cond ((eq state 'up-to-date) 'font-lock-builtin-face)
-		  ((eq state 'missing) 'font-lock-warning-face)
+		  ((memq state '(missing conflict)) 'font-lock-warning-face)
 		  (t 'font-lock-variable-name-face))
       'mouse-face 'highlight)
      " "
@@ -2956,7 +2980,7 @@
 (defun vc-status-mode ()
   "Major mode for VC status.
 \\{vc-status-mode-map}"
-  (setq mode-name "*VC Status*")
+  (setq mode-name "VC Status")
   (setq major-mode 'vc-status-mode)
   (setq buffer-read-only t)
   (set (make-local-variable 'vc-status-crt-marked) nil)
@@ -3278,8 +3302,6 @@
       ;; not needed.
       (unless found-vc-status-buf (remove-hook 'after-save-hook 'vc-status-mark-buffer-changed)))))
 
-;;; End experimental code.
-
 ;; Named-configuration entry points
 
 (defun vc-snapshot-precondition (dir)
@@ -3909,11 +3931,11 @@
 
 (defun vc-default-comment-history (backend file)
   "Return a string with all log entries stored in BACKEND for FILE."
-  (if (vc-find-backend-function backend 'print-log)
-      (with-current-buffer "*vc*"
-	(vc-call print-log (list file))
-	(vc-call-backend backend 'wash-log)
-	(buffer-string))))
+  (when (vc-find-backend-function backend 'print-log)
+    (with-current-buffer "*vc*"
+      (vc-call print-log (list file))
+      (vc-call-backend backend 'wash-log)
+      (buffer-string))))
 
 (defun vc-default-receive-file (backend file rev)
   "Let BACKEND receive FILE from another version control system."