Mercurial > emacs
comparison lisp/vc-bzr.el @ 81649:e40762570726
(vc-functions): Clear up the cache when reloading the file.
(vc-bzr-workfile-version, vc-bzr-could-register): Don't hardcode point-min == 1.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 28 Jun 2007 02:01:54 +0000 |
parents | 0c6323e48d45 |
children | 584ac4db2633 |
comparison
equal
deleted
inserted
replaced
81648:7697a0ec17f2 | 81649:e40762570726 |
---|---|
58 ;;; Code: | 58 ;;; Code: |
59 | 59 |
60 (eval-when-compile | 60 (eval-when-compile |
61 (require 'cl) | 61 (require 'cl) |
62 (require 'vc)) ; for vc-exec-after | 62 (require 'vc)) ; for vc-exec-after |
63 | |
64 ;; Clear up the cache to force vc-call to check again and discover | |
65 ;; new functions when we reload this file. | |
66 (put 'BZR 'vc-functions nil) | |
63 | 67 |
64 (defgroup vc-bzr nil | 68 (defgroup vc-bzr nil |
65 "VC bzr backend." | 69 "VC bzr backend." |
66 ;; :version "22" | 70 ;; :version "22" |
67 :group 'vc) | 71 :group 'vc) |
192 ;; if the file is up-to-date, we get no status report from `bzr', | 196 ;; if the file is up-to-date, we get no status report from `bzr', |
193 ;; so if the regexp search for the above pattern fails, we consider | 197 ;; so if the regexp search for the above pattern fails, we consider |
194 ;; the file to be up-to-date. | 198 ;; the file to be up-to-date. |
195 (goto-char (point-min)) | 199 (goto-char (point-min)) |
196 (when | 200 (when |
197 (re-search-forward | 201 (re-search-forward |
198 (concat "^\\(" vc-bzr-state-words "\\):[ \t\n]+" | 202 (concat "^\\(" vc-bzr-state-words "\\):[ \t\n]+" |
199 (file-name-nondirectory file) "[ \t\n]*$") | 203 (file-name-nondirectory file) "[ \t\n]*$") |
200 (point-max) t) | 204 (point-max) t) |
201 (let ((start (match-beginning 0)) | 205 (let ((start (match-beginning 0)) |
202 (end (match-end 0))) | 206 (end (match-end 0))) |
203 (goto-char start) | 207 (goto-char start) |
204 (setq state | 208 (setq state |
205 (cond | 209 (cond |
206 ((not (equal ret 0)) nil) | 210 ((not (equal ret 0)) nil) |
207 ((looking-at "added\\|renamed\\|modified\\|removed") 'edited) | 211 ((looking-at "added\\|renamed\\|modified\\|removed") 'edited) |
208 ((looking-at "unknown\\|ignored") nil))) | 212 ((looking-at "unknown\\|ignored") nil))) |
209 ;; erase the status text that matched | 213 ;; erase the status text that matched |
210 (delete-region start end))) | 214 (delete-region start end))) |
214 ;; it seems, `start-process' itself), we cannot catch stderr | 218 ;; it seems, `start-process' itself), we cannot catch stderr |
215 ;; and stdout into different buffers. So, if there's anything | 219 ;; and stdout into different buffers. So, if there's anything |
216 ;; left in the buffer after removing the above status | 220 ;; left in the buffer after removing the above status |
217 ;; keywords, let us just presume that any other message from | 221 ;; keywords, let us just presume that any other message from |
218 ;; "bzr" is a user warning, and display it. | 222 ;; "bzr" is a user warning, and display it. |
219 (message "Warnings in `bzr' output: %s" | 223 (message "Warnings in `bzr' output: %s" |
220 (buffer-substring (point-min) (point-max)))) | 224 (buffer-substring (point-min) (point-max)))) |
221 (when state | 225 (when state |
222 (vc-file-setprop file 'vc-workfile-version | 226 (vc-file-setprop file 'vc-workfile-version |
223 (vc-bzr-workfile-version file)) | 227 (vc-bzr-workfile-version file)) |
224 (vc-file-setprop file 'vc-state state)) | 228 (vc-file-setprop file 'vc-state state)) |
226 | 230 |
227 (defun vc-bzr-workfile-unchanged-p (file) | 231 (defun vc-bzr-workfile-unchanged-p (file) |
228 (eq 'up-to-date (vc-bzr-state file))) | 232 (eq 'up-to-date (vc-bzr-state file))) |
229 | 233 |
230 (defun vc-bzr-workfile-version (file) | 234 (defun vc-bzr-workfile-version (file) |
235 ;; Looks like this could be obtained via counting lines in | |
236 ;; .bzr/branch/revision-history. | |
231 (with-temp-buffer | 237 (with-temp-buffer |
232 (vc-bzr-command "revno" t 0 file) | 238 (vc-bzr-command "revno" t 0 file) |
233 (goto-char 1) | 239 (goto-char (point-min)) |
234 (buffer-substring 1 (line-end-position)))) | 240 (buffer-substring (point) (line-end-position)))) |
235 | 241 |
236 (defun vc-bzr-checkout-model (file) | 242 (defun vc-bzr-checkout-model (file) |
237 'implicit) | 243 'implicit) |
238 | 244 |
239 (defun vc-bzr-register (file &optional rev comment) | 245 (defun vc-bzr-register (file &optional rev comment) |
256 (condition-case () | 262 (condition-case () |
257 (with-temp-buffer | 263 (with-temp-buffer |
258 (vc-bzr-command "add" t 0 file "--dry-run") | 264 (vc-bzr-command "add" t 0 file "--dry-run") |
259 ;; The command succeeds with no output if file is | 265 ;; The command succeeds with no output if file is |
260 ;; registered (in bzr 0.8). | 266 ;; registered (in bzr 0.8). |
261 (goto-char 1) | 267 (goto-char (point-min)) |
262 (looking-at "added ")) | 268 (looking-at "added ")) |
263 (error)))) | 269 (error)))) |
264 | 270 |
265 (defun vc-bzr-unregister (file) | 271 (defun vc-bzr-unregister (file) |
266 "Unregister FILE from bzr." | 272 "Unregister FILE from bzr." |