aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/vc-bzr.el
diff options
context:
space:
mode:
authorStefan Monnier <[email protected]>2009-05-17 03:38:41 +0000
committerStefan Monnier <[email protected]>2009-05-17 03:38:41 +0000
commit2793b89ee485a0efa4210c6263bd845064e70adb (patch)
tree79dda271e952d696bb152139754dd251a84d50c3 /lisp/vc-bzr.el
parentd3b396e4e1d3b6886729fc0663e7a12cf2cde130 (diff)
(vc-bzr-state-heuristic): Fallback on vc-bzr-state in case
of any kind of error (e.g. when "sha1sum" is not found).
Diffstat (limited to 'lisp/vc-bzr.el')
-rw-r--r--lisp/vc-bzr.el95
1 files changed, 50 insertions, 45 deletions
diff --git a/lisp/vc-bzr.el b/lisp/vc-bzr.el
index cafca38389..9ad346f1e1 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."