emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r107860: * lisp/vc/vc-bzr.el (vc-bzr-


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107860: * lisp/vc/vc-bzr.el (vc-bzr-status): Handle all errors, not just file-errors.
Date: Tue, 10 Apr 2012 22:06:59 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107860
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Tue 2012-04-10 22:06:59 -0400
message:
  * lisp/vc/vc-bzr.el (vc-bzr-status): Handle all errors, not just file-errors.
  Ref: http://lists.gnu.org/archive/html/help-gnu-emacs/2012-04/msg00145.html
modified:
  lisp/ChangeLog
  lisp/vc/vc-bzr.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-04-11 01:16:48 +0000
+++ b/lisp/ChangeLog    2012-04-11 02:06:59 +0000
@@ -1,5 +1,8 @@
 2012-04-11  Glenn Morris  <address@hidden>
 
+       * vc/vc-bzr.el (vc-bzr-status): Handle all errors,
+       not just file-errors.
+
        * vc/vc-bzr.el (vc-bzr-sha1-program, sha1-program): Remove.
        (vc-bzr-sha1): Use internal sha1.
 

=== modified file 'lisp/vc/vc-bzr.el'
--- a/lisp/vc/vc-bzr.el 2012-04-11 01:16:48 +0000
+++ b/lisp/vc/vc-bzr.el 2012-04-11 02:06:59 +0000
@@ -400,49 +400,52 @@
 `ignored', `kindchanged', `modified', `removed', `renamed', `unknown',
 which directly correspond to `bzr status' output, or 'unchanged
 for files whose copy in the working tree is identical to the one
-in the branch repository, or nil for files that are not
-registered with Bzr.
-
-If any error occurred in running `bzr status', then return nil."
+in the branch repository (or whose status not be determined)."
+;; Doc used to also say the following, but AFAICS, it has never been true.
+;;
+;;   ", or nil for files that are not registered with Bzr.
+;;   If any error occurred in running `bzr status', then return nil."
+;;
+;; Rather than returning nil in case of an error, it returns
+;; (unchanged . WARNING).  FIXME unchanged is not the best status to
+;; return in case of error.
   (with-temp-buffer
-    (let ((ret (condition-case nil
-                   (vc-bzr-command "status" t 0 file)
-                 (file-error nil)))     ; vc-bzr-program not found.
-          (status 'unchanged))
-          ;; the only secure status indication in `bzr status' output
-          ;; is a couple of lines following the pattern::
-          ;;   | <status>:
-          ;;   |   <file name>
-          ;; if the file is up-to-date, we get no status report from `bzr',
-          ;; so if the regexp search for the above pattern fails, we consider
-          ;; the file to be up-to-date.
-          (goto-char (point-min))
-          (when (re-search-forward
-                 ;; bzr prints paths relative to the repository root.
-                 (concat "^\\(" vc-bzr-state-words "\\):[ \t\n]+"
-                         (regexp-quote (vc-bzr-file-name-relative file))
-                         ;; Bzr appends a '/' to directory names and
-                         ;; '*' to executable files
-                         (if (file-directory-p file) "/?" "\\*?")
-                         "[ \t\n]*$")
-                 nil t)
-            (lexical-let ((statusword (match-string 1)))
-              ;; Erase the status text that matched.
-              (delete-region (match-beginning 0) (match-end 0))
-              (setq status
-                    (intern (replace-regexp-in-string " " "" statusword)))))
-          (when status
-            (goto-char (point-min))
-            (skip-chars-forward " \n\t") ;Throw away spaces.
-            (cons status
-                  ;; "bzr" will output warnings and informational messages to
-                  ;; stderr; due to Emacs's `vc-do-command' (and, it seems,
-                  ;; `start-process' itself) limitations, we cannot catch 
stderr
-                  ;; and stdout into different buffers.  So, if there's 
anything
-                  ;; left in the buffer after removing the above status
-                  ;; keywords, let us just presume that any other message from
-                  ;; "bzr" is a user warning, and display it.
-                  (unless (eobp) (buffer-substring (point) (point-max))))))))
+    (with-demoted-errors (vc-bzr-command "status" t 0 file))
+    (let ((status 'unchanged))
+      ;; the only secure status indication in `bzr status' output
+      ;; is a couple of lines following the pattern::
+      ;;   | <status>:
+      ;;   |   <file name>
+      ;; if the file is up-to-date, we get no status report from `bzr',
+      ;; so if the regexp search for the above pattern fails, we consider
+      ;; the file to be up-to-date.
+      (goto-char (point-min))
+      (when (re-search-forward
+             ;; bzr prints paths relative to the repository root.
+             (concat "^\\(" vc-bzr-state-words "\\):[ \t\n]+"
+                     (regexp-quote (vc-bzr-file-name-relative file))
+                     ;; Bzr appends a '/' to directory names and
+                     ;; '*' to executable files
+                     (if (file-directory-p file) "/?" "\\*?")
+                     "[ \t\n]*$")
+             nil t)
+        (lexical-let ((statusword (match-string 1)))
+          ;; Erase the status text that matched.
+          (delete-region (match-beginning 0) (match-end 0))
+          (setq status
+                (intern (replace-regexp-in-string " " "" statusword)))))
+      (when status
+        (goto-char (point-min))
+        (skip-chars-forward " \n\t") ;Throw away spaces.
+        (cons status
+              ;; "bzr" will output warnings and informational messages to
+              ;; stderr; due to Emacs's `vc-do-command' (and, it seems,
+              ;; `start-process' itself) limitations, we cannot catch stderr
+              ;; and stdout into different buffers.  So, if there's anything
+              ;; left in the buffer after removing the above status
+              ;; keywords, let us just presume that any other message from
+              ;; "bzr" is a user warning, and display it.
+              (unless (eobp) (buffer-substring (point) (point-max))))))))
 
 (defun vc-bzr-state (file)
   (lexical-let ((result (vc-bzr-status file)))


reply via email to

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