changeset 103236:b4e12b7edf39

(vc-bzr-state-heuristic): Fallback on vc-bzr-state in case of any kind of error (e.g. when "sha1sum" is not found).
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 17 May 2009 03:38:41 +0000
parents 304eb5ff2a17
children 0c05518365a6
files lisp/ChangeLog lisp/vc-bzr.el
diffstat 2 files changed, 61 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat May 16 14:33:16 2009 +0000
+++ b/lisp/ChangeLog	Sun May 17 03:38:41 2009 +0000
@@ -1,3 +1,8 @@
+2009-05-17  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* vc-bzr.el (vc-bzr-state-heuristic): Fallback on vc-bzr-state in case
+	of any kind of error (e.g. when "sha1sum" is not found).
+
 2009-05-15  Martin Rudalics  <rudalics@gmx.at>
 
 	* dired.el (dired-pop-to-buffer): Try to make this behave the
@@ -434,11 +439,11 @@
 
 2009-04-07  Chong Yidong  <cyd@stupidchicken.com>
 
-	* vc-bzr.el (vc-bzr-log-view-mode): Tweak
-	log-view-message-re (Bug#2872).
-
-	* descr-text.el (describe-property-list, describe-char): Add
-	follow-link properties to buttons that need them.
+	* vc-bzr.el (vc-bzr-log-view-mode):
+	Tweak log-view-message-re (Bug#2872).
+
+	* descr-text.el (describe-property-list, describe-char):
+	Add follow-link properties to buttons that need them.
 
 	* tooltip.el (tooltip-show-help-non-mode): Don't save the last
 	message if it was also a help message (Bug#2895).
@@ -446,8 +451,7 @@
 2009-04-06  Roland Winkler  <Roland.Winkler@physik.uni-erlangen.de>
 
 	* textmodes/bibtex.el (bibtex-format-entry)
-	(bibtex-search-crossref): Allow OPT prefix for name of crossref
-	field.
+	(bibtex-search-crossref): Allow OPT prefix for name of crossref field.
 
 2009-04-06  Sam Steingold  <sds@gnu.org>
 
--- a/lisp/vc-bzr.el	Sat May 16 14:33:16 2009 +0000
+++ b/lisp/vc-bzr.el	Sun May 17 03:38:41 2009 +0000
@@ -143,7 +143,7 @@
 
 (defun vc-bzr-state-heuristic (file)
   "Like `vc-bzr-state' but hopefully without running Bzr."
-  ;; `bzr status' is excrutiatingly slow with large histories and
+  ;; `bzr status' was excrutiatingly slow with large histories and
   ;; pending merges, so try to avoid using it until they fix their
   ;; performance problems.
   ;; This function tries first to parse Bzr internal file
@@ -158,50 +158,55 @@
       ;; This looks at internal files.  May break if they change
       ;; their format.
       (lexical-let ((dirstate (expand-file-name vc-bzr-admin-dirstate root)))
-        (if (not (file-readable-p dirstate))
-            (vc-bzr-state file)         ; Expensive.
-          (with-temp-buffer
-            (insert-file-contents dirstate)
-            (goto-char (point-min))
-            (if (not (looking-at "#bazaar dirstate flat format 3"))
-                (vc-bzr-state file)     ; Some other unknown format?
-              (let* ((relfile (file-relative-name file root))
-                     (reldir (file-name-directory relfile)))
-                (if (re-search-forward
-                     (concat "^\0"
-                             (if reldir (regexp-quote
-                                         (directory-file-name reldir)))
-                             "\0"
-                             (regexp-quote (file-name-nondirectory relfile))
-                             "\0"
-                             "[^\0]*\0"       ;id?
-                             "\\([^\0]*\\)\0" ;"a/f/d", a=removed?
-                             "[^\0]*\0"       ;sha1 (empty if conflicted)?
-                             "\\([^\0]*\\)\0" ;size?
-                             "[^\0]*\0"       ;"y/n", executable?
-                             "[^\0]*\0"       ;?
-                             "\\([^\0]*\\)\0" ;"a/f/d" a=added?
-                             "\\([^\0]*\\)\0" ;sha1 again?
-                             "[^\0]*\0"       ;size again?
-                             "[^\0]*\0"       ;"y/n", executable again?
-                             "[^\0]*\0"       ;last revid?
-                             ;; There are more fields when merges are pending.
-                             )
-                     nil t)
-                    ;; Apparently the second sha1 is the one we want: when
-                    ;; there's a conflict, the first sha1 is absent (and the
-                    ;; first size seems to correspond to the file with
-                    ;; conflict markers).
-                    (cond
-                     ((eq (char-after (match-beginning 1)) ?a) 'removed)
-                     ((eq (char-after (match-beginning 3)) ?a) 'added)
-                     ((and (eq (string-to-number (match-string 2))
-                               (nth 7 (file-attributes file)))
-                           (equal (match-string 4)
-                                  (vc-bzr-sha1 file)))
-                      'up-to-date)
-                     (t 'edited))
-                  'unregistered)))))))))
+        (condition-case nil
+            (with-temp-buffer
+              (insert-file-contents dirstate)
+              (goto-char (point-min))
+              (if (not (looking-at "#bazaar dirstate flat format 3"))
+                  (vc-bzr-state file)   ; Some other unknown format?
+                (let* ((relfile (file-relative-name file root))
+                       (reldir (file-name-directory relfile)))
+                  (if (re-search-forward
+                       (concat "^\0"
+                               (if reldir (regexp-quote
+                                           (directory-file-name reldir)))
+                               "\0"
+                               (regexp-quote (file-name-nondirectory relfile))
+                               "\0"
+                               "[^\0]*\0"     ;id?
+                               "\\([^\0]*\\)\0" ;"a/f/d", a=removed?
+                               "[^\0]*\0" ;sha1 (empty if conflicted)?
+                               "\\([^\0]*\\)\0" ;size?
+                               "[^\0]*\0"       ;"y/n", executable?
+                               "[^\0]*\0"       ;?
+                               "\\([^\0]*\\)\0" ;"a/f/d" a=added?
+                               "\\([^\0]*\\)\0" ;sha1 again?
+                               "[^\0]*\0"       ;size again?
+                               "[^\0]*\0" ;"y/n", executable again?
+                               "[^\0]*\0" ;last revid?
+                               ;; There are more fields when merges are pending.
+                               )
+                       nil t)
+                      ;; Apparently the second sha1 is the one we want: when
+                      ;; there's a conflict, the first sha1 is absent (and the
+                      ;; first size seems to correspond to the file with
+                      ;; conflict markers).
+                      (cond
+                       ((eq (char-after (match-beginning 1)) ?a) 'removed)
+                       ((eq (char-after (match-beginning 3)) ?a) 'added)
+                       ((and (eq (string-to-number (match-string 2))
+                                 (nth 7 (file-attributes file)))
+                             (equal (match-string 4)
+                                    (vc-bzr-sha1 file)))
+                        'up-to-date)
+                       (t 'edited))
+                    'unregistered))))
+          ;; Either the dirstate file can't be read, or the sha1
+          ;; executable is missing, or ...
+          ;; In either case, recent versions of Bzr aren't that slow
+          ;; any more.
+          (error (vc-bzr-state file)))))))
+
 
 (defun vc-bzr-registered (file)
   "Return non-nil if FILE is registered with bzr."