aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2009-05-17 03:38:41 +0000
committerStefan Monnier2009-05-17 03:38:41 +0000
commit2793b89ee485a0efa4210c6263bd845064e70adb (patch)
tree79dda271e952d696bb152139754dd251a84d50c3
parentd3b396e4e1d3b6886729fc0663e7a12cf2cde130 (diff)
downloademacs-2793b89ee485a0efa4210c6263bd845064e70adb.tar.gz
emacs-2793b89ee485a0efa4210c6263bd845064e70adb.zip
(vc-bzr-state-heuristic): Fallback on vc-bzr-state in case
of any kind of error (e.g. when "sha1sum" is not found).
-rw-r--r--lisp/ChangeLog16
-rw-r--r--lisp/vc-bzr.el95
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 @@
12009-05-17 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * vc-bzr.el (vc-bzr-state-heuristic): Fallback on vc-bzr-state in case
4 of any kind of error (e.g. when "sha1sum" is not found).
5
12009-05-15 Martin Rudalics <rudalics@gmx.at> 62009-05-15 Martin Rudalics <rudalics@gmx.at>
2 7
3 * dired.el (dired-pop-to-buffer): Try to make this behave the 8 * dired.el (dired-pop-to-buffer): Try to make this behave the
@@ -434,11 +439,11 @@
434 439
4352009-04-07 Chong Yidong <cyd@stupidchicken.com> 4402009-04-07 Chong Yidong <cyd@stupidchicken.com>
436 441
437 * vc-bzr.el (vc-bzr-log-view-mode): Tweak 442 * vc-bzr.el (vc-bzr-log-view-mode):
438 log-view-message-re (Bug#2872). 443 Tweak log-view-message-re (Bug#2872).
439 444
440 * descr-text.el (describe-property-list, describe-char): Add 445 * descr-text.el (describe-property-list, describe-char):
441 follow-link properties to buttons that need them. 446 Add follow-link properties to buttons that need them.
442 447
443 * tooltip.el (tooltip-show-help-non-mode): Don't save the last 448 * tooltip.el (tooltip-show-help-non-mode): Don't save the last
444 message if it was also a help message (Bug#2895). 449 message if it was also a help message (Bug#2895).
@@ -446,8 +451,7 @@
4462009-04-06 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> 4512009-04-06 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
447 452
448 * textmodes/bibtex.el (bibtex-format-entry) 453 * textmodes/bibtex.el (bibtex-format-entry)
449 (bibtex-search-crossref): Allow OPT prefix for name of crossref 454 (bibtex-search-crossref): Allow OPT prefix for name of crossref field.
450 field.
451 455
4522009-04-06 Sam Steingold <sds@gnu.org> 4562009-04-06 Sam Steingold <sds@gnu.org>
453 457
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
143 143
144(defun vc-bzr-state-heuristic (file) 144(defun vc-bzr-state-heuristic (file)
145 "Like `vc-bzr-state' but hopefully without running Bzr." 145 "Like `vc-bzr-state' but hopefully without running Bzr."
146 ;; `bzr status' is excrutiatingly slow with large histories and 146 ;; `bzr status' was excrutiatingly slow with large histories and
147 ;; pending merges, so try to avoid using it until they fix their 147 ;; pending merges, so try to avoid using it until they fix their
148 ;; performance problems. 148 ;; performance problems.
149 ;; This function tries first to parse Bzr internal file 149 ;; This function tries first to parse Bzr internal file
@@ -158,50 +158,55 @@ Invoke the bzr command adding `BZR_PROGRESS_BAR=none' and
158 ;; This looks at internal files. May break if they change 158 ;; This looks at internal files. May break if they change
159 ;; their format. 159 ;; their format.
160 (lexical-let ((dirstate (expand-file-name vc-bzr-admin-dirstate root))) 160 (lexical-let ((dirstate (expand-file-name vc-bzr-admin-dirstate root)))
161 (if (not (file-readable-p dirstate)) 161 (condition-case nil
162 (vc-bzr-state file) ; Expensive. 162 (with-temp-buffer
163 (with-temp-buffer 163 (insert-file-contents dirstate)
164 (insert-file-contents dirstate) 164 (goto-char (point-min))
165 (goto-char (point-min)) 165 (if (not (looking-at "#bazaar dirstate flat format 3"))
166 (if (not (looking-at "#bazaar dirstate flat format 3")) 166 (vc-bzr-state file) ; Some other unknown format?
167 (vc-bzr-state file) ; Some other unknown format? 167 (let* ((relfile (file-relative-name file root))
168 (let* ((relfile (file-relative-name file root)) 168 (reldir (file-name-directory relfile)))
169 (reldir (file-name-directory relfile))) 169 (if (re-search-forward
170 (if (re-search-forward 170 (concat "^\0"
171 (concat "^\0" 171 (if reldir (regexp-quote
172 (if reldir (regexp-quote 172 (directory-file-name reldir)))
173 (directory-file-name reldir))) 173 "\0"
174 "\0" 174 (regexp-quote (file-name-nondirectory relfile))
175 (regexp-quote (file-name-nondirectory relfile)) 175 "\0"
176 "\0" 176 "[^\0]*\0" ;id?
177 "[^\0]*\0" ;id? 177 "\\([^\0]*\\)\0" ;"a/f/d", a=removed?
178 "\\([^\0]*\\)\0" ;"a/f/d", a=removed? 178 "[^\0]*\0" ;sha1 (empty if conflicted)?
179 "[^\0]*\0" ;sha1 (empty if conflicted)? 179 "\\([^\0]*\\)\0" ;size?
180 "\\([^\0]*\\)\0" ;size? 180 "[^\0]*\0" ;"y/n", executable?
181 "[^\0]*\0" ;"y/n", executable? 181 "[^\0]*\0" ;?
182 "[^\0]*\0" ;? 182 "\\([^\0]*\\)\0" ;"a/f/d" a=added?
183 "\\([^\0]*\\)\0" ;"a/f/d" a=added? 183 "\\([^\0]*\\)\0" ;sha1 again?
184 "\\([^\0]*\\)\0" ;sha1 again? 184 "[^\0]*\0" ;size again?
185 "[^\0]*\0" ;size again? 185 "[^\0]*\0" ;"y/n", executable again?
186 "[^\0]*\0" ;"y/n", executable again? 186 "[^\0]*\0" ;last revid?
187 "[^\0]*\0" ;last revid? 187 ;; There are more fields when merges are pending.
188 ;; There are more fields when merges are pending. 188 )
189 ) 189 nil t)
190 nil t) 190 ;; Apparently the second sha1 is the one we want: when
191 ;; Apparently the second sha1 is the one we want: when 191 ;; there's a conflict, the first sha1 is absent (and the
192 ;; there's a conflict, the first sha1 is absent (and the 192 ;; first size seems to correspond to the file with
193 ;; first size seems to correspond to the file with 193 ;; conflict markers).
194 ;; conflict markers). 194 (cond
195 (cond 195 ((eq (char-after (match-beginning 1)) ?a) 'removed)
196 ((eq (char-after (match-beginning 1)) ?a) 'removed) 196 ((eq (char-after (match-beginning 3)) ?a) 'added)
197 ((eq (char-after (match-beginning 3)) ?a) 'added) 197 ((and (eq (string-to-number (match-string 2))
198 ((and (eq (string-to-number (match-string 2)) 198 (nth 7 (file-attributes file)))
199 (nth 7 (file-attributes file))) 199 (equal (match-string 4)
200 (equal (match-string 4) 200 (vc-bzr-sha1 file)))
201 (vc-bzr-sha1 file))) 201 'up-to-date)
202 'up-to-date) 202 (t 'edited))
203 (t 'edited)) 203 'unregistered))))
204 'unregistered))))))))) 204 ;; Either the dirstate file can't be read, or the sha1
205 ;; executable is missing, or ...
206 ;; In either case, recent versions of Bzr aren't that slow
207 ;; any more.
208 (error (vc-bzr-state file)))))))
209
205 210
206(defun vc-bzr-registered (file) 211(defun vc-bzr-registered (file)
207 "Return non-nil if FILE is registered with bzr." 212 "Return non-nil if FILE is registered with bzr."