comparison lisp/vc-bzr.el @ 94873:66788c63a40a

(vc-bzr-sha1, vc-bzr-command-discarding-stderr) (vc-bzr-revision-completion-table): Use process-file. (vc-bzr-working-revision): Pass relative file names.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 11 May 2008 21:59:45 +0000
parents 5e64dca662f0
children e7ce20fce4c4
comparison
equal deleted inserted replaced
94872:c5a53051fe83 94873:66788c63a40a
132 (let ((prog sha1-program) 132 (let ((prog sha1-program)
133 (args nil)) 133 (args nil))
134 (when (consp prog) 134 (when (consp prog)
135 (setq args (cdr prog)) 135 (setq args (cdr prog))
136 (setq prog (car prog))) 136 (setq prog (car prog)))
137 (apply 'call-process prog file t nil args) 137 (apply 'process-file prog (file-relative-name file) t nil args)
138 (buffer-substring (point-min) (+ (point-min) 40))))) 138 (buffer-substring (point-min) (+ (point-min) 40)))))
139 139
140 (defun vc-bzr-state-heuristic (file) 140 (defun vc-bzr-state-heuristic (file)
141 "Like `vc-bzr-state' but hopefully without running Bzr." 141 "Like `vc-bzr-state' but hopefully without running Bzr."
142 ;; `bzr status' is excrutiatingly slow with large histories and 142 ;; `bzr status' is excrutiatingly slow with large histories and
340 (if (re-search-forward "[0-9]+" nil t) 340 (if (re-search-forward "[0-9]+" nil t)
341 (buffer-substring (match-beginning 0) (match-end 0)))))) 341 (buffer-substring (match-beginning 0) (match-end 0))))))
342 ;; fallback to calling "bzr revno" 342 ;; fallback to calling "bzr revno"
343 (lexical-let* 343 (lexical-let*
344 ((result (vc-bzr-command-discarding-stderr 344 ((result (vc-bzr-command-discarding-stderr
345 vc-bzr-program "revno" file)) 345 vc-bzr-program "revno" (file-relative-name file)))
346 (exitcode (car result)) 346 (exitcode (car result))
347 (output (cdr result))) 347 (output (cdr result)))
348 (cond 348 (cond
349 ((eq exitcode 0) (substring output 0 -1)) 349 ((eq exitcode 0) (substring output 0 -1))
350 (t nil)))))) 350 (t nil))))))
559 the (numerical) exit code of the process, and OUTPUT is a string 559 the (numerical) exit code of the process, and OUTPUT is a string
560 containing whatever the process sent to its standard output 560 containing whatever the process sent to its standard output
561 stream. Standard error output is discarded." 561 stream. Standard error output is discarded."
562 (with-temp-buffer 562 (with-temp-buffer
563 (cons 563 (cons
564 (apply #'call-process command nil (list (current-buffer) nil) nil args) 564 (apply #'process-file command nil (list (current-buffer) nil) nil args)
565 (buffer-substring (point-min) (point-max))))) 565 (buffer-substring (point-min) (point-max)))))
566 566
567 (defun vc-bzr-prettify-state-info (file) 567 (defun vc-bzr-prettify-state-info (file)
568 "Bzr-specific version of `vc-prettify-state-info'." 568 "Bzr-specific version of `vc-prettify-state-info'."
569 (if (eq 'edited (vc-state file)) 569 (if (eq 'edited (vc-state file))
643 (let ((prefix (substring string 0 (match-end 0))) 643 (let ((prefix (substring string 0 (match-end 0)))
644 (tag (substring string (match-end 0))) 644 (tag (substring string (match-end 0)))
645 (table nil)) 645 (table nil))
646 (with-temp-buffer 646 (with-temp-buffer
647 ;; "bzr-1.2 tags" is much faster with --show-ids. 647 ;; "bzr-1.2 tags" is much faster with --show-ids.
648 (call-process vc-bzr-program nil '(t) nil "tags" "--show-ids") 648 (process-file vc-bzr-program nil '(t) nil "tags" "--show-ids")
649 ;; The output is ambiguous, unless we assume that revids do not 649 ;; The output is ambiguous, unless we assume that revids do not
650 ;; contain spaces. 650 ;; contain spaces.
651 (goto-char (point-min)) 651 (goto-char (point-min))
652 (while (re-search-forward "^\\(.*[^ \n]\\) +[^ \n]*$" nil t) 652 (while (re-search-forward "^\\(.*[^ \n]\\) +[^ \n]*$" nil t)
653 (push (match-string-no-properties 1) table))) 653 (push (match-string-no-properties 1) table)))