annotate lisp/vc-bzr.el @ 81499:2b9a3f7e51f0

*** empty log message ***
author Juanma Barranquero <lekktu@gmail.com>
date Wed, 20 Jun 2007 10:12:44 +0000
parents 92dd41bc6130
children 1214f1b9e278
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
81477
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
13 ;; Version: 2007-05-24
81307
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
81477
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
39 ;; Load this library to register bzr support in VC. It covers basic VC
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
40 ;; functionality, but was only lightly exercised with a few Emacs/bzr
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
41 ;; version combinations, namely those current on the authors' PCs.
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
42 ;; See various Fixmes below.
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
43
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
44
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
45 ;; Known bugs
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
46 ;; ==========
81307
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47
81477
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
48 ;; When edititing a symlink and *both* the symlink and its target
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
49 ;; are bzr-versioned, `vc-bzr` presently runs `bzr status` on the
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
50 ;; symlink, thereby not detecting whether the actual contents
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
51 ;; (that is, the target contents) are changed.
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
52 ;; See https://bugs.launchpad.net/vc-bzr/+bug/116607
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
53
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
54 ;; For an up-to-date list of bugs, please see:
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
55 ;; https://bugs.launchpad.net/vc-bzr/+bugs
81307
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56
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 ;;; Code:
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 (eval-when-compile
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 (require 'vc)) ; for vc-exec-after
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 (defgroup vc-bzr nil
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64 "VC bzr backend."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 ;; :version "22"
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 :group 'vc)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 (defcustom vc-bzr-program "bzr"
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69 "*Name of the bzr command (excluding any arguments)."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70 :group 'vc-bzr
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71 :type 'string)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
73 ;; Fixme: there's probably no call for this.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
74 (defcustom vc-bzr-program-args nil
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75 "*List of global arguments to pass to `vc-bzr-program'."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76 :group 'vc-bzr
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 :type '(repeat string))
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 (defcustom vc-bzr-diff-switches nil
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
80 "*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
81 :type '(choice (const :tag "None" nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
82 (string :tag "Argument String")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83 (repeat :tag "Argument List" :value ("") string))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
84 :group 'vc-bzr)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
85
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86 (defvar vc-bzr-version nil
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87 "Internal use.")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
88
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89 ;; Could be used for compatibility checks if bzr changes.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 (defun vc-bzr-version ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
91 "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
92 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
93 if running `vc-bzr-program' doesn't produce the expected output."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
94 (if vc-bzr-version
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
95 vc-bzr-version
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
96 (let ((s (shell-command-to-string
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
97 (concat (shell-quote-argument vc-bzr-program) " --version"))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
98 (if (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)$" s)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
99 (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
100 (string-to-number (match-string 2 s))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
101 (string-to-number (match-string 3 s))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
102 '(0 0 0)))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
103
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
104 (defun vc-bzr-at-least-version (vers)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
105 "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
106 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
107 (version-list-<= vers (vc-bzr-version)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
108
81477
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
109 (eval-when-compile
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
110 (defmacro vc-bzr-with-process-environment (envspec &rest body)
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
111 "Prepend the contents of ENVSPEC to `process-environment', then execute BODY."
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
112 `(let ((process-environment process-environment))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
113 (mapcar (lambda (var) (add-to-list 'process-environment var)) ,envspec)
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
114 ,@body))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
115
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
116 (defmacro vc-bzr-std-process-invocation (&rest body)
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
117 `(vc-bzr-with-process-environment
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
118 '("BZR_PROGRESS_BAR=none" ; suppress progress output (bzr >=0.9)
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
119 "LC_ALL=C") ; force English output
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
120 ;; bzr may attempt some kind of user interaction if its stdin/stdout
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
121 ;; is connected to a PTY; therefore, ask Emacs to use a pipe to
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
122 ;; communicate with it.
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
123 (let ((process-connection-type nil))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
124 ,@body))))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
125
81307
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
126 ;; XXX: vc-do-command is tailored for RCS and assumes that command-line
81477
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
127 ;; options precede the file name (e.g., "ci -something file"); with bzr,
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
128 ;; we need to pass options *after* the subcommand, e.g. "bzr ls --versioned".
81307
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
129 (defun vc-bzr-do-command* (buffer okstatus command &rest args)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
130 "Execute bzr COMMAND, notifying user and checking for errors.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
131 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
132 explanation of arguments BUFFER, OKSTATUS and COMMAND.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
133
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
134 If the optional list of ARGS is present, its elements are
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
135 appended to the command line, in the order given.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
136
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
137 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
138 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
139 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
140 you can mix options and file names in any order."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
141 (apply 'vc-do-command buffer okstatus command nil args))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
142
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
143 (cond
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
144 ((vc-bzr-at-least-version '(0 9))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
145 ;; since v0.9, bzr supports removing the progress indicators
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
146 ;; by setting environment variable BZR_PROGRESS_BAR to "none".
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
147 (defun vc-bzr-command (bzr-command buffer okstatus file &rest args)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
148 "Wrapper round `vc-do-command' using `vc-bzr-program' as COMMAND.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
149 Invoke the bzr command adding `BZR_PROGRESS_BAR=none' to the environment."
81477
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
150 (vc-bzr-std-process-invocation
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
151 (apply 'vc-do-command buffer okstatus vc-bzr-program
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
152 file bzr-command (append vc-bzr-program-args args))))
81307
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-command* (bzr-command buffer okstatus file &rest args)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
155 "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
156 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
157 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
158 `vc-bzr-do-command*'."
81477
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
159 (vc-bzr-std-process-invocation
81307
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
160 (apply 'vc-bzr-do-command* buffer okstatus vc-bzr-program
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
161 bzr-command (append vc-bzr-program-args args)))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
162
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
163 (t
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
164 ;; for older versions, we fall back to washing the log buffer
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
165 ;; when all output has been gathered.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
166 (defun vc-bzr-command (command buffer okstatus file &rest args)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
167 "Wrapper round `vc-do-command' using `vc-bzr-program' as COMMAND."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
168 ;; Note: The ^Ms from the progress-indicator stuff that bzr prints
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
169 ;; 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
170 ;; 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
171 ;; suppress this. See also `vc-bzr-post-command-function'. (We
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
172 ;; can't sink the stderr output in `vc-do-command'.)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
173 (apply 'vc-do-command buffer okstatus vc-bzr-program
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
174 file command (append vc-bzr-program-args args)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
175
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
176 (defun vc-bzr-command* (command buffer okstatus &rest args)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
177 "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
178 (apply 'vc-bzr-do-command* buffer okstatus vc-bzr-program
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
179 command file (append vc-bzr-program-args args)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
180
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
181 (defun vc-bzr-post-command-function (command file flags)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
182 "`vc-post-command-functions' function to remove progress messages."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
183 ;; Note that using this requires that the vc command is run
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
184 ;; synchronously. Otherwise, the ^Ms in the leading progress
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
185 ;; message on stdout cause the stream to be interpreted as having
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
186 ;; 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
187 ;; know how this works under Windows.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
188 (when (equal command vc-bzr-program)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
189 (save-excursion
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
190 (goto-char (point-min))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
191 (if (looking-at "^\\(\r.*\r\\)[^\r]+$")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
192 (replace-match "" nil nil nil 1)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
193 (save-excursion
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
194 (goto-char (point-min))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
195 ;; This is inserted by bzr 0.11 `log', at least
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
196 (while (looking-at "read knit.*\n")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
197 (replace-match "")))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
198
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
199 (add-hook 'vc-post-command-functions 'vc-bzr-post-command-function)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
200
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
201 (defun vc-bzr-bzr-dir (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
202 "Return the .bzr directory in the hierarchy above FILE.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
203 Return nil if there isn't one."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
204 (setq file (expand-file-name file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
205 (let ((dir (if (file-directory-p file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
206 file
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
207 (file-name-directory file)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
208 bzr)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
209 (catch 'found
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
210 (while t
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
211 (setq bzr (expand-file-name ".bzr" dir)) ; fixme: "_bzr" on Doze??
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
212 (if (file-directory-p bzr)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
213 (throw 'found (file-name-as-directory bzr)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
214 (if (equal "" (file-name-nondirectory (directory-file-name dir)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
215 (throw 'found nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
216 (setq dir (file-name-directory (directory-file-name dir))))))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
217
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
218 (defun vc-bzr-registered (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
219 "Return non-nil if FILE is registered with bzr."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
220 (if (vc-bzr-bzr-dir file) ; short cut
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
221 (vc-bzr-state file))) ; expensive
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
222
81477
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
223 (defun vc-bzr-buffer-nonblank-p (&optional buffer)
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
224 "Return non-nil if BUFFER contains any non-blank characters."
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
225 (or (> (buffer-size buffer) 0)
81307
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
226 (save-excursion
81477
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
227 (set-buffer (or buffer (current-buffer)))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
228 (goto-char (point-min))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
229 (re-search-forward "[^ \t\n]" (point-max) t))))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
230
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
231 (defconst vc-bzr-state-words
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
232 "added\\|ignored\\|modified\\|removed\\|renamed\\|unknown"
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
233 "Regexp matching file status words as reported in `bzr' output.")
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
234
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
235 ;; FIXME: Also get this in a non-registered sub-directory.
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
236 (defun vc-bzr-state (file)
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
237 (with-temp-buffer
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
238 (cd (file-name-directory file))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
239 (let ((ret (vc-bzr-command "status" t 255 file))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
240 (state 'up-to-date))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
241 ;; the only secure status indication in `bzr status' output
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
242 ;; is a couple of lines following the pattern::
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
243 ;; | <status>:
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
244 ;; | <file name>
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
245 ;; if the file is up-to-date, we get no status report from `bzr',
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
246 ;; so if the regexp search for the above pattern fails, we consider
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
247 ;; the file to be up-to-date.
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
248 (goto-char (point-min))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
249 (when
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
250 (re-search-forward
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
251 (concat "^\\(" vc-bzr-state-words "\\):[ \t\n]+"
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
252 (file-name-nondirectory file) "[ \t\n]*$")
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
253 (point-max) t)
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
254 (let ((start (match-beginning 0))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
255 (end (match-end 0)))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
256 (goto-char start)
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
257 (setq state
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
258 (cond
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
259 ((not (equal ret 0)) nil)
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
260 ((looking-at "added\\|renamed\\|modified\\|removed") 'edited)
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
261 ((looking-at "unknown\\|ignored") nil)))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
262 ;; erase the status text that matched
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
263 (delete-region start end)))
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
264 (when (vc-bzr-buffer-nonblank-p)
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
265 ;; "bzr" will output some warnings and informational messages
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
266 ;; to the user to stderr; due to Emacs' `vc-do-command' (and,
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
267 ;; it seems, `start-process' itself), we cannot catch stderr
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
268 ;; and stdout into different buffers. So, if there's anything
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
269 ;; left in the buffer after removing the above status
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
270 ;; keywords, let us just presume that any other message from
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
271 ;; "bzr" is a user warning, and display it.
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
272 (message "Warnings in `bzr' output: %s"
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
273 (buffer-substring (point-min) (point-max))))
81307
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
274 (when state
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
275 (vc-file-setprop file 'vc-workfile-version
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
276 (vc-bzr-workfile-version file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
277 (vc-file-setprop file 'vc-state state))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
278 state)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
279
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
280 (defun vc-bzr-workfile-unchanged-p (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
281 (eq 'up-to-date (vc-bzr-state file)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
282
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
283 (defun vc-bzr-workfile-version (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
284 (with-temp-buffer
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
285 (vc-bzr-command "revno" t 0 file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
286 (goto-char 1)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
287 (buffer-substring 1 (line-end-position))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
288
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
289 (defun vc-bzr-checkout-model (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
290 'implicit)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
291
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
292 (defun vc-bzr-register (file &optional rev comment)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
293 "Register FILE under bzr.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
294 Signal an error unless REV is nil.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
295 COMMENT is ignored."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
296 (if rev (error "Can't register explicit version with bzr"))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
297 (vc-bzr-command "add" nil 0 file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
298
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
299 ;; 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
300 ;; that's relatively expensive.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
301 (defun vc-bzr-responsible-p (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
302 "Return non-nil if FILE is (potentially) controlled by bzr.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
303 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
304 or a superior directory."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
305 (vc-bzr-bzr-dir file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
306
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
307 (defun vc-bzr-could-register (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
308 "Return non-nil if FILE could be registered under bzr."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
309 (and (vc-bzr-responsible-p file) ; shortcut
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
310 (condition-case ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
311 (with-temp-buffer
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
312 (vc-bzr-command "add" t 0 file "--dry-run")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
313 ;; The command succeeds with no output if file is
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
314 ;; registered (in bzr 0.8).
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
315 (goto-char 1)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
316 (looking-at "added "))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
317 (error))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
318
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
319 (defun vc-bzr-unregister (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
320 "Unregister FILE from bzr."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
321 (vc-bzr-command "remove" nil 0 file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
322
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
323 (defun vc-bzr-checkin (file rev comment)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
324 "Check FILE in to bzr with log message COMMENT.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
325 REV non-nil gets an error."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
326 (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
327 (vc-bzr-command "commit" nil 0 file "-m" comment))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
328
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
329 (defun vc-bzr-checkout (file &optional editable rev destfile)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
330 "Checkout revision REV of FILE from bzr to DESTFILE.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
331 EDITABLE is ignored."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
332 (unless destfile
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
333 (setq destfile (vc-version-backup-file-name file rev)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
334 (let ((coding-system-for-read 'binary)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
335 (coding-system-for-write 'binary))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
336 (with-temp-file destfile
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
337 (if rev
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
338 (vc-bzr-command "cat" t 0 file "-r" rev)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
339 (vc-bzr-command "cat" t 0 file)))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
340
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
341 (defun vc-bzr-revert (file &optional contents-done)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
342 (unless contents-done
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
343 (with-temp-buffer (vc-bzr-command "revert" t 'async file))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
344
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
345 (eval-when-compile
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
346 (defvar log-view-message-re)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
347 (defvar log-view-file-re)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
348 (defvar log-view-font-lock-keywords)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
349 (defvar log-view-current-tag-function))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
350
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
351 ;; Grim hack to account for lack of an extension mechanism for
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
352 ;; log-view. Should be fixed in VC...
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
353 (defun vc-bzr-view-log-function ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
354 "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
355 Removes itself after running."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
356 (remove-hook 'log-view-mode-hook 'vc-bzr-view-log-function)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
357 (require 'add-log)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
358 ;; Don't have file markers, so use impossible regexp.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
359 (set (make-local-variable 'log-view-file-re) "\\'\\`")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
360 (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
361 (set (make-local-variable 'log-view-font-lock-keywords)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
362 `(("^ *committer: \
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
363 \\([^<(]+?\\)[ ]*[(<]\\([A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\\)[>)]"
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
364 nil nil
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
365 (1 'change-log-name-face nil t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
366 (2 'change-log-email-face nil t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
367 (3 'change-log-email-face nil t))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
368 ("^ *timestamp: \\(.*\\)" (1 'change-log-date-face))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
369 (,log-view-message-re . 'log-view-message-face)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
370 ;; ("^ \\(.*\\)$" (1 'log-view-message-face))
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
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
373 (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
374 "Get bzr change log for FILE into specified BUFFER."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
375 ;; 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
376 ;; least set the regexps right.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
377 ;; 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
378 ;; got localized, but certainly it shouldn't use LC_ALL=C.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
379 ;; NB. Can't be async -- see `vc-bzr-post-command-function'.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
380 (vc-bzr-command "log" buffer 0 file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
381 (add-hook 'log-view-mode-hook 'vc-bzr-view-log-function))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
382
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
383 (defun vc-bzr-show-log-entry (version)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
384 "Find entry for patch name VERSION in bzr change log buffer."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
385 (goto-char (point-min))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
386 (let (case-fold-search)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
387 (if (re-search-forward (concat "^-+\nrevno: " version "$") nil t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
388 (beginning-of-line 0)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
389 (goto-char (point-min)))))
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 ;; Fixem: vc-bzr-wash-log
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
392
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
393 (autoload 'vc-diff-switches-list "vc" nil nil t)
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 (defun vc-bzr-diff (file &optional rev1 rev2 buffer)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
396 "VC bzr backend for diff."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
397 (let ((working (vc-workfile-version file)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
398 (if (and (equal rev1 working) (not rev2))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
399 (setq rev1 nil))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
400 (if (and (not rev1) rev2)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
401 (setq rev1 working))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
402 ;; NB. Can't be async -- see `vc-bzr-post-command-function'.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
403 ;; bzr diff produces condition code 1 for some reason.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
404 (apply #'vc-bzr-command "diff" (or buffer "*vc-diff*") 1 file
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
405 "--diff-options" (mapconcat 'identity (vc-diff-switches-list bzr)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
406 " ")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
407 (when rev1
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
408 (if rev2
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
409 (list "-r" (format "%s..%s" rev1 rev2))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
410 (list "-r" rev1))))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
411
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
412 (defalias 'vc-bzr-diff-tree 'vc-bzr-diff)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
413
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
414 ;; Fixme: implement vc-bzr-dir-state, vc-bzr-dired-state-info
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
415
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
416 ;; 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
417 ;; straight integer versions.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
418
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
419 (defun vc-bzr-delete-file (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
420 "Delete FILE and delete it in the bzr repository."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
421 (condition-case ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
422 (delete-file file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
423 (file-error nil))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
424 (vc-bzr-command "remove" nil 0 file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
425
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
426 (defun vc-bzr-rename-file (old new)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
427 "Rename file from OLD to NEW using `bzr mv'."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
428 (vc-bzr-command "mv" nil 0 new old))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
429
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
430 (defvar vc-bzr-annotation-table nil
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
431 "Internal use.")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
432 (make-variable-buffer-local 'vc-bzr-annotation-table)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
433
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
434 (defun vc-bzr-annotate-command (file buffer &optional version)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
435 "Prepare BUFFER for `vc-annotate' on FILE.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
436 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
437 property containing author and date information."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
438 (apply #'vc-bzr-command "annotate" buffer 0 file "-l" "--all"
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
439 (if version (list "-r" version)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
440 (with-current-buffer buffer
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
441 ;; 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
442 ;; to allow saving space by sharing the text properties.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
443 (setq vc-bzr-annotation-table (make-hash-table :test 'equal))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
444 (goto-char (point-min))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
445 (while (re-search-forward "^\\( *[0-9]+\\) \\(.+\\) +\\([0-9]\\{8\\}\\) |"
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
446 nil t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
447 (let* ((rev (match-string 1))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
448 (author (match-string 2))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
449 (date (match-string 3))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
450 (key (match-string 0))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
451 (tag (gethash key vc-bzr-annotation-table)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
452 (unless tag
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
453 (save-match-data
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
454 (string-match " +\\'" author)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
455 (setq author (substring author 0 (match-beginning 0))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
456 (setq tag (propertize rev 'help-echo (concat "Author: " author
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
457 ", date: " date)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
458 'mouse-face 'highlight))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
459 (puthash key tag vc-bzr-annotation-table))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
460 (replace-match "")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
461 (insert tag " |")))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
462
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
463 ;; Definition from Emacs 22
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
464 (unless (fboundp 'vc-annotate-convert-time)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
465 (defun vc-annotate-convert-time (time)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
466 "Convert a time value to a floating-point number of days.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
467 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
468 `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
469 (/ (+ (* (float (car time)) (lsh 1 16)) (cadr time)) 24 3600)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
470
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
471 (defun vc-bzr-annotate-time ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
472 (when (re-search-forward "^ *[0-9]+ |" nil t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
473 (let ((prop (get-text-property (line-beginning-position) 'help-echo)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
474 (string-match "[0-9]+\\'" prop)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
475 (vc-annotate-convert-time
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
476 (encode-time 0 0 0
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
477 (string-to-number (substring (match-string 0 prop) 6 8))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
478 (string-to-number (substring (match-string 0 prop) 4 6))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
479 (string-to-number (substring (match-string 0 prop) 0 4))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
480 )))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
481
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
482 (defun vc-bzr-annotate-extract-revision-at-line ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
483 "Return revision for current line of annoation buffer, or nil.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
484 Return nil if current line isn't annotated."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
485 (save-excursion
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
486 (beginning-of-line)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
487 (if (looking-at " *\\([0-9]+\\) | ")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
488 (match-string-no-properties 1))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
489
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
490 ;; Not needed for Emacs 22
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
491 (defun vc-bzr-annotate-difference (point)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
492 (let ((next-time (vc-bzr-annotate-time)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
493 (if next-time
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
494 (- (vc-annotate-convert-time (current-time)) next-time))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
495
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
496 ;; 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
497 ;; 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
498 ;; if there are any symbolic links.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
499 (defun vc-bzr-root (dir)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
500 "Return the root directory of the bzr repository containing DIR."
81446
774e9d2142bd * vc-bzr.el (vc-bzr-root): Cache the output of shell command execution.
Masatake YAMATO <jet@gyve.org>
parents: 81307
diff changeset
501 ;; Cache technique copied from vc-arch.el.
774e9d2142bd * vc-bzr.el (vc-bzr-root): Cache the output of shell command execution.
Masatake YAMATO <jet@gyve.org>
parents: 81307
diff changeset
502 (or (vc-file-getprop dir 'bzr-root)
774e9d2142bd * vc-bzr.el (vc-bzr-root): Cache the output of shell command execution.
Masatake YAMATO <jet@gyve.org>
parents: 81307
diff changeset
503 (vc-file-setprop
774e9d2142bd * vc-bzr.el (vc-bzr-root): Cache the output of shell command execution.
Masatake YAMATO <jet@gyve.org>
parents: 81307
diff changeset
504 dir 'bzr-root
774e9d2142bd * vc-bzr.el (vc-bzr-root): Cache the output of shell command execution.
Masatake YAMATO <jet@gyve.org>
parents: 81307
diff changeset
505 (substring
774e9d2142bd * vc-bzr.el (vc-bzr-root): Cache the output of shell command execution.
Masatake YAMATO <jet@gyve.org>
parents: 81307
diff changeset
506 (shell-command-to-string (concat vc-bzr-program " root " dir)) 0 -1))))
81307
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
507
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
508 ;; 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
509 ;; 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
510 ;; changes have been merged.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
511 (defun vc-bzr-dir-state (dir &optional localp)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
512 "Find the VC state of all files in DIR.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
513 Optional argument LOCALP is always ignored."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
514 (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
515 ;; check that DIR is a bzr repository
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
516 (set 'bzr-root-directory (vc-bzr-root dir))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
517 (unless (string-match "^/" bzr-root-directory)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
518 (error "Cannot find bzr repository for directory `%s'" dir))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
519 ;; `bzr ls --versioned' lists all versioned files;
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
520 ;; assume they are up-to-date, unless we are given
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
521 ;; evidence of the contrary.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
522 (set 'at-start t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
523 (with-temp-buffer
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
524 (vc-bzr-command* "ls" t 0 "--versioned" "--non-recursive")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
525 (goto-char (point-min))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
526 (while (or at-start
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
527 (eq 0 (forward-line)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
528 (set 'at-start nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
529 (let ((file (expand-file-name
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
530 (buffer-substring-no-properties
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
531 (line-beginning-position) (line-end-position))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
532 bzr-root-directory)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
533 (vc-file-setprop file 'vc-state 'up-to-date)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
534 ;; XXX: is this correct? what happens if one
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
535 ;; mixes different SCMs in the same dir?
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
536 (vc-file-setprop file 'vc-backend 'BZR))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
537 ;; `bzr status' reports on added/modified/renamed and unknown/ignored files
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
538 (set 'at-start t)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
539 (with-temp-buffer
81477
92dd41bc6130 (vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81446
diff changeset
540 (vc-bzr-command "status" t 0 nil)
81307
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
541 (goto-char (point-min))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
542 (while (or at-start
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
543 (eq 0 (forward-line)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
544 (set 'at-start nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
545 (cond
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
546 ((looking-at "^added")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
547 (set 'current-vc-state 'edited)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
548 (set 'current-bzr-state 'added))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
549 ((looking-at "^modified")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
550 (set 'current-vc-state 'edited)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
551 (set 'current-bzr-state 'modified))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
552 ((looking-at "^renamed")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
553 (set 'current-vc-state 'edited)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
554 (set 'current-bzr-state 'renamed))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
555 ((looking-at "^\\(unknown\\|ignored\\)")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
556 (set 'current-vc-state nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
557 (set 'current-bzr-state 'not-versioned))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
558 ((looking-at " ")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
559 ;; file names are indented by two spaces
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
560 (when current-vc-state
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
561 (let ((file (expand-file-name
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
562 (buffer-substring-no-properties
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
563 (match-end 0) (line-end-position))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
564 bzr-root-directory)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
565 (vc-file-setprop file 'vc-state current-vc-state)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
566 (vc-file-setprop file 'vc-bzr-state current-bzr-state)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
567 (when (eq 'added current-bzr-state)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
568 (vc-file-setprop file 'vc-workfile-version "0"))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
569 (when (eq 'not-versioned current-bzr-state)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
570 (let ((file (expand-file-name
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
571 (buffer-substring-no-properties
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
572 (match-end 0) (line-end-position))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
573 bzr-root-directory)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
574 (vc-file-setprop file 'vc-backend 'none)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
575 (vc-file-setprop file 'vc-state nil))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
576 (t
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
577 ;; skip this part of `bzr status' output
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
578 (set 'current-vc-state nil)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
579 (set 'current-bzr-state nil)))))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
580
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
581 (defun vc-bzr-dired-state-info (file)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
582 "Bzr-specific version of `vc-dired-state-info'."
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
583 (if (eq 'edited (vc-state file))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
584 (let ((bzr-state (vc-file-getprop file 'vc-bzr-state)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
585 (if bzr-state
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
586 (concat "(" (symbol-name bzr-state) ")")
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
587 ;; else fall back to default vc representation
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
588 (vc-default-dired-state-info 'BZR file)))))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
589
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
590 ;; 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
591 ;; way to do it.
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
592 (add-to-list 'vc-handled-backends 'BZR)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
593
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
594 (eval-after-load "vc"
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
595 '(add-to-list 'vc-directory-exclusion-list ".bzr" t))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
596
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
597 (defconst vc-bzr-unload-hook
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
598 (lambda ()
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
599 (setq vc-handled-backends (delq 'BZR vc-handled-backends))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
600 (remove-hook 'vc-post-command-functions 'vc-bzr-post-command-function)))
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
601
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
602 (provide 'vc-bzr)
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
603 ;; arch-tag: 8101bad8-4e92-4e7d-85ae-d8e08b4e7c06
a5186dc625d4 *** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
604 ;;; vc-bzr.el ends here