]> code.delx.au - gnu-emacs/blobdiff - lisp/vc-bzr.el
(completion-setup-function):
[gnu-emacs] / lisp / vc-bzr.el
index efa9fc9ef9e325d72e5f66f16def4f613dfd0580..cafca3838917311a7c683bc7c4edbb2f4a27fa36 100644 (file)
@@ -1,8 +1,9 @@
 ;;; vc-bzr.el --- VC backend for the bzr revision control system
 
-;; Copyright (C) 2006, 2007, 2008  Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
 
-;; Author: Dave Love <fx@gnu.org>, Riccardo Murri <riccardo.murri@gmail.com>
+;; Author: Dave Love <fx@gnu.org>
+;;        Riccardo Murri <riccardo.murri@gmail.com>
 ;; Keywords: tools
 ;; Created: Sept 2006
 ;; Version: 2008-01-04 (Bzr revno 25)
   :type 'string)
 
 (defcustom vc-bzr-diff-switches nil
-  "String/list of strings specifying extra switches for bzr diff under VC."
-  :type '(choice (const :tag "None" nil)
+  "String or list of strings specifying switches for bzr diff under VC.
+If nil, use the value of `vc-diff-switches'.  If t, use no switches."
+  :type '(choice (const :tag "Unspecified" nil)
+                 (const :tag "None" t)
                  (string :tag "Argument String")
                  (repeat :tag "Argument List" :value ("") string))
   :group 'vc-bzr)
 
 (defcustom vc-bzr-log-switches nil
-  "String/list of strings specifying extra switches for `bzr log' under VC."
+  "String or list of strings specifying switches for bzr log under VC."
   :type '(choice (const :tag "None" nil)
                  (string :tag "Argument String")
                  (repeat :tag "Argument List" :value ("") string))
@@ -324,7 +327,24 @@ If any error occurred in running `bzr status', then return nil."
        (lastrev-file (expand-file-name vc-bzr-admin-lastrev rootdir)))
     ;; This looks at internal files to avoid forking a bzr process.
     ;; May break if they change their format.
-    (if (file-exists-p branch-format-file)
+    (if (and (file-exists-p branch-format-file)
+            ;; For lightweight checkouts (obtained with bzr checkout --lightweight)
+            ;; the branch-format-file does not contain the revision
+            ;; information, we need to look up the branch-format-file
+            ;; in the place where the lightweight checkout comes
+            ;; from.  We only do that if it's a local file.
+            (let ((location-fname (expand-file-name
+                                   (concat vc-bzr-admin-dirname
+                                           "/branch/location") rootdir)))
+              ;; The existence of this file is how we distinguish
+              ;; lightweight checkouts.
+              (if (file-exists-p location-fname)
+                  (with-temp-buffer
+                    (insert-file-contents location-fname)
+                    (when (re-search-forward "file://\(.+\)" nil t)
+                      (setq branch-format-file (match-string 1))
+                      (file-exists-p branch-format-file)))
+                t)))
         (with-temp-buffer
           (insert-file-contents branch-format-file)
           (goto-char (point-min))
@@ -335,11 +355,13 @@ If any error occurred in running `bzr status', then return nil."
             ;; count lines in .bzr/branch/revision-history
             (insert-file-contents revhistory-file)
             (number-to-string (count-lines (line-end-position) (point-max))))
-           ((looking-at "Bazaar Branch Format 6 (bzr 0.15)")
+           ((or
+            (looking-at "Bazaar Branch Format 6 (bzr 0.15)")
+            (looking-at "Bazaar Branch Format 7 (needs bzr 1.6)"))
             ;; revno is the first number in .bzr/branch/last-revision
             (insert-file-contents lastrev-file)
-            (if (re-search-forward "[0-9]+" nil t)
-                (buffer-substring (match-beginning 0) (match-end 0))))))
+            (when (re-search-forward "[0-9]+" nil t)
+             (buffer-substring (match-beginning 0) (match-end 0))))))
       ;; fallback to calling "bzr revno"
       (lexical-let*
           ((result (vc-bzr-command-discarding-stderr
@@ -432,7 +454,7 @@ REV non-nil gets an error."
   (set (make-local-variable 'log-view-per-file-logs) nil)
   (set (make-local-variable 'log-view-file-re) "^Working file:[ \t]+\\(.+\\)")
   (set (make-local-variable 'log-view-message-re)
-       "^ *-+\n *\\(?:revno: \\([0-9.]+\\)\\|merged: .+\\)")
+       "^ *\\(?:revno: \\([0-9.]+\\)\\|merged: .+\\)")
   (set (make-local-variable 'log-view-font-lock-keywords)
        ;; log-view-font-lock-keywords is careful to use the buffer-local
        ;; value of log-view-message-re only since Emacs-23.
@@ -614,6 +636,11 @@ stream.  Standard error output is discarded."
                       ;; For a non existent file FOO, the output is:
                       ;; bzr: ERROR: Path(s) do not exist: FOO
                       ("bzr" . not-found)
+                      ;; If the tree is not up to date, bzr will print this warning:
+                      ;; working tree is out of date, run 'bzr update'
+                      ;; ignore it.
+                      ;; FIXME: maybe this warning can be put in the vc-dir header...
+                      ("wor" . not-found)
                        ;; Ignore "P " and "P." for pending patches.
                        ))
        (translated nil)
@@ -666,16 +693,35 @@ stream.  Standard error output is discarded."
    `(vc-bzr-after-dir-status (quote ,update-function))))
 
 (defun vc-bzr-dir-extra-headers (dir)
-  (let ((str (with-temp-buffer
-              (vc-bzr-command "info" t 0 dir)
-              (buffer-string))))
+  (let*
+      ((str (with-temp-buffer
+             (vc-bzr-command "info" t 0 dir)
+             (buffer-string)))
+       (light-checkout
+       (when (string-match ".+light checkout root: \\(.+\\)$" str)
+         (match-string 1 str)))
+       (light-checkout-branch
+       (when light-checkout
+         (when (string-match ".+checkout of branch: \\(.+\\)$" str)
+           (match-string 1 str)))))
     (concat
-     (propertize "Parent branch: " 'face 'font-lock-type-face)
-     (propertize 
+     (propertize "Parent branch      : " 'face 'font-lock-type-face)
+     (propertize
       (if (string-match "parent branch: \\(.+\\)$" str)
-         (match-string 1 str)
-       "None")
-       'face 'font-lock-variable-name-face))))
+         (match-string 1 str)
+       "None")
+       'face 'font-lock-variable-name-face)
+     "\n"
+      (when light-checkout
+       (concat
+        (propertize "Light checkout root: " 'face 'font-lock-type-face)
+        (propertize light-checkout 'face 'font-lock-variable-name-face)
+        "\n"))
+      (when light-checkout-branch
+       (concat
+        (propertize "Checkout of branch : " 'face 'font-lock-type-face)
+        (propertize light-checkout-branch 'face 'font-lock-variable-name-face)
+        "\n")))))
 
 ;;; Revision completion