(frame.o, keyboard.o, xdisp.o, xfaces.o): Depend on macgui.h.
[emacs.git] / lisp / vc-bzr.el
blobc689d70deef1f8d64848f97e3206455128f8f202
1 ;;; vc-bzr.el --- VC backend for the bzr revision control system
3 ;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
5 ;; Author: Dave Love <fx@gnu.org>, Riccardo Murri <riccardo.murri@gmail.com>
6 ;; Keywords: tools
7 ;; Created: Sept 2006
8 ;; Version: 2008-01-04 (Bzr revno 25)
9 ;; URL: http://launchpad.net/vc-bzr
11 ;; This file is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; any later version.
16 ;; This file is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
27 ;;; Commentary:
29 ;; See <URL:http://bazaar-vcs.org/> concerning bzr. See
30 ;; <URL:http://launchpad.net/vc-bzr> for alternate development
31 ;; branches of `vc-bzr'.
33 ;; Load this library to register bzr support in VC.
35 ;; Known bugs
36 ;; ==========
38 ;; When edititing a symlink and *both* the symlink and its target
39 ;; are bzr-versioned, `vc-bzr` presently runs `bzr status` on the
40 ;; symlink, thereby not detecting whether the actual contents
41 ;; (that is, the target contents) are changed.
42 ;; See https://bugs.launchpad.net/vc-bzr/+bug/116607
44 ;; For an up-to-date list of bugs, please see:
45 ;; https://bugs.launchpad.net/vc-bzr/+bugs
48 ;;; Code:
50 (eval-when-compile
51 (require 'cl)
52 (require 'vc)) ; for vc-exec-after
54 ;; Clear up the cache to force vc-call to check again and discover
55 ;; new functions when we reload this file.
56 (put 'Bzr 'vc-functions nil)
58 (defgroup vc-bzr nil
59 "VC bzr backend."
60 :version "22.2"
61 :group 'vc)
63 (defcustom vc-bzr-program "bzr"
64 "Name of the bzr command (excluding any arguments)."
65 :group 'vc-bzr
66 :type 'string)
68 (defcustom vc-bzr-diff-switches nil
69 "String/list of strings specifying extra switches for bzr diff under VC."
70 :type '(choice (const :tag "None" nil)
71 (string :tag "Argument String")
72 (repeat :tag "Argument List" :value ("") string))
73 :group 'vc-bzr)
75 (defcustom vc-bzr-log-switches nil
76 "String/list of strings specifying extra switches for `bzr log' under VC."
77 :type '(choice (const :tag "None" nil)
78 (string :tag "Argument String")
79 (repeat :tag "Argument List" :value ("") string))
80 :group 'vc-bzr)
82 ;; since v0.9, bzr supports removing the progress indicators
83 ;; by setting environment variable BZR_PROGRESS_BAR to "none".
84 (defun vc-bzr-command (bzr-command buffer okstatus file-or-list &rest args)
85 "Wrapper round `vc-do-command' using `vc-bzr-program' as COMMAND.
86 Invoke the bzr command adding `BZR_PROGRESS_BAR=none' and
87 `LC_MESSAGES=C' to the environment."
88 (let ((process-environment
89 (list* "BZR_PROGRESS_BAR=none" ; Suppress progress output (bzr >=0.9)
90 "LC_MESSAGES=C" ; Force English output
91 process-environment)))
92 (apply 'vc-do-command buffer okstatus vc-bzr-program
93 file-or-list bzr-command args)))
95 ;;;###autoload
96 (defconst vc-bzr-admin-dirname ".bzr"
97 "Name of the directory containing Bzr repository status files.")
98 ;;;###autoload
99 (defconst vc-bzr-admin-checkout-format-file
100 (concat vc-bzr-admin-dirname "/checkout/format"))
101 (defconst vc-bzr-admin-dirstate
102 (concat vc-bzr-admin-dirname "/checkout/dirstate"))
103 (defconst vc-bzr-admin-branch-format-file
104 (concat vc-bzr-admin-dirname "/branch/format"))
105 (defconst vc-bzr-admin-revhistory
106 (concat vc-bzr-admin-dirname "/branch/revision-history"))
107 (defconst vc-bzr-admin-lastrev
108 (concat vc-bzr-admin-dirname "/branch/last-revision"))
110 ;;;###autoload (defun vc-bzr-registered (file)
111 ;;;###autoload (if (vc-find-root file vc-bzr-admin-checkout-format-file)
112 ;;;###autoload (progn
113 ;;;###autoload (load "vc-bzr")
114 ;;;###autoload (vc-bzr-registered file))))
116 (defun vc-bzr-root (file)
117 "Return the root directory of the bzr repository containing FILE."
118 ;; Cache technique copied from vc-arch.el.
119 (or (vc-file-getprop file 'bzr-root)
120 (vc-file-setprop
121 file 'bzr-root
122 (vc-find-root file vc-bzr-admin-checkout-format-file))))
124 (defun vc-bzr-registered (file)
125 "Return non-nil if FILE is registered with bzr.
127 For speed, this function tries first to parse Bzr internal file
128 `checkout/dirstate', but it may fail if Bzr internal file format
129 has changed. As a safeguard, the `checkout/dirstate' file is
130 only parsed if it contains the string `#bazaar dirstate flat
131 format 3' in the first line.
133 If the `checkout/dirstate' file cannot be parsed, fall back to
134 running `vc-bzr-state'."
135 (lexical-let ((root (vc-bzr-root file)))
136 (when root ; Short cut.
137 ;; This looks at internal files. May break if they change
138 ;; their format.
139 (lexical-let ((dirstate (expand-file-name vc-bzr-admin-dirstate root)))
140 (if (not (file-readable-p dirstate))
141 (vc-bzr-state file) ; Expensive.
142 (with-temp-buffer
143 (insert-file-contents dirstate)
144 (goto-char (point-min))
145 (if (not (looking-at "#bazaar dirstate flat format 3"))
146 (vc-bzr-state file) ; Some other unknown format?
147 (let* ((relfile (file-relative-name file root))
148 (reldir (file-name-directory relfile)))
149 (when (re-search-forward
150 (concat "^\0"
151 (if reldir (regexp-quote
152 (directory-file-name reldir)))
153 "\0"
154 (regexp-quote (file-name-nondirectory relfile))
155 "\0")
156 nil t)
157 ;; Make sure `bzr' agrees that this file is under Bzr's
158 ;; control. This is important because if `bzr' is not
159 ;; installed vc-find-file may otherwise get an error in
160 ;; the subsequent call to `vc-state'.
161 (vc-bzr-state file))))))))))
163 (defconst vc-bzr-state-words
164 "added\\|ignored\\|kind changed\\|modified\\|removed\\|renamed\\|unknown"
165 "Regexp matching file status words as reported in `bzr' output.")
167 (defun vc-bzr-file-name-relative (filename)
168 "Return file name FILENAME stripped of the initial Bzr repository path."
169 (lexical-let*
170 ((filename* (expand-file-name filename))
171 (rootdir (vc-bzr-root filename*)))
172 (when rootdir
173 (file-relative-name filename* rootdir))))
175 (defun vc-bzr-status (file)
176 "Return FILE status according to Bzr.
177 Return value is a cons (STATUS . WARNING), where WARNING is a
178 string or nil, and STATUS is one of the symbols: `added',
179 `ignored', `kindchanged', `modified', `removed', `renamed', `unknown',
180 which directly correspond to `bzr status' output, or 'unchanged
181 for files whose copy in the working tree is identical to the one
182 in the branch repository, or nil for files that are not
183 registered with Bzr.
185 If any error occurred in running `bzr status', then return nil."
186 (with-temp-buffer
187 (let ((ret (condition-case nil
188 (vc-bzr-command "status" t 0 file)
189 (file-error nil))) ; vc-bzr-program not found.
190 (status 'unchanged))
191 ;; the only secure status indication in `bzr status' output
192 ;; is a couple of lines following the pattern::
193 ;; | <status>:
194 ;; | <file name>
195 ;; if the file is up-to-date, we get no status report from `bzr',
196 ;; so if the regexp search for the above pattern fails, we consider
197 ;; the file to be up-to-date.
198 (goto-char (point-min))
199 (when (re-search-forward
200 ;; bzr prints paths relative to the repository root.
201 (concat "^\\(" vc-bzr-state-words "\\):[ \t\n]+"
202 (regexp-quote (vc-bzr-file-name-relative file))
203 ;; Bzr appends a '/' to directory names and
204 ;; '*' to executable files
205 (if (file-directory-p file) "/?" "\\*?")
206 "[ \t\n]*$")
207 nil t)
208 (lexical-let ((statusword (match-string 1)))
209 ;; Erase the status text that matched.
210 (delete-region (match-beginning 0) (match-end 0))
211 (setq status
212 (intern (replace-regexp-in-string " " "" statusword)))))
213 (when status
214 (goto-char (point-min))
215 (skip-chars-forward " \n\t") ;Throw away spaces.
216 (cons status
217 ;; "bzr" will output warnings and informational messages to
218 ;; stderr; due to Emacs' `vc-do-command' (and, it seems,
219 ;; `start-process' itself) limitations, we cannot catch stderr
220 ;; and stdout into different buffers. So, if there's anything
221 ;; left in the buffer after removing the above status
222 ;; keywords, let us just presume that any other message from
223 ;; "bzr" is a user warning, and display it.
224 (unless (eobp) (buffer-substring (point) (point-max))))))))
226 (defun vc-bzr-state (file)
227 (lexical-let ((result (vc-bzr-status file)))
228 (when (consp result)
229 (if (cdr result)
230 (message "Warnings in `bzr' output: %s" (cdr result)))
231 (cdr (assq (car result)
232 '((added . edited)
233 (kindchanged . edited)
234 (renamed . edited)
235 (modified . edited)
236 (removed . edited)
237 (ignored . nil)
238 (unknown . nil)
239 (unchanged . up-to-date)))))))
241 (defun vc-bzr-workfile-unchanged-p (file)
242 (eq 'unchanged (car (vc-bzr-status file))))
244 (defun vc-bzr-workfile-version (file)
245 (lexical-let*
246 ((rootdir (vc-bzr-root file))
247 (branch-format-file (expand-file-name vc-bzr-admin-branch-format-file
248 rootdir))
249 (revhistory-file (expand-file-name vc-bzr-admin-revhistory rootdir))
250 (lastrev-file (expand-file-name vc-bzr-admin-lastrev rootdir)))
251 ;; This looks at internal files to avoid forking a bzr process.
252 ;; May break if they change their format.
253 (if (file-exists-p branch-format-file)
254 (with-temp-buffer
255 (insert-file-contents branch-format-file)
256 (goto-char (point-min))
257 (cond
258 ((or
259 (looking-at "Bazaar-NG branch, format 0.0.4")
260 (looking-at "Bazaar-NG branch format 5"))
261 ;; count lines in .bzr/branch/revision-history
262 (insert-file-contents revhistory-file)
263 (number-to-string (count-lines (line-end-position) (point-max))))
264 ((looking-at "Bazaar Branch Format 6 (bzr 0.15)")
265 ;; revno is the first number in .bzr/branch/last-revision
266 (insert-file-contents lastrev-file)
267 (if (re-search-forward "[0-9]+" nil t)
268 (buffer-substring (match-beginning 0) (match-end 0))))))
269 ;; fallback to calling "bzr revno"
270 (lexical-let*
271 ((result (vc-bzr-command-discarding-stderr
272 vc-bzr-program "revno" file))
273 (exitcode (car result))
274 (output (cdr result)))
275 (cond
276 ((eq exitcode 0) (substring output 0 -1))
277 (t nil))))))
279 (defun vc-bzr-checkout-model (file)
280 'implicit)
282 (defun vc-bzr-create-repo ()
283 "Create a new Bzr repository."
284 (vc-bzr-command "init" nil 0 nil))
286 (defun vc-bzr-init-version (&optional file)
287 "Always return nil, as Bzr cannot register explicit versions."
288 nil)
290 (defun vc-bzr-register (files &optional rev comment)
291 "Register FILE under bzr.
292 Signal an error unless REV is nil.
293 COMMENT is ignored."
294 (if rev (error "Can't register explicit version with bzr"))
295 (vc-bzr-command "add" nil 0 files))
297 ;; Could run `bzr status' in the directory and see if it succeeds, but
298 ;; that's relatively expensive.
299 (defalias 'vc-bzr-responsible-p 'vc-bzr-root
300 "Return non-nil if FILE is (potentially) controlled by bzr.
301 The criterion is that there is a `.bzr' directory in the same
302 or a superior directory.")
304 (defun vc-bzr-could-register (file)
305 "Return non-nil if FILE could be registered under bzr."
306 (and (vc-bzr-responsible-p file) ; shortcut
307 (condition-case ()
308 (with-temp-buffer
309 (vc-bzr-command "add" t 0 file "--dry-run")
310 ;; The command succeeds with no output if file is
311 ;; registered (in bzr 0.8).
312 (goto-char (point-min))
313 (looking-at "added "))
314 (error))))
316 (defun vc-bzr-unregister (file)
317 "Unregister FILE from bzr."
318 (vc-bzr-command "remove" nil 0 file "--keep"))
320 (defun vc-bzr-checkin (files rev comment)
321 "Check FILE in to bzr with log message COMMENT.
322 REV non-nil gets an error."
323 (if rev (error "Can't check in a specific version with bzr"))
324 (vc-bzr-command "commit" nil 0 files "-m" comment))
326 (defun vc-bzr-find-version (file rev buffer)
327 "Fetch version REV of file FILE and put it into BUFFER."
328 (with-current-buffer buffer
329 (if (and rev (stringp rev) (not (string= rev "")))
330 (vc-bzr-command "cat" t 0 file "-r" rev)
331 (vc-bzr-command "cat" t 0 file))))
333 (defun vc-bzr-checkout (file &optional editable rev destfile)
334 "Checkout revision REV of FILE from bzr to DESTFILE.
335 EDITABLE is ignored."
336 (unless destfile
337 (setq destfile (vc-version-backup-file-name file rev)))
338 (let ((coding-system-for-read 'binary)
339 (coding-system-for-write 'binary))
340 (with-temp-file destfile
341 (if (and rev (stringp rev) (not (string= rev "")))
342 (vc-bzr-command "cat" t 0 file "-r" rev)
343 (vc-bzr-command "cat" t 0 file)))))
345 (defun vc-bzr-revert (file &optional contents-done)
346 (unless contents-done
347 (with-temp-buffer (vc-bzr-command "revert" t 0 file))))
349 (defvar log-view-message-re)
350 (defvar log-view-file-re)
351 (defvar log-view-font-lock-keywords)
352 (defvar log-view-current-tag-function)
354 (define-derived-mode vc-bzr-log-view-mode log-view-mode "Bzr-Log-View"
355 (remove-hook 'log-view-mode-hook 'vc-bzr-log-view-mode) ;Deactivate the hack.
356 (require 'add-log)
357 (set (make-local-variable 'log-view-file-re) "^Working file:[ \t]+\\(.+\\)")
358 (set (make-local-variable 'log-view-message-re)
359 "^ *-+\n *\\(?:revno: \\([0-9.]+\\)\\|merged: .+\\)")
360 (set (make-local-variable 'log-view-font-lock-keywords)
361 ;; log-view-font-lock-keywords is careful to use the buffer-local
362 ;; value of log-view-message-re only since Emacs-23.
363 (append `((,log-view-message-re . 'log-view-message-face))
364 ;; log-view-font-lock-keywords
365 '(("^ *committer: \
366 \\([^<(]+?\\)[ ]*[(<]\\([[:alnum:]_.+-]+@[[:alnum:]_.-]+\\)[>)]"
367 (1 'change-log-name)
368 (2 'change-log-email))
369 ("^ *timestamp: \\(.*\\)" (1 'change-log-date-face))))))
371 (defun vc-bzr-print-log (files &optional buffer) ; get buffer arg in Emacs 22
372 "Get bzr change log for FILES into specified BUFFER."
373 ;; `vc-do-command' creates the buffer, but we need it before running
374 ;; the command.
375 (vc-setup-buffer buffer)
376 ;; If the buffer exists from a previous invocation it might be
377 ;; read-only.
378 (let ((inhibit-read-only t)
379 ;; Support both the old print-log interface that passes a
380 ;; single file, and the new one that passes a file list.
381 (flist (if (listp files) files (list files))))
382 ;; FIXME: `vc-bzr-command' runs `bzr log' with `LC_MESSAGES=C', so
383 ;; the log display may not what the user wants - but I see no other
384 ;; way of getting the above regexps working.
385 ;; "bzr log" (as of bzr-1.1) can only take a single file argument.
386 ;; Loop through the file list.
387 (dolist (file flist)
388 (with-current-buffer buffer
389 ;; Insert the file name so that log-view.el can find it.
390 (insert "Working file: " file "\n")) ;; Like RCS/CVS.
391 (apply 'vc-bzr-command "log" buffer 0 file
392 (if (stringp vc-bzr-log-switches)
393 (list vc-bzr-log-switches)
394 vc-bzr-log-switches))))
395 ;; FIXME: Until Emacs-23, VC was missing a hook to sort out the mode for
396 ;; the buffer, or at least set the regexps right.
397 (unless (fboundp 'vc-default-log-view-mode)
398 (add-hook 'log-view-mode-hook 'vc-bzr-log-view-mode)))
400 (defun vc-bzr-show-log-entry (version)
401 "Find entry for patch name VERSION in bzr change log buffer."
402 (goto-char (point-min))
403 (let (case-fold-search)
404 (if (re-search-forward
405 ;; "revno:" can appear either at the beginning of a line, or indented.
406 (concat "^[ ]*-+\n[ ]*revno: "
407 ;; The revision can contain ".", quote it so that it
408 ;; does not interfere with regexp matching.
409 (regexp-quote version) "$") nil t)
410 (beginning-of-line 0)
411 (goto-char (point-min)))))
413 (autoload 'vc-diff-switches-list "vc" nil nil t)
415 (defun vc-bzr-diff (files &optional rev1 rev2 buffer)
416 "VC bzr backend for diff."
417 ;; `bzr diff' exits with code 1 if diff is non-empty
418 (apply #'vc-bzr-command "diff" (or buffer "*vc-diff*") 1 files
419 "--diff-options" (mapconcat 'identity
420 (vc-diff-switches-list bzr)
421 " ")
422 (list "-r" (format "%s..%s"
423 (or rev1 "revno:-1")
424 (or rev2 "")))))
426 (defalias 'vc-bzr-diff-tree 'vc-bzr-diff)
429 ;; FIXME: vc-{next,previous}-version need fixing in vc.el to deal with
430 ;; straight integer versions.
432 (defun vc-bzr-delete-file (file)
433 "Delete FILE and delete it in the bzr repository."
434 (condition-case ()
435 (delete-file file)
436 (file-error nil))
437 (vc-bzr-command "remove" nil 0 file))
439 (defun vc-bzr-rename-file (old new)
440 "Rename file from OLD to NEW using `bzr mv'."
441 (vc-bzr-command "mv" nil 0 new old))
443 (defvar vc-bzr-annotation-table nil
444 "Internal use.")
445 (make-variable-buffer-local 'vc-bzr-annotation-table)
447 (defun vc-bzr-annotate-command (file buffer &optional version)
448 "Prepare BUFFER for `vc-annotate' on FILE.
449 Each line is tagged with the revision number, which has a `help-echo'
450 property containing author and date information."
451 (apply #'vc-bzr-command "annotate" buffer 0 file "--long" "--all"
452 (if version (list "-r" version)))
453 (with-current-buffer buffer
454 ;; Store the tags for the annotated source lines in a hash table
455 ;; to allow saving space by sharing the text properties.
456 (setq vc-bzr-annotation-table (make-hash-table :test 'equal))
457 (goto-char (point-min))
458 (while (re-search-forward "^\\( *[0-9.]+ *\\) \\([^\n ]+\\) +\\([0-9]\\{8\\}\\) |"
459 nil t)
460 (let* ((rev (match-string 1))
461 (author (match-string 2))
462 (date (match-string 3))
463 (key (match-string 0))
464 (tag (gethash key vc-bzr-annotation-table)))
465 (unless tag
466 (setq tag (propertize rev 'help-echo (concat "Author: " author
467 ", date: " date)
468 'mouse-face 'highlight))
469 (puthash key tag vc-bzr-annotation-table))
470 (replace-match "")
471 (insert tag " |")))))
473 (defun vc-bzr-annotate-time ()
474 (when (re-search-forward "^ *[0-9.]+ +|" nil t)
475 (let ((prop (get-text-property (line-beginning-position) 'help-echo)))
476 (string-match "[0-9]+\\'" prop)
477 (vc-annotate-convert-time
478 (encode-time 0 0 0
479 (string-to-number (substring (match-string 0 prop) 6 8))
480 (string-to-number (substring (match-string 0 prop) 4 6))
481 (string-to-number (substring (match-string 0 prop) 0 4))
482 )))))
484 (defun vc-bzr-annotate-extract-revision-at-line ()
485 "Return revision for current line of annoation buffer, or nil.
486 Return nil if current line isn't annotated."
487 (save-excursion
488 (beginning-of-line)
489 (if (looking-at " *\\([0-9.]+\\) | ")
490 (match-string-no-properties 1))))
492 (defun vc-bzr-command-discarding-stderr (command &rest args)
493 "Execute shell command COMMAND (with ARGS); return its output and exitcode.
494 Return value is a cons (EXITCODE . OUTPUT), where EXITCODE is
495 the (numerical) exit code of the process, and OUTPUT is a string
496 containing whatever the process sent to its standard output
497 stream. Standard error output is discarded."
498 (with-temp-buffer
499 (cons
500 (apply #'call-process command nil (list (current-buffer) nil) nil args)
501 (buffer-substring (point-min) (point-max)))))
503 ;; TODO: it would be nice to mark the conflicted files in VC Dired,
504 ;; and implement a command to run ediff and `bzr resolve' once the
505 ;; changes have been merged.
506 (defun vc-bzr-dir-state (dir &optional localp)
507 "Find the VC state of all files in DIR.
508 Optional argument LOCALP is always ignored."
509 (let ((bzr-root-directory (vc-bzr-root dir))
510 (at-start t)
511 current-bzr-state current-vc-state)
512 ;; Check that DIR is a bzr repository.
513 (unless (file-name-absolute-p bzr-root-directory)
514 (error "Cannot find bzr repository for directory `%s'" dir))
515 ;; `bzr ls --versioned' lists all versioned files;
516 ;; assume they are up-to-date, unless we are given
517 ;; evidence of the contrary.
518 (setq at-start t)
519 (with-temp-buffer
520 (vc-bzr-command "ls" t 0 nil "--versioned" "--non-recursive")
521 (goto-char (point-min))
522 (while (or at-start
523 (eq 0 (forward-line)))
524 (setq at-start nil)
525 (let ((file (expand-file-name
526 (buffer-substring-no-properties
527 (line-beginning-position) (line-end-position))
528 bzr-root-directory)))
529 ;; files are up-to-date unless they appear in the `bzr
530 ;; status' output below
531 (vc-file-setprop file 'vc-state 'up-to-date)
532 ;; XXX: is this correct? what happens if one
533 ;; mixes different SCMs in the same dir?
534 ;; Anyway, we're looking at the output of `bzr ls --versioned',
535 ;; so we know these files are registered with Bzr.
536 (vc-file-setprop file 'vc-backend 'Bzr))))
537 ;; `bzr status' reports on added/modified/renamed and unknown/ignored files
538 (setq at-start t)
539 (with-temp-buffer
540 (vc-bzr-command "status" t 0 nil)
541 (goto-char (point-min))
542 (while (or at-start
543 (eq 0 (forward-line)))
544 (setq at-start nil)
545 (cond
546 ((looking-at "^added")
547 (setq current-vc-state 'edited)
548 (setq current-bzr-state 'added))
549 ((looking-at "^kind changed")
550 (setq current-vc-state 'edited)
551 (setq current-bzr-state 'kindchanged))
552 ((looking-at "^modified")
553 (setq current-vc-state 'edited)
554 (setq current-bzr-state 'modified))
555 ((looking-at "^renamed")
556 (setq current-vc-state 'edited)
557 (setq current-bzr-state 'renamed))
558 ((looking-at "^\\(unknown\\|ignored\\)")
559 (setq current-vc-state nil)
560 (setq current-bzr-state 'not-versioned))
561 ((looking-at " ")
562 ;; file names are indented by two spaces
563 (when current-vc-state
564 (let ((file (expand-file-name
565 (buffer-substring-no-properties
566 (match-end 0) (line-end-position))
567 bzr-root-directory)))
568 (vc-file-setprop file 'vc-state current-vc-state)
569 (vc-file-setprop file 'vc-bzr-state current-bzr-state)
570 (when (eq 'added current-bzr-state)
571 (vc-file-setprop file 'vc-workfile-version "0"))))
572 (when (eq 'not-versioned current-bzr-state)
573 (let ((file (expand-file-name
574 (buffer-substring-no-properties
575 (match-end 0) (line-end-position))
576 bzr-root-directory)))
577 (vc-file-setprop file 'vc-backend 'none)
578 (vc-file-setprop file 'vc-state nil))))
580 ;; skip this part of `bzr status' output
581 (setq current-vc-state nil)
582 (setq current-bzr-state nil)))))))
584 (defun vc-bzr-dired-state-info (file)
585 "Bzr-specific version of `vc-dired-state-info'."
586 (if (eq 'edited (vc-state file))
587 (concat "(" (symbol-name (or (vc-file-getprop file 'vc-bzr-state)
588 'edited)) ")")
589 ;; else fall back to default vc.el representation
590 (vc-default-dired-state-info 'Bzr file)))
592 (eval-after-load "vc"
593 '(add-to-list 'vc-directory-exclusion-list vc-bzr-admin-dirname t))
595 (provide 'vc-bzr)
596 ;; arch-tag: 8101bad8-4e92-4e7d-85ae-d8e08b4e7c06
597 ;;; vc-bzr.el ends here