Function: vc-bzr-status
vc-bzr-status is a byte-compiled function defined in vc-bzr.el.gz.
Signature
(vc-bzr-status FILE)
Documentation
Return FILE status according to Bzr.
Return value is a cons (STATUS . WARNING), where WARNING is a
string or nil, and STATUS is one of the symbols: added,
ignored, kindchanged, modified, removed, renamed, unknown,
which directly correspond to bzr status output, or unchanged
for files whose copy in the working tree is identical to the one
in the branch repository (or whose status not be determined).
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc-bzr.el.gz
(defun vc-bzr-status (file)
"Return FILE status according to Bzr.
Return value is a cons (STATUS . WARNING), where WARNING is a
string or nil, and STATUS is one of the symbols: `added',
`ignored', `kindchanged', `modified', `removed', `renamed', `unknown',
which directly correspond to `bzr status' output, or `unchanged'
for files whose copy in the working tree is identical to the one
in the branch repository (or whose status not be determined)."
;; Doc used to also say the following, but AFAICS, it has never been true.
;;
;; ", or nil for files that are not registered with Bzr.
;; If any error occurred in running `bzr status', then return nil."
;;
;; Rather than returning nil in case of an error, it returns
;; (unchanged . WARNING). FIXME unchanged is not the best status to
;; return in case of error.
(with-temp-buffer
;; This is with-demoted-errors without the condition-case-unless-debug
;; annoyance, which makes it fail during ert testing.
(condition-case err (vc-bzr-command "status" t 0 file)
(error (message "Error: %S" err) nil))
(let ((status 'unchanged))
;; the only secure status indication in `bzr status' output
;; is a couple of lines following the pattern::
;; | <status>:
;; | <file name>
;; if the file is up-to-date, we get no status report from `bzr',
;; so if the regexp search for the above pattern fails, we consider
;; the file to be up-to-date.
(goto-char (point-min))
(when (re-search-forward
;; bzr prints paths relative to the repository root.
(concat "^\\(" vc-bzr-state-words "\\):[ \t\n]+"
(regexp-quote (vc-bzr-file-name-relative file))
;; Bzr appends a '/' to directory names and
;; '*' to executable files
(if (file-directory-p file) "/?" "\\*?")
"[ \t\n]*$")
nil t)
(let ((statusword (match-string 1)))
;; Erase the status text that matched.
(delete-region (match-beginning 0) (match-end 0))
(setq status
(intern (string-replace " " "" statusword)))))
(when status
(goto-char (point-min))
(skip-chars-forward " \n\t") ;Throw away spaces.
(cons status
;; "bzr" will output warnings and informational messages to
;; stderr; due to Emacs's `vc-do-command' (and, it seems,
;; `start-process' itself) limitations, we cannot catch stderr
;; and stdout into different buffers. So, if there's anything
;; left in the buffer after removing the above status
;; keywords, let us just presume that any other message from
;; "bzr" is a user warning, and display it.
(unless (eobp) (buffer-substring (point) (point-max))))))))