From 2793b89ee485a0efa4210c6263bd845064e70adb Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 17 May 2009 03:38:41 +0000 Subject: [PATCH] (vc-bzr-state-heuristic): Fallback on vc-bzr-state in case of any kind of error (e.g. when "sha1sum" is not found). --- lisp/ChangeLog | 16 +++++---- lisp/vc-bzr.el | 95 ++++++++++++++++++++++++++------------------------ 2 files changed, 60 insertions(+), 51 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e7e011147c1..e0b1739c562 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2009-05-17 Stefan Monnier + + * 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 * dired.el (dired-pop-to-buffer): Try to make this behave the @@ -434,11 +439,11 @@ 2009-04-07 Chong Yidong - * 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). @@ -446,8 +451,7 @@ 2009-04-06 Roland Winkler * 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 diff --git a/lisp/vc-bzr.el b/lisp/vc-bzr.el index cafca383891..9ad346f1e12 100644 --- a/lisp/vc-bzr.el +++ b/lisp/vc-bzr.el @@ -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." -- 2.39.5