aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-05-18 16:38:37 -0400
committerStefan Monnier2012-05-18 16:38:37 -0400
commit77f3b62ecae6cc1c2d2bfb26dbc4040346cbeab7 (patch)
treed718d04f59ca1aebecf3c711712ff7b569d4d9ef
parent60c4db3a60a7b7f0b835201efbd767ce12fa18d3 (diff)
downloademacs-77f3b62ecae6cc1c2d2bfb26dbc4040346cbeab7.tar.gz
emacs-77f3b62ecae6cc1c2d2bfb26dbc4040346cbeab7.zip
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic): Save match-data around sha1.
-rw-r--r--lisp/ChangeLog2
-rw-r--r--lisp/vc/vc-bzr.el161
2 files changed, 84 insertions, 79 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 58bf5a025d1..ed24a1eb176 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,7 @@
12012-05-18 Stefan Monnier <monnier@iro.umontreal.ca> 12012-05-18 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * vc/vc-bzr.el (vc-bzr-state-heuristic): Save match-data around sha1.
4
3 * textmodes/flyspell.el: Commenting style, plus code simplifications. 5 * textmodes/flyspell.el: Commenting style, plus code simplifications.
4 (flyspell-default-deplacement-commands): Don't spell check after 6 (flyspell-default-deplacement-commands): Don't spell check after
5 repeated window/frame switches (e.g. triggered by mouse-movement). 7 repeated window/frame switches (e.g. triggered by mouse-movement).
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el
index 5488e53e32f..b5488eb96a9 100644
--- a/lisp/vc/vc-bzr.el
+++ b/lisp/vc/vc-bzr.el
@@ -208,85 +208,88 @@ in the repository root directory of FILE."
208 ;; + working ( = packed_stat ) 208 ;; + working ( = packed_stat )
209 ;; parent = common ( as above ) + history ( = rev_id ) 209 ;; parent = common ( as above ) + history ( = rev_id )
210 ;; kinds = (r)elocated, (a)bsent, (d)irectory, (f)ile, (l)ink 210 ;; kinds = (r)elocated, (a)bsent, (d)irectory, (f)ile, (l)ink
211 (let ((root (vc-bzr-root file))) 211 (let* ((root (vc-bzr-root file))
212 (when root ; Short cut. 212 (dirstate (expand-file-name vc-bzr-admin-dirstate root)))
213 (let ((dirstate (expand-file-name vc-bzr-admin-dirstate root))) 213 (when root ; Short cut.
214 (condition-case nil 214 (condition-case err
215 (with-temp-buffer 215 (with-temp-buffer
216 (insert-file-contents dirstate) 216 (insert-file-contents dirstate)
217 (goto-char (point-min)) 217 (goto-char (point-min))
218 (if (not (looking-at "#bazaar dirstate flat format 3")) 218 (if (not (looking-at "#bazaar dirstate flat format 3"))
219 (vc-bzr-state file) ; Some other unknown format? 219 (vc-bzr-state file) ; Some other unknown format?
220 (let* ((relfile (file-relative-name file root)) 220 (let* ((relfile (file-relative-name file root))
221 (reldir (file-name-directory relfile))) 221 (reldir (file-name-directory relfile)))
222 (if (re-search-forward 222 (cond
223 (concat "^\0" 223 ((not
224 (if reldir (regexp-quote 224 (re-search-forward
225 (directory-file-name reldir))) 225 (concat "^\0"
226 "\0" 226 (if reldir (regexp-quote
227 (regexp-quote (file-name-nondirectory relfile)) 227 (directory-file-name reldir)))
228 "\0" 228 "\0"
229 "[^\0]*\0" ;id? 229 (regexp-quote (file-name-nondirectory relfile))
230 "\\([^\0]*\\)\0" ;"a/f/d", a=removed? 230 "\0"
231 "\\([^\0]*\\)\0" ;sha1 (empty if conflicted)? 231 "[^\0]*\0" ;id?
232 "\\([^\0]*\\)\0" ;size?p 232 "\\([^\0]*\\)\0" ;"a/f/d", a=removed?
233 ;; y/n. Whether or not the current copy 233 "\\([^\0]*\\)\0" ;sha1 (empty if conflicted)?
234 ;; was executable the last time bzr checked? 234 "\\([^\0]*\\)\0" ;size?p
235 "[^\0]*\0" 235 ;; y/n. Whether or not the current copy
236 "[^\0]*\0" ;? 236 ;; was executable the last time bzr checked?
237 ;; Parent information. Absent in a new repo. 237 "[^\0]*\0"
238 "\\(?:\\([^\0]*\\)\0" ;"a/f/d" a=added? 238 "[^\0]*\0" ;?
239 "\\([^\0]*\\)\0" ;sha1 again? 239 ;; Parent information. Absent in a new repo.
240 "\\([^\0]*\\)\0" ;size again? 240 "\\(?:\\([^\0]*\\)\0" ;"a/f/d" a=added?
241 ;; y/n. Whether or not the repo thinks 241 "\\([^\0]*\\)\0" ;sha1 again?
242 ;; the file should be executable? 242 "\\([^\0]*\\)\0" ;size again?
243 "\\([^\0]*\\)\0" 243 ;; y/n. Whether or not the repo thinks
244 "[^\0]*\0\\)?" ;last revid? 244 ;; the file should be executable?
245 ;; There are more fields when merges are pending. 245 "\\([^\0]*\\)\0"
246 ) 246 "[^\0]*\0\\)?" ;last revid?
247 nil t) 247 ;; There are more fields when merges are pending.
248 ;; Apparently the second sha1 is the one we want: when 248 )
249 ;; there's a conflict, the first sha1 is absent (and the 249 nil t))
250 ;; first size seems to correspond to the file with 250 'unregistered)
251 ;; conflict markers). 251 ;; Apparently the second sha1 is the one we want: when
252 (cond 252 ;; there's a conflict, the first sha1 is absent (and the
253 ((eq (char-after (match-beginning 1)) ?a) 'removed) 253 ;; first size seems to correspond to the file with
254 ;; If there is no parent, this must be a new repo. 254 ;; conflict markers).
255 ;; If file is in dirstate, can only be added (b#8025). 255 ((eq (char-after (match-beginning 1)) ?a) 'removed)
256 ((or (not (match-beginning 4)) 256 ;; If there is no parent, this must be a new repo.
257 (eq (char-after (match-beginning 4)) ?a)) 'added) 257 ;; If file is in dirstate, can only be added (b#8025).
258 ((or (and (eq (string-to-number (match-string 3)) 258 ((or (not (match-beginning 4))
259 (nth 7 (file-attributes file))) 259 (eq (char-after (match-beginning 4)) ?a)) 'added)
260 (equal (match-string 5) 260 ((or (and (eq (string-to-number (match-string 3))
261 (vc-bzr-sha1 file)) 261 (nth 7 (file-attributes file)))
262 ;; For a file, does the executable state match? 262 (equal (match-string 5)
263 ;; (Bug#7544) 263 (save-match-data (vc-bzr-sha1 file)))
264 (or (not 264 ;; For a file, does the executable state match?
265 (eq (char-after (match-beginning 1)) ?f)) 265 ;; (Bug#7544)
266 (let ((exe 266 (or (not
267 (memq 267 (eq (char-after (match-beginning 1)) ?f))
268 ?x 268 (let ((exe
269 (mapcar 269 (memq
270 'identity 270 ?x
271 (nth 8 (file-attributes file)))))) 271 (mapcar
272 (if (eq (char-after (match-beginning 7)) 272 'identity
273 ?y) 273 (nth 8 (file-attributes file))))))
274 exe 274 (if (eq (char-after (match-beginning 7))
275 (not exe))))) 275 ?y)
276 (and 276 exe
277 ;; It looks like for lightweight 277 (not exe)))))
278 ;; checkouts \2 is empty and we need to 278 (and
279 ;; look for size in \6. 279 ;; It looks like for lightweight
280 (eq (match-beginning 2) (match-end 2)) 280 ;; checkouts \2 is empty and we need to
281 (eq (string-to-number (match-string 6)) 281 ;; look for size in \6.
282 (nth 7 (file-attributes file))) 282 (eq (match-beginning 2) (match-end 2))
283 (equal (match-string 5) 283 (eq (string-to-number (match-string 6))
284 (vc-bzr-sha1 file)))) 284 (nth 7 (file-attributes file)))
285 'up-to-date) 285 (equal (match-string 5)
286 (t 'edited)) 286 (vc-bzr-sha1 file))))
287 'unregistered)))) 287 'up-to-date)
288 ;; The dirstate file can't be read, or some other problem. 288 (t 'edited)))))
289 (error (vc-bzr-state file))))))) 289 ;; The dirstate file can't be read, or some other problem.
290 (error
291 (message "Falling back on \"slow\" status detection (%S)" err)
292 (vc-bzr-state file))))))
290 293
291 294
292(defun vc-bzr-registered (file) 295(defun vc-bzr-registered (file)