]> code.delx.au - gnu-emacs/commitdiff
(vc-bzr-state-heuristic): Fallback on vc-bzr-state in case
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 17 May 2009 03:38:41 +0000 (03:38 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sun, 17 May 2009 03:38:41 +0000 (03:38 +0000)
of any kind of error (e.g. when "sha1sum" is not found).

lisp/ChangeLog
lisp/vc-bzr.el

index e7e011147c1e3b2584ea03309d7216b5bce6ea65..e0b1739c562e31864f4b2352ecfc3310e2be994c 100644 (file)
@@ -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
 
 2009-04-07  Chong Yidong  <cyd@stupidchicken.com>
 
-       * vc-bzr.el (vc-bzr-log-view-mode): Tweak
-       log-view-message-re (Bug#2872).
+       * 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.
+       * 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).
 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>
 
index cafca3838917311a7c683bc7c4edbb2f4a27fa36..9ad346f1e12a5ab761b9fa18d17e3c48e376bfeb 100644 (file)
@@ -143,7 +143,7 @@ Invoke the bzr command adding `BZR_PROGRESS_BAR=none' and
 
 (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 @@ Invoke the bzr command adding `BZR_PROGRESS_BAR=none' and
       ;; 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."