changeset 54806:e16241d08bbc

(vc-arch-root): Be a bit more careful. (vc-arch-register): Save the buffer if we modified it. (vc-arch-delete-rej-if-obsolete): Save excursion. (vc-arch-find-file-hook): Use the simpler after-save-hook. (vc-arch-responsible-p, vc-arch-init-version): New functions.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 12 Apr 2004 04:23:38 +0000
parents 37581abcf761
children 1e00569924bf
files lisp/vc-arch.el
diffstat 1 files changed, 22 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/vc-arch.el	Mon Apr 12 04:12:02 2004 +0000
+++ b/lisp/vc-arch.el	Mon Apr 12 04:23:38 2004 +0000
@@ -191,17 +191,22 @@
 	 (while (not (or root
 			 (equal file (setq file (file-name-directory file)))
 			 (null file)))
-	   (if (file-directory-p (expand-file-name "{arch}" file))
+	   ;; Check the =tagging-method, in case someone naively manually
+	   ;; creates a {arch} directory somewhere.
+	   (if (file-exists-p (expand-file-name "{arch}/=tagging-method" file))
 	       (setq root file)
 	     (setq file (directory-file-name file))))
 	 root))))
 
 (defun vc-arch-register (file &optional rev comment)
-  (if rev (error "Explicit initial revision not supported for Arch."))
+  (if rev (error "Explicit initial revision not supported for Arch"))
   (let ((tagmet (vc-arch-tagging-method file)))
     (if (and (memq tagmet '(tagline implicit)) comment-start)
 	(with-current-buffer (find-file-noselect file)
-	  (vc-arch-add-tagline))
+	  (if (buffer-modified-p)
+	      (error "Save %s first" (buffer-name)))
+	  (vc-arch-add-tagline)
+	  (save-buffer))
       (vc-arch-command nil 0 file "add"))))
 
 (defun vc-arch-registered (file)
@@ -272,7 +277,7 @@
 				(match-string 1)))
 		    'up-to-date
 		  'edited)))))))))
-	    
+
 (defun vc-arch-workfile-version (file)
   (let* ((root (expand-file-name "{arch}" (vc-arch-root file)))
 	 (defbranch (vc-arch-default-version file)))
@@ -328,14 +333,13 @@
 	   (looking-at "Conflicts occured, diff3 conflict markers left in file\\.")))))
 
 (defun vc-arch-delete-rej-if-obsolete ()
-  "For use in `write-file-functions'."
-  (let ((rej (concat buffer-file-name ".rej")))
-    (when (and buffer-file-name (vc-arch-diff3-rej-p rej))
-      (if (not (re-search-forward "^>>>>>>> " nil t))
-	  ;; The .rej file is obsolete.
-	  (condition-case nil (delete-file rej) (error nil)))))
-  ;; This did not save the buffer.
-  nil)
+  "For use in `after-save-hook'."
+  (save-excursion
+    (let ((rej (concat buffer-file-name ".rej")))
+      (when (and buffer-file-name (vc-arch-diff3-rej-p rej))
+	(if (not (re-search-forward "^<<<<<<< " nil t))
+	    ;; The .rej file is obsolete.
+	    (condition-case nil (delete-file rej) (error nil)))))))
 
 (defun vc-arch-find-file-hook ()
   (let ((rej (concat buffer-file-name ".rej")))
@@ -343,11 +347,11 @@
       (if (vc-arch-diff3-rej-p rej)
 	  (save-excursion
 	    (goto-char (point-min))
-	    (if (not (re-search-forward "^>>>>>>> " nil t))
+	    (if (not (re-search-forward "^<<<<<<< " nil t))
 		;; The .rej file is obsolete.
 		(condition-case nil (delete-file rej) (error nil))
 	      (smerge-mode 1)
-	      (add-hook 'write-file-functions
+	      (add-hook 'after-save-hook
 			'vc-arch-delete-rej-if-obsolete nil t)
 	      (message "There are unresolved conflicts in this file")))
 	(message "There are unresolved conflicts in %s"
@@ -403,10 +407,14 @@
 (defun vc-arch-rename-file (old new)
   (vc-arch-command nil 0 new "mv" (file-relative-name old)))
 
+(defalias 'vc-arch-responsible-p 'vc-arch-root)
+
 (defun vc-arch-command (buffer okstatus file &rest flags)
   "A wrapper around `vc-do-command' for use in vc-arch.el."
   (apply 'vc-do-command buffer okstatus vc-arch-command file flags))
 
+(defun vc-arch-init-version () nil)
+
 (provide 'vc-arch)
 
 ;;; arch-tag: a35c7c1c-5237-429d-88ef-3d718fd2e704