annotate lisp/vc-bzr.el @ 81408:c5c3c338808a

(USE_MAC_TOOLBAR): New define.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Thu, 14 Jun 2007 08:39:07 +0000
parents a5186dc625d4
children 774e9d2142bd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
81307
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 ;;; vc-bzr.el --- VC backend for the bzr revision control system
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
3 ;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
4
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
5 ;; NOTE: THIS IS A MODIFIED VERSION OF Dave Love's vc-bzr.el,
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6 ;; which you can find at: http://www.loveshack.ukfsn.org/emacs/vc-bzr.el
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
7 ;; I could not get in touch with Dave Love by email, so
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
8 ;; I am releasing my changes separately. -- Riccardo
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
9
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
10 ;; Author: Dave Love <fx@gnu.org>, Riccardo Murri <riccardo.murri@gmail.com>
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
11 ;; Keywords: tools
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
12 ;; Created: Sept 2006
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
13 ;; Version: 2007-01-17
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
14 ;; URL: http://launchpad.net/vc-bzr
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
15
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
16 ;; This file is free software; you can redistribute it and/or modify
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
17 ;; it under the terms of the GNU General Public License as published by
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
18 ;; the Free Software Foundation; either version 2, or (at your option)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
19 ;; any later version.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
20
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
21 ;; This file is distributed in the hope that it will be useful,
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
24 ;; GNU General Public License for more details.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
25
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
26 ;; You should have received a copy of the GNU General Public License
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
27 ;; along with GNU Emacs; see the file COPYING. If not, write to the
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
28 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
29 ;; Boston, MA 02110-1301, USA.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32 ;;; Commentary:
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
33
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34 ;; NOTE: THIS IS A MODIFIED VERSION OF Dave Love's vc-bzr.el,
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35 ;; which you can find at: http://www.loveshack.ukfsn.org/emacs/vc-bzr.el
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37 ;; See <URL:http://bazaar-vcs.org/> concerning bzr.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39 ;; Load this library to register bzr support in VC. The support is
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 ;; preliminary and incomplete, adapted from my darcs version. Lightly
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41 ;; exercised with bzr 0.8 and Emacs 21, and bzr 0.11 on Emacs 22. See
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 ;; various Fixmes below.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
43
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 ;; This should be suitable for direct inclusion in Emacs if someone
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45 ;; can persuade rms.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48 ;;; Code:
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 (eval-when-compile
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51 (require 'vc)) ; for vc-exec-after
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 (defgroup vc-bzr nil
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54 "VC bzr backend."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55 ;; :version "22"
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 :group 'vc)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 (defcustom vc-bzr-program "bzr"
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 "*Name of the bzr command (excluding any arguments)."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 :group 'vc-bzr
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 :type 'string)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 ;; Fixme: there's probably no call for this.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64 (defcustom vc-bzr-program-args nil
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 "*List of global arguments to pass to `vc-bzr-program'."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 :group 'vc-bzr
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67 :type '(repeat string))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69 (defcustom vc-bzr-diff-switches nil
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70 "*String/list of strings specifying extra switches for bzr diff under VC."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71 :type '(choice (const :tag "None" nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72 (string :tag "Argument String")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
73 (repeat :tag "Argument List" :value ("") string))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
74 :group 'vc-bzr)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76 (defvar vc-bzr-version nil
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 "Internal use.")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
78
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
79 ;; Could be used for compatibility checks if bzr changes.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
80 (defun vc-bzr-version ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
81 "Return a three-numeric element list with components of the bzr version.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
82 This is of the form (X Y Z) for revision X.Y.Z. The elements are zero
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83 if running `vc-bzr-program' doesn't produce the expected output."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
84 (if vc-bzr-version
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
85 vc-bzr-version
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86 (let ((s (shell-command-to-string
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87 (concat (shell-quote-argument vc-bzr-program) " --version"))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
88 (if (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)$" s)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89 (setq vc-bzr-version (list (string-to-number (match-string 1 s))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 (string-to-number (match-string 2 s))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
91 (string-to-number (match-string 3 s))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 '(0 0 0)))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
93
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
94 (defun vc-bzr-at-least-version (vers)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
95 "Return t if the bzr command reports being a least version VERS.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
96 First argument VERS is a list of the form (X Y Z), as returned by `vc-bzr-version'."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
97 (version-list-<= vers (vc-bzr-version)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
98
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
99 ;; XXX: vc-do-command is tailored for RCS and assumes that command-line
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
100 ;; options precede the file name (ci -something file); with bzr, we need
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
101 ; to pass options *after* the subcommand, e.g. bzr ls --versioned.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
102 (defun vc-bzr-do-command* (buffer okstatus command &rest args)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
103 "Execute bzr COMMAND, notifying user and checking for errors.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
104 This is a wrapper around `vc-do-command', which see for detailed
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
105 explanation of arguments BUFFER, OKSTATUS and COMMAND.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
106
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
107 If the optional list of ARGS is present, its elements are
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
108 appended to the command line, in the order given.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
109
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
110 Unlike `vc-do-command', this has no way of telling which elements
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
111 in ARGS are file names and which are command-line options, so be
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
112 sure to pass absolute file names if needed. On the other hand,
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
113 you can mix options and file names in any order."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
114 (apply 'vc-do-command buffer okstatus command nil args))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
115
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
116 (cond
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
117 ((vc-bzr-at-least-version '(0 9))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
118 ;; since v0.9, bzr supports removing the progress indicators
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
119 ;; by setting environment variable BZR_PROGRESS_BAR to "none".
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
120 (defun vc-bzr-command (bzr-command buffer okstatus file &rest args)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
121 "Wrapper round `vc-do-command' using `vc-bzr-program' as COMMAND.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
122 Invoke the bzr command adding `BZR_PROGRESS_BAR=none' to the environment."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
123 (let ((process-environment (cons "BZR_PROGRESS_BAR=none" process-environment)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
124 (apply 'vc-do-command buffer okstatus vc-bzr-program
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
125 file bzr-command (append vc-bzr-program-args args))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
126
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
127 (defun vc-bzr-command* (bzr-command buffer okstatus file &rest args)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
128 "Wrapper round `vc-bzr-do-command*' using `vc-bzr-program' as COMMAND.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
129 Invoke the bzr command adding `BZR_PROGRESS_BAR=none' to the environment.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
130 First argument BZR-COMMAND is passed as the first optional argument to
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
131 `vc-bzr-do-command*'."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
132 (let ((process-environment (cons "BZR_PROGRESS_BAR=none" process-environment)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
133 (apply 'vc-bzr-do-command* buffer okstatus vc-bzr-program
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
134 bzr-command (append vc-bzr-program-args args)))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
135
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
136 (t
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
137 ;; for older versions, we fall back to washing the log buffer
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
138 ;; when all output has been gathered.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
139 (defun vc-bzr-command (command buffer okstatus file &rest args)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
140 "Wrapper round `vc-do-command' using `vc-bzr-program' as COMMAND."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
141 ;; Note: The ^Ms from the progress-indicator stuff that bzr prints
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
142 ;; on stderr cause auto-detection of a mac coding system on the
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
143 ;; stream for async output. bzr ought to be fixed to be able to
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
144 ;; suppress this. See also `vc-bzr-post-command-function'. (We
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
145 ;; can't sink the stderr output in `vc-do-command'.)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
146 (apply 'vc-do-command buffer okstatus vc-bzr-program
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
147 file command (append vc-bzr-program-args args)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
148
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
149 (defun vc-bzr-command* (command buffer okstatus &rest args)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
150 "Wrapper round `vc-bzr-do-command*' using `vc-bzr-program' as COMMAND."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
151 (apply 'vc-bzr-do-command* buffer okstatus vc-bzr-program
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
152 command file (append vc-bzr-program-args args)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
153
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
154 (defun vc-bzr-post-command-function (command file flags)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
155 "`vc-post-command-functions' function to remove progress messages."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
156 ;; Note that using this requires that the vc command is run
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
157 ;; synchronously. Otherwise, the ^Ms in the leading progress
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
158 ;; message on stdout cause the stream to be interpreted as having
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
159 ;; DOS line endings, losing the ^Ms, so the search fails. I don't
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
160 ;; know how this works under Windows.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
161 (when (equal command vc-bzr-program)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
162 (save-excursion
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
163 (goto-char (point-min))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
164 (if (looking-at "^\\(\r.*\r\\)[^\r]+$")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
165 (replace-match "" nil nil nil 1)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
166 (save-excursion
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
167 (goto-char (point-min))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
168 ;; This is inserted by bzr 0.11 `log', at least
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
169 (while (looking-at "read knit.*\n")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
170 (replace-match "")))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
171
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
172 (add-hook 'vc-post-command-functions 'vc-bzr-post-command-function)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
173
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
174 ;; Fixme: If we're only interested in status messages, we only need
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
175 ;; to set LC_MESSAGES, and we might need finer control of this. This
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
176 ;; is moot anyhow, since bzr doesn't appear to be localized at all
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
177 ;; (yet?).
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
178 (eval-when-compile
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
179 (defmacro vc-bzr-with-c-locale (&rest body)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
180 "Run BODY with LC_ALL=C in the process environment.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
181 This ensures that messages to be matched come out as expected."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
182 `(let ((process-environment (cons "LC_ALL=C" process-environment)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
183 ,@body)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
184 (put 'vc-bzr-with-c-locale 'edebug-form-spec t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
185 (put 'vc-bzr-with-c-locale 'lisp-indent-function 0)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
186
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
187 (defun vc-bzr-bzr-dir (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
188 "Return the .bzr directory in the hierarchy above FILE.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
189 Return nil if there isn't one."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
190 (setq file (expand-file-name file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
191 (let ((dir (if (file-directory-p file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
192 file
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
193 (file-name-directory file)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
194 bzr)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
195 (catch 'found
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
196 (while t
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
197 (setq bzr (expand-file-name ".bzr" dir)) ; fixme: "_bzr" on Doze??
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
198 (if (file-directory-p bzr)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
199 (throw 'found (file-name-as-directory bzr)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
200 (if (equal "" (file-name-nondirectory (directory-file-name dir)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
201 (throw 'found nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
202 (setq dir (file-name-directory (directory-file-name dir))))))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
203
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
204 (defun vc-bzr-registered (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
205 "Return non-nil if FILE is registered with bzr."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
206 (if (vc-bzr-bzr-dir file) ; short cut
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
207 (vc-bzr-state file))) ; expensive
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
208
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
209 (defun vc-bzr-state (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
210 (let (ret state conflicts pending-merges)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
211 (with-temp-buffer
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
212 (cd (file-name-directory file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
213 (setq ret (vc-bzr-with-c-locale (vc-bzr-command "status" t 255 file)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
214 (goto-char 1)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
215 (save-excursion
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
216 (when (re-search-forward "^conflicts:" nil t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
217 (message "Warning -- conflicts in bzr branch")))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
218 (save-excursion
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
219 (when (re-search-forward "^pending merges:" nil t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
220 (message "Warning -- pending merges in bzr branch")))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
221 (setq state
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
222 (cond ((not (equal ret 0)) nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
223 ((looking-at "added\\|renamed\\|modified\\|removed") 'edited)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
224 ;; Fixme: Also get this in a non-registered sub-directory.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
225 ((looking-at "^$") 'up-to-date)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
226 ;; if we're seeing this as first line of text,
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
227 ;; then the status is up-to-date,
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
228 ;; but bzr output only gives the warning to users.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
229 ((looking-at "conflicts\\|pending") 'up-to-date)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
230 ((looking-at "unknown\\|ignored") nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
231 (t (error "Unrecognized output from `bzr status'"))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
232 (when (or conflicts pending-merges)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
233 (message
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
234 (concat "Warning -- "
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
235 (if conflicts "conflicts ")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
236 (if (and conflicts pending-merges) "and ")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
237 (if pending-merges "pending merges ")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
238 "in bzr branch")))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
239 (when state
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
240 (vc-file-setprop file 'vc-workfile-version
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
241 (vc-bzr-workfile-version file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
242 (vc-file-setprop file 'vc-state state))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
243 state)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
244
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
245 (defun vc-bzr-workfile-unchanged-p (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
246 (eq 'up-to-date (vc-bzr-state file)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
247
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
248 (defun vc-bzr-workfile-version (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
249 (with-temp-buffer
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
250 (vc-bzr-command "revno" t 0 file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
251 (goto-char 1)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
252 (buffer-substring 1 (line-end-position))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
253
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
254 (defun vc-bzr-checkout-model (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
255 'implicit)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
256
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
257 (defun vc-bzr-register (file &optional rev comment)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
258 "Register FILE under bzr.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
259 Signal an error unless REV is nil.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
260 COMMENT is ignored."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
261 (if rev (error "Can't register explicit version with bzr"))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
262 (vc-bzr-command "add" nil 0 file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
263
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
264 ;; Could run `bzr status' in the directory and see if it succeeds, but
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
265 ;; that's relatively expensive.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
266 (defun vc-bzr-responsible-p (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
267 "Return non-nil if FILE is (potentially) controlled by bzr.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
268 The criterion is that there is a `.bzr' directory in the same
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
269 or a superior directory."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
270 (vc-bzr-bzr-dir file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
271
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
272 (defun vc-bzr-could-register (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
273 "Return non-nil if FILE could be registered under bzr."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
274 (and (vc-bzr-responsible-p file) ; shortcut
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
275 (condition-case ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
276 (with-temp-buffer
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
277 (vc-bzr-command "add" t 0 file "--dry-run")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
278 ;; The command succeeds with no output if file is
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
279 ;; registered (in bzr 0.8).
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
280 (goto-char 1)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
281 (looking-at "added "))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
282 (error))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
283
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
284 (defun vc-bzr-unregister (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
285 "Unregister FILE from bzr."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
286 (vc-bzr-command "remove" nil 0 file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
287
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
288 (defun vc-bzr-checkin (file rev comment)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
289 "Check FILE in to bzr with log message COMMENT.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
290 REV non-nil gets an error."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
291 (if rev (error "Can't check in a specific version with bzr"))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
292 (vc-bzr-command "commit" nil 0 file "-m" comment))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
293
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
294 (defun vc-bzr-checkout (file &optional editable rev destfile)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
295 "Checkout revision REV of FILE from bzr to DESTFILE.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
296 EDITABLE is ignored."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
297 (unless destfile
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
298 (setq destfile (vc-version-backup-file-name file rev)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
299 (let ((coding-system-for-read 'binary)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
300 (coding-system-for-write 'binary))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
301 (with-temp-file destfile
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
302 (if rev
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
303 (vc-bzr-command "cat" t 0 file "-r" rev)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
304 (vc-bzr-command "cat" t 0 file)))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
305
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
306 (defun vc-bzr-revert (file &optional contents-done)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
307 (unless contents-done
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
308 (with-temp-buffer (vc-bzr-command "revert" t 'async file))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
309
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
310 (eval-when-compile
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
311 (defvar log-view-message-re)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
312 (defvar log-view-file-re)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
313 (defvar log-view-font-lock-keywords)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
314 (defvar log-view-current-tag-function))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
315
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
316 ;; Grim hack to account for lack of an extension mechanism for
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
317 ;; log-view. Should be fixed in VC...
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
318 (defun vc-bzr-view-log-function ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
319 "To be added to `log-view-mode-hook' to set variables for bzr output.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
320 Removes itself after running."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
321 (remove-hook 'log-view-mode-hook 'vc-bzr-view-log-function)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
322 (require 'add-log)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
323 ;; Don't have file markers, so use impossible regexp.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
324 (set (make-local-variable 'log-view-file-re) "\\'\\`")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
325 (set (make-local-variable 'log-view-message-re) "^ *-+\n *\\(revno: [0-9]+\\|merged: .+\\)")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
326 (set (make-local-variable 'log-view-font-lock-keywords)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
327 `(("^ *committer: \
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
328 \\([^<(]+?\\)[ ]*[(<]\\([A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\\)[>)]"
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
329 nil nil
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
330 (1 'change-log-name-face nil t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
331 (2 'change-log-email-face nil t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
332 (3 'change-log-email-face nil t))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
333 ("^ *timestamp: \\(.*\\)" (1 'change-log-date-face))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
334 (,log-view-message-re . 'log-view-message-face)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
335 ;; ("^ \\(.*\\)$" (1 'log-view-message-face))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
336 )))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
337
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
338 (defun vc-bzr-print-log (file &optional buffer) ; get buffer arg in Emacs 22
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
339 "Get bzr change log for FILE into specified BUFFER."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
340 ;; Fixme: VC needs a hook to sort out the mode for the buffer, or at
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
341 ;; least set the regexps right.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
342 ;; Fixme: This might need the locale fixing up if things like `revno'
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
343 ;; got localized, but certainly it shouldn't use LC_ALL=C.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
344 ;; NB. Can't be async -- see `vc-bzr-post-command-function'.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
345 (vc-bzr-command "log" buffer 0 file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
346 (add-hook 'log-view-mode-hook 'vc-bzr-view-log-function))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
347
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
348 (defun vc-bzr-show-log-entry (version)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
349 "Find entry for patch name VERSION in bzr change log buffer."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
350 (goto-char (point-min))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
351 (let (case-fold-search)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
352 (if (re-search-forward (concat "^-+\nrevno: " version "$") nil t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
353 (beginning-of-line 0)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
354 (goto-char (point-min)))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
355
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
356 ;; Fixem: vc-bzr-wash-log
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
357
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
358 (autoload 'vc-diff-switches-list "vc" nil nil t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
359
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
360 (defun vc-bzr-diff (file &optional rev1 rev2 buffer)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
361 "VC bzr backend for diff."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
362 (let ((working (vc-workfile-version file)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
363 (if (and (equal rev1 working) (not rev2))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
364 (setq rev1 nil))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
365 (if (and (not rev1) rev2)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
366 (setq rev1 working))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
367 ;; NB. Can't be async -- see `vc-bzr-post-command-function'.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
368 ;; bzr diff produces condition code 1 for some reason.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
369 (apply #'vc-bzr-command "diff" (or buffer "*vc-diff*") 1 file
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
370 "--diff-options" (mapconcat 'identity (vc-diff-switches-list bzr)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
371 " ")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
372 (when rev1
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
373 (if rev2
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
374 (list "-r" (format "%s..%s" rev1 rev2))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
375 (list "-r" rev1))))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
376
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
377 (defalias 'vc-bzr-diff-tree 'vc-bzr-diff)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
378
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
379 ;; Fixme: implement vc-bzr-dir-state, vc-bzr-dired-state-info
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
380
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
381 ;; Fixme: vc-{next,previous}-version need fixing in vc.el to deal with
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
382 ;; straight integer versions.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
383
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
384 (defun vc-bzr-delete-file (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
385 "Delete FILE and delete it in the bzr repository."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
386 (condition-case ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
387 (delete-file file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
388 (file-error nil))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
389 (vc-bzr-command "remove" nil 0 file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
390
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
391 (defun vc-bzr-rename-file (old new)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
392 "Rename file from OLD to NEW using `bzr mv'."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
393 (vc-bzr-command "mv" nil 0 new old))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
394
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
395 (defvar vc-bzr-annotation-table nil
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
396 "Internal use.")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
397 (make-variable-buffer-local 'vc-bzr-annotation-table)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
398
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
399 (defun vc-bzr-annotate-command (file buffer &optional version)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
400 "Prepare BUFFER for `vc-annotate' on FILE.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
401 Each line is tagged with the revision number, which has a `help-echo'
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
402 property containing author and date information."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
403 (apply #'vc-bzr-command "annotate" buffer 0 file "-l" "--all"
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
404 (if version (list "-r" version)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
405 (with-current-buffer buffer
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
406 ;; Store the tags for the annotated source lines in a hash table
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
407 ;; to allow saving space by sharing the text properties.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
408 (setq vc-bzr-annotation-table (make-hash-table :test 'equal))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
409 (goto-char (point-min))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
410 (while (re-search-forward "^\\( *[0-9]+\\) \\(.+\\) +\\([0-9]\\{8\\}\\) |"
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
411 nil t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
412 (let* ((rev (match-string 1))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
413 (author (match-string 2))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
414 (date (match-string 3))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
415 (key (match-string 0))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
416 (tag (gethash key vc-bzr-annotation-table)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
417 (unless tag
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
418 (save-match-data
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
419 (string-match " +\\'" author)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
420 (setq author (substring author 0 (match-beginning 0))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
421 (setq tag (propertize rev 'help-echo (concat "Author: " author
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
422 ", date: " date)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
423 'mouse-face 'highlight))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
424 (puthash key tag vc-bzr-annotation-table))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
425 (replace-match "")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
426 (insert tag " |")))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
427
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
428 ;; Definition from Emacs 22
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
429 (unless (fboundp 'vc-annotate-convert-time)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
430 (defun vc-annotate-convert-time (time)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
431 "Convert a time value to a floating-point number of days.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
432 The argument TIME is a list as returned by `current-time' or
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
433 `encode-time', only the first two elements of that list are considered."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
434 (/ (+ (* (float (car time)) (lsh 1 16)) (cadr time)) 24 3600)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
435
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
436 (defun vc-bzr-annotate-time ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
437 (when (re-search-forward "^ *[0-9]+ |" nil t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
438 (let ((prop (get-text-property (line-beginning-position) 'help-echo)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
439 (string-match "[0-9]+\\'" prop)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
440 (vc-annotate-convert-time
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
441 (encode-time 0 0 0
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
442 (string-to-number (substring (match-string 0 prop) 6 8))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
443 (string-to-number (substring (match-string 0 prop) 4 6))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
444 (string-to-number (substring (match-string 0 prop) 0 4))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
445 )))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
446
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
447 (defun vc-bzr-annotate-extract-revision-at-line ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
448 "Return revision for current line of annoation buffer, or nil.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
449 Return nil if current line isn't annotated."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
450 (save-excursion
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
451 (beginning-of-line)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
452 (if (looking-at " *\\([0-9]+\\) | ")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
453 (match-string-no-properties 1))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
454
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
455 ;; Not needed for Emacs 22
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
456 (defun vc-bzr-annotate-difference (point)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
457 (let ((next-time (vc-bzr-annotate-time)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
458 (if next-time
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
459 (- (vc-annotate-convert-time (current-time)) next-time))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
460
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
461 ;; FIXME: `bzr root' will return the real path to the repository root,
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
462 ;; that is, it can differ from the buffer's current directory name
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
463 ;; if there are any symbolic links.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
464 (defun vc-bzr-root (dir)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
465 "Return the root directory of the bzr repository containing DIR."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
466 (substring
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
467 (shell-command-to-string (concat vc-bzr-program " root " dir)) 0 -1))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
468
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
469 ;; TODO: it would be nice to mark the conflicted files in VC Dired,
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
470 ;; and implement a command to run ediff and `bzr resolve' once the
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
471 ;; changes have been merged.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
472 (defun vc-bzr-dir-state (dir &optional localp)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
473 "Find the VC state of all files in DIR.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
474 Optional argument LOCALP is always ignored."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
475 (let (at-start bzr-root-directory current-bzr-state current-vc-state)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
476 ;; check that DIR is a bzr repository
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
477 (set 'bzr-root-directory (vc-bzr-root dir))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
478 (unless (string-match "^/" bzr-root-directory)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
479 (error "Cannot find bzr repository for directory `%s'" dir))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
480 ;; `bzr ls --versioned' lists all versioned files;
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
481 ;; assume they are up-to-date, unless we are given
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
482 ;; evidence of the contrary.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
483 (set 'at-start t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
484 (with-temp-buffer
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
485 (vc-bzr-command* "ls" t 0 "--versioned" "--non-recursive")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
486 (goto-char (point-min))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
487 (while (or at-start
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
488 (eq 0 (forward-line)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
489 (set 'at-start nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
490 (let ((file (expand-file-name
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
491 (buffer-substring-no-properties
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
492 (line-beginning-position) (line-end-position))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
493 bzr-root-directory)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
494 (vc-file-setprop file 'vc-state 'up-to-date)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
495 ;; XXX: is this correct? what happens if one
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
496 ;; mixes different SCMs in the same dir?
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
497 (vc-file-setprop file 'vc-backend 'BZR))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
498 ;; `bzr status' reports on added/modified/renamed and unknown/ignored files
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
499 (set 'at-start t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
500 (with-temp-buffer
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
501 (vc-bzr-with-c-locale (vc-bzr-command "status" t 0 nil))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
502 (goto-char (point-min))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
503 (while (or at-start
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
504 (eq 0 (forward-line)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
505 (set 'at-start nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
506 (cond
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
507 ((looking-at "^added")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
508 (set 'current-vc-state 'edited)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
509 (set 'current-bzr-state 'added))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
510 ((looking-at "^modified")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
511 (set 'current-vc-state 'edited)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
512 (set 'current-bzr-state 'modified))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
513 ((looking-at "^renamed")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
514 (set 'current-vc-state 'edited)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
515 (set 'current-bzr-state 'renamed))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
516 ((looking-at "^\\(unknown\\|ignored\\)")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
517 (set 'current-vc-state nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
518 (set 'current-bzr-state 'not-versioned))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
519 ((looking-at " ")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
520 ;; file names are indented by two spaces
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
521 (when current-vc-state
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
522 (let ((file (expand-file-name
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
523 (buffer-substring-no-properties
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
524 (match-end 0) (line-end-position))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
525 bzr-root-directory)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
526 (vc-file-setprop file 'vc-state current-vc-state)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
527 (vc-file-setprop file 'vc-bzr-state current-bzr-state)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
528 (when (eq 'added current-bzr-state)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
529 (vc-file-setprop file 'vc-workfile-version "0"))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
530 (when (eq 'not-versioned current-bzr-state)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
531 (let ((file (expand-file-name
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
532 (buffer-substring-no-properties
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
533 (match-end 0) (line-end-position))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
534 bzr-root-directory)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
535 (vc-file-setprop file 'vc-backend 'none)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
536 (vc-file-setprop file 'vc-state nil))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
537 (t
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
538 ;; skip this part of `bzr status' output
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
539 (set 'current-vc-state nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
540 (set 'current-bzr-state nil)))))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
541
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
542 (defun vc-bzr-dired-state-info (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
543 "Bzr-specific version of `vc-dired-state-info'."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
544 (if (eq 'edited (vc-state file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
545 (let ((bzr-state (vc-file-getprop file 'vc-bzr-state)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
546 (if bzr-state
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
547 (concat "(" (symbol-name bzr-state) ")")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
548 ;; else fall back to default vc representation
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
549 (vc-default-dired-state-info 'BZR file)))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
550
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
551 ;; In case of just `(load "vc-bzr")', but that's probably the wrong
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
552 ;; way to do it.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
553 (add-to-list 'vc-handled-backends 'BZR)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
554
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
555 (eval-after-load "vc"
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
556 '(add-to-list 'vc-directory-exclusion-list ".bzr" t))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
557
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
558 (defconst vc-bzr-unload-hook
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
559 (lambda ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
560 (setq vc-handled-backends (delq 'BZR vc-handled-backends))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
561 (remove-hook 'vc-post-command-functions 'vc-bzr-post-command-function)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
562
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
563 (provide 'vc-bzr)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
564 ;; arch-tag: 8101bad8-4e92-4e7d-85ae-d8e08b4e7c06
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
565 ;;; vc-bzr.el ends here