changeset 78166:516805bc7988

(vc-hg-registered): Replace if with when. (vc-hg-state): Deal with nonexistent files.
author Dan Nicolaescu <dann@ics.uci.edu>
date Thu, 19 Jul 2007 23:51:28 +0000
parents dbaad02ecde9
children 252b7f091c04
files lisp/ChangeLog lisp/vc-hg.el
diffstat 2 files changed, 15 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed Jul 18 22:20:42 2007 +0000
+++ b/lisp/ChangeLog	Thu Jul 19 23:51:28 2007 +0000
@@ -1,3 +1,8 @@
+2007-07-19  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc-hg.el (vc-hg-registered): Replace if with when.
+	(vc-hg-state): Deal with nonexistent files.
+
 2007-07-18  Juanma Barranquero  <lekktu@gmail.com>
 
 	* follow.el (follow-mode-hook, follow-mode-off-hook, follow-mode)
--- a/lisp/vc-hg.el	Wed Jul 18 22:20:42 2007 +0000
+++ b/lisp/vc-hg.el	Thu Jul 19 23:51:28 2007 +0000
@@ -4,7 +4,6 @@
 
 ;; Author: Ivan Kanis
 ;; Keywords: tools
-;; Version: 1889
 
 ;; This file is part of GNU Emacs.
 
@@ -137,8 +136,8 @@
 ;; Modelled after the similar function in vc-bzr.el
 (defun vc-hg-registered (file)
   "Return non-nil if FILE is registered with hg."
-  (if (vc-hg-root file)               ; short cut
-      (vc-hg-state file)))            ; expensive
+  (when (vc-hg-root file)           ; short cut
+    (vc-hg-state file)))            ; expensive
 
 (defun vc-hg-state (file)
   "Hg-specific version of `vc-state'."
@@ -159,13 +158,14 @@
 		    (error nil)))))))
     (when (eq 0 status)
       (if (eq 0 (length out)) 'up-to-date
-	(let ((state (aref out 0)))
-	  (cond
-	   ((eq state ?A) 'edited)
-	   ((eq state ?M) 'edited)
-	   ((eq state ?R) nil)
-	   ((eq state ??) nil)
-	   (t 'up-to-date)))))))
+	(when (null (string-match ".*: No such file or directory$" out))
+	  (let ((state (aref out 0)))
+	    (cond
+	     ((eq state ?A) 'edited)
+	     ((eq state ?M) 'edited)
+	     ((eq state ?R) nil)
+	     ((eq state ??) nil)
+	     (t 'up-to-date))))))))
 
 (defun vc-hg-dir-state (dir)
   (with-temp-buffer