-;; TODO: it would be nice to mark the conflicted files in VC Dired,
-;; and implement a command to run ediff and `bzr resolve' once the
-;; changes have been merged.
-(defun vc-bzr-dir-state (dir &optional localp)
- "Find the VC state of all files in DIR and its subdirectories.
-Optional argument LOCALP is always ignored."
- (let ((bzr-root-directory (vc-bzr-root dir))
- (at-start t)
- current-bzr-state current-vc-state)
- ;; Check that DIR is a bzr repository.
- (unless (file-name-absolute-p bzr-root-directory)
- (error "Cannot find bzr repository for directory `%s'" dir))
- ;; `bzr ls --versioned' lists all versioned files;
- ;; assume they are up-to-date, unless we are given
- ;; evidence of the contrary.
- (setq at-start t)
- (with-temp-buffer
- (buffer-disable-undo) ;; Because these buffers can get huge
- (vc-bzr-command "ls" t 0 nil "--versioned")
- (goto-char (point-min))
- (while (or at-start
- (eq 0 (forward-line)))
- (setq at-start nil)
- (let ((file (expand-file-name
- (buffer-substring-no-properties
- (line-beginning-position) (line-end-position))
- bzr-root-directory)))
- ;; files are up-to-date unless they appear in the `bzr
- ;; status' output below
- (vc-file-setprop file 'vc-state 'up-to-date)
- ;; Anyway, we're looking at the output of `bzr ls
- ;; --versioned', so we know these files are registered with
- ;; Bzr.
- (vc-file-setprop file 'vc-backend 'Bzr))))
- ;; `bzr status' reports on added/modified/renamed and unknown/ignored files
- (setq at-start t)
- (with-temp-buffer
- (vc-bzr-command "status" t 0 nil)
- (goto-char (point-min))
- (while (or at-start
- (eq 0 (forward-line)))
- (setq at-start nil)
- (cond
- ((looking-at "^added")
- (setq current-vc-state 'added)
- (setq current-bzr-state 'added))
- ((looking-at "^kind changed")
- (setq current-vc-state 'edited)
- (setq current-bzr-state 'kindchanged))
- ((looking-at "^modified")
- (setq current-vc-state 'edited)
- (setq current-bzr-state 'modified))
- ((looking-at "^renamed")
- (setq current-vc-state 'edited)
- (setq current-bzr-state 'renamed))
- ((looking-at "^ignored")
- (setq current-vc-state 'ignored)
- (setq current-bzr-state 'not-versioned))
- ((looking-at "^unknown")
- (setq current-vc-state 'unregistered)
- (setq current-bzr-state 'not-versioned))
- ((looking-at " ")
- ;; file names are indented by two spaces
- (when current-vc-state
- (let ((file (expand-file-name
- (buffer-substring-no-properties
- (match-end 0) (line-end-position))
- bzr-root-directory)))
- (vc-file-setprop file 'vc-state current-vc-state)
- (vc-file-setprop file 'vc-bzr-state current-bzr-state)
- (when (eq 'added current-bzr-state)
- (vc-file-setprop file 'vc-working-revision "0"))))
- (when (eq 'not-versioned current-bzr-state)
- (let ((file (expand-file-name
- (buffer-substring-no-properties
- (match-end 0) (line-end-position))
- bzr-root-directory)))
- (vc-file-setprop file 'vc-backend 'none)
- (vc-file-setprop file 'vc-state nil))))
- (t
- ;; skip this part of `bzr status' output
- (setq current-vc-state nil)
- (setq current-bzr-state nil)))))))
-
-(defun vc-bzr-prettify-state-info (file)
- "Bzr-specific version of `vc-prettify-state-info'."
- (if (eq 'edited (vc-state file))
- (concat "(" (symbol-name (or (vc-file-getprop file 'vc-bzr-state)
- 'edited)) ")")
- ;; else fall back to default vc.el representation
- (vc-default-prettify-state-info 'Bzr file)))
-
-;; XXX: this needs testing, it's probably incomplete.
+(defstruct (vc-bzr-extra-fileinfo
+ (:copier nil)
+ (:constructor vc-bzr-create-extra-fileinfo (extra-name))
+ (:conc-name vc-bzr-extra-fileinfo->))
+ extra-name) ;; original name for rename targets, new name for
+
+(defun vc-bzr-dir-printer (info)
+ "Pretty-printer for the vc-dir-fileinfo structure."
+ (let ((extra (vc-dir-fileinfo->extra info)))
+ (vc-default-dir-printer 'Bzr info)
+ (when extra
+ (insert (propertize
+ (format " (renamed from %s)"
+ (vc-bzr-extra-fileinfo->extra-name extra))
+ 'face 'font-lock-comment-face)))))
+
+;; FIXME: this needs testing, it's probably incomplete.