all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dan Nicolaescu <dann@ics.uci.edu>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: conflict state (was Re: VC state)
Date: Tue, 08 Apr 2008 08:03:12 -0700	[thread overview]
Message-ID: <200804081503.m38F3C3A019899@sallyv1.ics.uci.edu> (raw)
In-Reply-To: <jwvhcedyadt.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 07 Apr 2008 11:16:22 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

  > > This has been in Todo for a while, displaying this stuff is trivial, VC
  > > needs just to provide the information.  Someone just needs to sit down
  > > and figure out how it's supposed to work in VC...
  > 
  > With some backends (E.g. Svn and Bzr), it would make a lot of sense to
  > make it a new vc-state, since you need to run `(svn|bzr) resolve' to
  > switch from that state to `edited' and you can't commit before.
  > 
  > In other bakends, it's less clear.  Maybe you should try to simply add
  > `conflict' as a new `vc-state' and see how it works out.  This will
  > require checking all uses of `vc-state' to adjust them to the new state.

A patch to implement the new conflict state is below.  Can you please
change the magic that runs the resolve command and turns on
smerge-mode to use this state instead?
Not sure what to do about the new `mark-resolved' backend function for
CVS, it probably should be just a no-op, it should be easy to see once
the smerge logic is in place.


Index: vc-hooks.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc-hooks.el,v
retrieving revision 1.234
diff -u -3 -p -r1.234 vc-hooks.el
--- vc-hooks.el	1 Apr 2008 02:58:15 -0000	1.234
+++ vc-hooks.el	8 Apr 2008 06:29:00 -0000
@@ -517,6 +517,8 @@ For registered files, the value returned
 
   'removed           Scheduled to be deleted from the repository on next commit.
 
+  'conflict          The file contains conflicts as the result of a merge.
+
   'missing           The file is not present in the file system, but the VC 
                      system still tracks it.
 
@@ -775,10 +777,10 @@ Before doing that, check if there are an
          (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 +863,9 @@ This function assumes that the file is r
            ((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))
Index: vc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
retrieving revision 1.573
diff -u -3 -p -r1.573 vc.el
--- vc.el	6 Apr 2008 17:30:39 -0000	1.573
+++ vc.el	8 Apr 2008 06:29:04 -0000
@@ -362,6 +362,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)
+;;
+;;   The the VCS that conflicts have been resolved.  Not all systems
+;;   need to do this.
+;;
 ;; HISTORY FUNCTIONS
 ;;
 ;; * print-log (files &optional buffer)
@@ -1478,7 +1483,7 @@ Otherwise, throw an error."
 (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 +1672,9 @@ merge in the changes into your working c
                   (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 +1909,13 @@ After check-out, runs the normal hook `v
   (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?
+   `((vc-state . edited))))
+
 (defun vc-steal-lock (file rev owner)
   "Steal the lock on FILE."
   (let (file-description)
@@ -2722,7 +2737,7 @@ specific headers."
      (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)
      " "
@@ -3898,6 +3913,10 @@ to provide the `find-revision' operation
   (with-current-buffer (find-file-noselect new)
     (vc-register)))
 
+(defun vc-default-mark-resolved (backend files)
+  ;; XXX: For testing.
+  (error "Backend implements the conflict state, but it does not implement a `mark-resolved' function"))
+
 (defalias 'vc-default-logentry-check 'ignore)
 (defalias 'vc-default-check-headers 'ignore)
 
@@ -3909,11 +3928,11 @@ to provide the `find-revision' operation
 
 (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."
Index: vc-svn.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc-svn.el,v
retrieving revision 1.75
diff -u -3 -p -r1.75 vc-svn.el
--- vc-svn.el	31 Mar 2008 15:36:54 -0000	1.75
+++ vc-svn.el	8 Apr 2008 14:50:29 -0000
@@ -160,7 +160,7 @@ If you want to force an empty list of ar
 
 (defun vc-svn-after-dir-status (callback buffer)
   (let ((state-map '((?A . added)
-                    (?C . edited)
+                    (?C . conflict)
                     (?D . removed)
                     (?I . ignored)
                     (?M . edited)
@@ -327,12 +327,16 @@ The changes are between FIRST-VERSION an
 		 "-r" (if second-version
 			(concat first-version ":" second-version)
 		      first-version))
-  (vc-file-setprop file 'vc-state 'edited)
   (with-current-buffer (get-buffer "*vc*")
     (goto-char (point-min))
     (if (looking-at "C  ")
-        1				; signal conflict
-      0)))				; signal success
+	(progn
+	  (vc-file-setprop file 'vc-state 'conflict)
+	  ;; signal conflict
+	  1)
+      ;; signal success
+      (vc-file-setprop file 'vc-state 'edited)
+      0)))
 
 (defun vc-svn-merge-news (file)
   "Merge in any new changes made to FILE."
@@ -376,7 +380,7 @@ The changes are between FIRST-VERSION an
                 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*")
@@ -621,7 +625,9 @@ information about FILENAME and return it
 	   (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))
Index: vc-cvs.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc-cvs.el,v
retrieving revision 1.114
diff -u -3 -p -r1.114 vc-cvs.el
--- vc-cvs.el	31 Mar 2008 15:36:55 -0000	1.114
+++ vc-cvs.el	8 Apr 2008 14:50:30 -0000
@@ -432,12 +432,16 @@ The changes are between FIRST-REVISION a
                  "update" "-kk"
                  (concat "-j" first-revision)
                  (concat "-j" second-revision))
-  (vc-file-setprop file 'vc-state 'edited)
   (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 +482,7 @@ The changes are between FIRST-REVISION a
                 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*")
@@ -839,11 +843,11 @@ state."
 	(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
@@ -858,6 +862,7 @@ state."
 	   (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)
@@ -922,6 +927,7 @@ state."
 		    (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))))))




  reply	other threads:[~2008-04-08 15:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-06  5:54 VC state Stefan Monnier
2008-04-06 17:40 ` Dan Nicolaescu
2008-04-07 15:16   ` Stefan Monnier
2008-04-08 15:03     ` Dan Nicolaescu [this message]
2008-04-09 20:35       ` conflict state Stefan Monnier
2008-04-09 21:39         ` Dan Nicolaescu
2008-04-10  0:44           ` Stefan Monnier
2008-04-08 20:45     ` VC state Dan Nicolaescu
2008-04-09  2:44       ` Stefan Monnier
2008-04-09  3:07         ` Dan Nicolaescu
2008-04-09  3:52           ` Nick Roberts
2008-04-09 22:54             ` Dan Nicolaescu
2008-04-10  5:53               ` VC development [was Re: VC state] Nick Roberts
2008-04-10  8:33               ` VC state Nick Roberts
2008-04-10 14:13                 ` Dan Nicolaescu
2008-04-11 12:01                   ` Nick Roberts
2008-04-10 19:17                 ` Stefan Monnier
2008-04-09 14:02           ` Stefan Monnier
2008-04-10 17:28             ` Dan Nicolaescu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200804081503.m38F3C3A019899@sallyv1.ics.uci.edu \
    --to=dann@ics.uci.edu \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.