Mercurial > emacs
annotate lisp/vc-bzr.el @ 81911:2d5f4f5607c1
*** empty log message ***
author | Thien-Thi Nguyen <ttn@gnuvola.org> |
---|---|
date | Mon, 16 Jul 2007 16:59:58 +0000 |
parents | e40762570726 |
children | 584ac4db2633 |
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 |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
61 (require 'cl) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
62 (require 'vc)) ; for vc-exec-after |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
63 |
81649
e40762570726
(vc-functions): Clear up the cache when reloading the file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81539
diff
changeset
|
64 ;; Clear up the cache to force vc-call to check again and discover |
e40762570726
(vc-functions): Clear up the cache when reloading the file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81539
diff
changeset
|
65 ;; new functions when we reload this file. |
e40762570726
(vc-functions): Clear up the cache when reloading the file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81539
diff
changeset
|
66 (put 'BZR 'vc-functions nil) |
e40762570726
(vc-functions): Clear up the cache when reloading the file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81539
diff
changeset
|
67 |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
68 (defgroup vc-bzr nil |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
69 "VC bzr backend." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
70 ;; :version "22" |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
71 :group 'vc) |
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 (defcustom vc-bzr-program "bzr" |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
74 "Name of the bzr command (excluding any arguments)." |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
75 :group 'vc-bzr |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
76 :type 'string) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
77 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
78 ;; Fixme: there's probably no call for this. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
79 (defcustom vc-bzr-program-args nil |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
80 "List of global arguments to pass to `vc-bzr-program'." |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
81 :group 'vc-bzr |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
82 :type '(repeat string)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
83 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
84 (defcustom vc-bzr-diff-switches nil |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
85 "String/list of strings specifying extra switches for bzr diff under VC." |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
86 :type '(choice (const :tag "None" nil) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
87 (string :tag "Argument String") |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
88 (repeat :tag "Argument List" :value ("") string)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
89 :group 'vc-bzr) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
90 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
91 (defvar vc-bzr-version nil |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
92 "Internal use.") |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
93 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
94 ;; Could be used for compatibility checks if bzr changes. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
95 (defun vc-bzr-version () |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
96 "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
|
97 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
|
98 if running `vc-bzr-program' doesn't produce the expected output." |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
99 (or vc-bzr-version |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
100 (setq vc-bzr-version |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
101 (let ((s (shell-command-to-string |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
102 (concat (shell-quote-argument vc-bzr-program) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
103 " --version")))) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
104 (if (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)$" s) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
105 (list (string-to-number (match-string 1 s)) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
106 (string-to-number (match-string 2 s)) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
107 (string-to-number (match-string 3 s))) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
108 '(0 0 0)))))) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
109 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
110 (defun vc-bzr-at-least-version (vers) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
111 "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
|
112 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
|
113 (version-list-<= vers (vc-bzr-version))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
114 |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
115 ;; since v0.9, bzr supports removing the progress indicators |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
116 ;; by setting environment variable BZR_PROGRESS_BAR to "none". |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
117 (defun vc-bzr-command (bzr-command buffer okstatus file &rest args) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
118 "Wrapper round `vc-do-command' using `vc-bzr-program' as COMMAND. |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
119 Invoke the bzr command adding `BZR_PROGRESS_BAR=none' to the environment." |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
120 (let ((process-environment |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
121 (list* "BZR_PROGRESS_BAR=none" ; Suppress progress output (bzr >=0.9) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
122 "LC_ALL=C" ; Force English output |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
123 process-environment)) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
124 ;; bzr may attempt some kind of user interaction if its stdin/stdout |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
125 ;; is connected to a PTY; therefore, ask Emacs to use a pipe to |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
126 ;; communicate with it. |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
127 ;; This is redundant because vc-do-command does it already. --Stef |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
128 (process-connection-type nil)) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
129 (apply 'vc-do-command buffer okstatus vc-bzr-program |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
130 file bzr-command (append vc-bzr-program-args args)))) |
81477
92dd41bc6130
(vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81446
diff
changeset
|
131 |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
132 (unless (vc-bzr-at-least-version '(0 9)) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
133 ;; For older versions, we fall back to washing the log buffer |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
134 ;; when all output has been gathered. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
135 (defun vc-bzr-post-command-function (command file flags) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
136 "`vc-post-command-functions' function to remove progress messages." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
137 ;; Note that using this requires that the vc command is run |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
138 ;; synchronously. Otherwise, the ^Ms in the leading progress |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
139 ;; message on stdout cause the stream to be interpreted as having |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
140 ;; 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
|
141 ;; know how this works under Windows. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
142 (when (equal command vc-bzr-program) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
143 (save-excursion |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
144 (goto-char (point-min)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
145 (if (looking-at "^\\(\r.*\r\\)[^\r]+$") |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
146 (replace-match "" nil nil nil 1))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
147 (save-excursion |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
148 (goto-char (point-min)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
149 ;; This is inserted by bzr 0.11 `log', at least |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
150 (while (looking-at "read knit.*\n") |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
151 (replace-match ""))))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
152 |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
153 (add-hook 'vc-post-command-functions 'vc-bzr-post-command-function)) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
154 |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
155 ;;;###autoload |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
156 (defconst vc-bzr-admin-dirname ".bzr") ; FIXME: "_bzr" on w32? |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
157 |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
158 ;;;###autoload (defun vc-bzr-registered (file) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
159 ;;;###autoload (if (vc-find-root file vc-bzr-admin-dirname) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
160 ;;;###autoload (progn |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
161 ;;;###autoload (load "vc-bzr") |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
162 ;;;###autoload (vc-bzr-registered file)))) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
163 |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
164 (defun vc-bzr-root-dir (file) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
165 "Return the root directory in the hierarchy above FILE. |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
166 Return nil if there isn't one." |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
167 (vc-find-root file vc-bzr-admin-dirname)) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
168 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
169 (defun vc-bzr-registered (file) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
170 "Return non-nil if FILE is registered with bzr." |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
171 (if (vc-bzr-root-dir file) ; Short cut. |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
172 (vc-bzr-state file))) ; Expensive. |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
173 |
81477
92dd41bc6130
(vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81446
diff
changeset
|
174 (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
|
175 "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
|
176 (or (> (buffer-size buffer) 0) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
177 (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
|
178 (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
|
179 (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
|
180 (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
|
181 |
92dd41bc6130
(vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81446
diff
changeset
|
182 (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
|
183 "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
|
184 "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
|
185 |
92dd41bc6130
(vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81446
diff
changeset
|
186 ;; 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
|
187 (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
|
188 (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
|
189 (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
|
190 (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
|
191 (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
|
192 ;; 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
|
193 ;; 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
|
194 ;; | <status>: |
92dd41bc6130
(vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81446
diff
changeset
|
195 ;; | <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
|
196 ;; 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
|
197 ;; 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
|
198 ;; 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
|
199 (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
|
200 (when |
81649
e40762570726
(vc-functions): Clear up the cache when reloading the file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81539
diff
changeset
|
201 (re-search-forward |
e40762570726
(vc-functions): Clear up the cache when reloading the file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81539
diff
changeset
|
202 (concat "^\\(" vc-bzr-state-words "\\):[ \t\n]+" |
81477
92dd41bc6130
(vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81446
diff
changeset
|
203 (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
|
204 (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
|
205 (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
|
206 (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
|
207 (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
|
208 (setq state |
81649
e40762570726
(vc-functions): Clear up the cache when reloading the file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81539
diff
changeset
|
209 (cond |
81477
92dd41bc6130
(vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81446
diff
changeset
|
210 ((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
|
211 ((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
|
212 ((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
|
213 ;; 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
|
214 (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
|
215 (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
|
216 ;; "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
|
217 ;; 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
|
218 ;; 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
|
219 ;; 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
|
220 ;; 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
|
221 ;; 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
|
222 ;; "bzr" is a user warning, and display it. |
81649
e40762570726
(vc-functions): Clear up the cache when reloading the file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81539
diff
changeset
|
223 (message "Warnings in `bzr' output: %s" |
81477
92dd41bc6130
(vc-bzr-with-process-environment, vc-bzr-std-process-invocation): New macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81446
diff
changeset
|
224 (buffer-substring (point-min) (point-max)))) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
225 (when state |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
226 (vc-file-setprop file 'vc-workfile-version |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
227 (vc-bzr-workfile-version file)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
228 (vc-file-setprop file 'vc-state state)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
229 state))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
230 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
231 (defun vc-bzr-workfile-unchanged-p (file) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
232 (eq 'up-to-date (vc-bzr-state file))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
233 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
234 (defun vc-bzr-workfile-version (file) |
81649
e40762570726
(vc-functions): Clear up the cache when reloading the file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81539
diff
changeset
|
235 ;; Looks like this could be obtained via counting lines in |
e40762570726
(vc-functions): Clear up the cache when reloading the file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81539
diff
changeset
|
236 ;; .bzr/branch/revision-history. |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
237 (with-temp-buffer |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
238 (vc-bzr-command "revno" t 0 file) |
81649
e40762570726
(vc-functions): Clear up the cache when reloading the file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81539
diff
changeset
|
239 (goto-char (point-min)) |
e40762570726
(vc-functions): Clear up the cache when reloading the file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81539
diff
changeset
|
240 (buffer-substring (point) (line-end-position)))) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
241 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
242 (defun vc-bzr-checkout-model (file) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
243 'implicit) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
244 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
245 (defun vc-bzr-register (file &optional rev comment) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
246 "Register FILE under bzr. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
247 Signal an error unless REV is nil. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
248 COMMENT is ignored." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
249 (if rev (error "Can't register explicit version with bzr")) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
250 (vc-bzr-command "add" nil 0 file)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
251 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
252 ;; 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
|
253 ;; that's relatively expensive. |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
254 (defalias 'vc-bzr-responsible-p 'vc-bzr-root-dir |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
255 "Return non-nil if FILE is (potentially) controlled by bzr. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
256 The criterion is that there is a `.bzr' directory in the same |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
257 or a superior directory.") |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
258 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
259 (defun vc-bzr-could-register (file) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
260 "Return non-nil if FILE could be registered under bzr." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
261 (and (vc-bzr-responsible-p file) ; shortcut |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
262 (condition-case () |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
263 (with-temp-buffer |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
264 (vc-bzr-command "add" t 0 file "--dry-run") |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
265 ;; The command succeeds with no output if file is |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
266 ;; registered (in bzr 0.8). |
81649
e40762570726
(vc-functions): Clear up the cache when reloading the file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81539
diff
changeset
|
267 (goto-char (point-min)) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
268 (looking-at "added ")) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
269 (error)))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
270 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
271 (defun vc-bzr-unregister (file) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
272 "Unregister FILE from bzr." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
273 (vc-bzr-command "remove" nil 0 file)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
274 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
275 (defun vc-bzr-checkin (file rev comment) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
276 "Check FILE in to bzr with log message COMMENT. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
277 REV non-nil gets an error." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
278 (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
|
279 (vc-bzr-command "commit" nil 0 file "-m" comment)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
280 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
281 (defun vc-bzr-checkout (file &optional editable rev destfile) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
282 "Checkout revision REV of FILE from bzr to DESTFILE. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
283 EDITABLE is ignored." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
284 (unless destfile |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
285 (setq destfile (vc-version-backup-file-name file rev))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
286 (let ((coding-system-for-read 'binary) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
287 (coding-system-for-write 'binary)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
288 (with-temp-file destfile |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
289 (if rev |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
290 (vc-bzr-command "cat" t 0 file "-r" rev) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
291 (vc-bzr-command "cat" t 0 file))))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
292 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
293 (defun vc-bzr-revert (file &optional contents-done) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
294 (unless contents-done |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
295 (with-temp-buffer (vc-bzr-command "revert" t 'async file)))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
296 |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
297 (defvar log-view-message-re) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
298 (defvar log-view-file-re) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
299 (defvar log-view-font-lock-keywords) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
300 (defvar log-view-current-tag-function) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
301 |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
302 (define-derived-mode vc-bzr-log-view-mode log-view-mode "Bzr-Log-View" |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
303 (remove-hook 'log-view-mode-hook 'vc-bzr-log-view-mode) ;Deactivate the hack. |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
304 (require 'add-log) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
305 ;; Don't have file markers, so use impossible regexp. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
306 (set (make-local-variable 'log-view-file-re) "\\'\\`") |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
307 (set (make-local-variable 'log-view-message-re) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
308 "^ *-+\n *\\(?:revno: \\([0-9]+\\)\\|merged: .+\\)") |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
309 (set (make-local-variable 'log-view-font-lock-keywords) |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
310 ;; log-view-font-lock-keywords is careful to use the buffer-local |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
311 ;; value of log-view-message-re only since Emacs-23. |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
312 (append `((,log-view-message-re . 'log-view-message-face)) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
313 ;; log-view-font-lock-keywords |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
314 '(("^ *committer: \ |
81539
0c6323e48d45
(vc-bzr-log-view-mode): Add + to the email address
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81512
diff
changeset
|
315 \\([^<(]+?\\)[ ]*[(<]\\([[:alnum:]_.+-]+@[[:alnum:]_.-]+\\)[>)]" |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
316 (1 'change-log-name) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
317 (2 'change-log-email)) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
318 ("^ *timestamp: \\(.*\\)" (1 'change-log-date-face)))))) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
319 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
320 (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
|
321 "Get bzr change log for FILE into specified BUFFER." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
322 ;; 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
|
323 ;; got localized, but certainly it shouldn't use LC_ALL=C. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
324 ;; NB. Can't be async -- see `vc-bzr-post-command-function'. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
325 (vc-bzr-command "log" buffer 0 file) |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
326 ;; FIXME: Until Emacs-23, VC was missing a hook to sort out the mode for |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
327 ;; the buffer, or at least set the regexps right. |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
328 (unless (fboundp 'vc-default-log-view-mode) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
329 (add-hook 'log-view-mode-hook 'vc-bzr-log-view-mode))) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
330 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
331 (defun vc-bzr-show-log-entry (version) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
332 "Find entry for patch name VERSION in bzr change log buffer." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
333 (goto-char (point-min)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
334 (let (case-fold-search) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
335 (if (re-search-forward (concat "^-+\nrevno: " version "$") nil t) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
336 (beginning-of-line 0) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
337 (goto-char (point-min))))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
338 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
339 ;; Fixem: vc-bzr-wash-log |
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 (autoload 'vc-diff-switches-list "vc" nil nil t) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
342 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
343 (defun vc-bzr-diff (file &optional rev1 rev2 buffer) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
344 "VC bzr backend for diff." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
345 (let ((working (vc-workfile-version file))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
346 (if (and (equal rev1 working) (not rev2)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
347 (setq rev1 nil)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
348 (if (and (not rev1) rev2) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
349 (setq rev1 working)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
350 ;; NB. Can't be async -- see `vc-bzr-post-command-function'. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
351 ;; bzr diff produces condition code 1 for some reason. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
352 (apply #'vc-bzr-command "diff" (or buffer "*vc-diff*") 1 file |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
353 "--diff-options" (mapconcat 'identity (vc-diff-switches-list bzr) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
354 " ") |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
355 (when rev1 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
356 (if rev2 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
357 (list "-r" (format "%s..%s" rev1 rev2)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
358 (list "-r" rev1)))))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
359 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
360 (defalias 'vc-bzr-diff-tree 'vc-bzr-diff) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
361 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
362 ;; Fixme: implement vc-bzr-dir-state, vc-bzr-dired-state-info |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
363 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
364 ;; 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
|
365 ;; straight integer versions. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
366 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
367 (defun vc-bzr-delete-file (file) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
368 "Delete FILE and delete it in the bzr repository." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
369 (condition-case () |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
370 (delete-file file) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
371 (file-error nil)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
372 (vc-bzr-command "remove" nil 0 file)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
373 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
374 (defun vc-bzr-rename-file (old new) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
375 "Rename file from OLD to NEW using `bzr mv'." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
376 (vc-bzr-command "mv" nil 0 new old)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
377 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
378 (defvar vc-bzr-annotation-table nil |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
379 "Internal use.") |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
380 (make-variable-buffer-local 'vc-bzr-annotation-table) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
381 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
382 (defun vc-bzr-annotate-command (file buffer &optional version) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
383 "Prepare BUFFER for `vc-annotate' on FILE. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
384 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
|
385 property containing author and date information." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
386 (apply #'vc-bzr-command "annotate" buffer 0 file "-l" "--all" |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
387 (if version (list "-r" version))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
388 (with-current-buffer buffer |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
389 ;; 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
|
390 ;; to allow saving space by sharing the text properties. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
391 (setq vc-bzr-annotation-table (make-hash-table :test 'equal)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
392 (goto-char (point-min)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
393 (while (re-search-forward "^\\( *[0-9]+\\) \\(.+\\) +\\([0-9]\\{8\\}\\) |" |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
394 nil t) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
395 (let* ((rev (match-string 1)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
396 (author (match-string 2)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
397 (date (match-string 3)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
398 (key (match-string 0)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
399 (tag (gethash key vc-bzr-annotation-table))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
400 (unless tag |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
401 (save-match-data |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
402 (string-match " +\\'" author) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
403 (setq author (substring author 0 (match-beginning 0)))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
404 (setq tag (propertize rev 'help-echo (concat "Author: " author |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
405 ", date: " date) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
406 'mouse-face 'highlight)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
407 (puthash key tag vc-bzr-annotation-table)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
408 (replace-match "") |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
409 (insert tag " |"))))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
410 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
411 ;; Definition from Emacs 22 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
412 (unless (fboundp 'vc-annotate-convert-time) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
413 (defun vc-annotate-convert-time (time) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
414 "Convert a time value to a floating-point number of days. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
415 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
|
416 `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
|
417 (/ (+ (* (float (car time)) (lsh 1 16)) (cadr time)) 24 3600))) |
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-annotate-time () |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
420 (when (re-search-forward "^ *[0-9]+ |" nil t) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
421 (let ((prop (get-text-property (line-beginning-position) 'help-echo))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
422 (string-match "[0-9]+\\'" prop) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
423 (vc-annotate-convert-time |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
424 (encode-time 0 0 0 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
425 (string-to-number (substring (match-string 0 prop) 6 8)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
426 (string-to-number (substring (match-string 0 prop) 4 6)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
427 (string-to-number (substring (match-string 0 prop) 0 4)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
428 ))))) |
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 (defun vc-bzr-annotate-extract-revision-at-line () |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
431 "Return revision for current line of annoation buffer, or nil. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
432 Return nil if current line isn't annotated." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
433 (save-excursion |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
434 (beginning-of-line) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
435 (if (looking-at " *\\([0-9]+\\) | ") |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
436 (match-string-no-properties 1)))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
437 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
438 ;; Not needed for Emacs 22 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
439 (defun vc-bzr-annotate-difference (point) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
440 (let ((next-time (vc-bzr-annotate-time))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
441 (if next-time |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
442 (- (vc-annotate-convert-time (current-time)) next-time)))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
443 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
444 ;; 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
|
445 ;; 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
|
446 ;; if there are any symbolic links. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
447 (defun vc-bzr-root (dir) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
448 "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
|
449 ;; 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
|
450 (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
|
451 (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
|
452 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
|
453 (substring |
774e9d2142bd
* vc-bzr.el (vc-bzr-root): Cache the output of shell command execution.
Masatake YAMATO <jet@gyve.org>
parents:
81307
diff
changeset
|
454 (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
|
455 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
456 ;; 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
|
457 ;; 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
|
458 ;; changes have been merged. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
459 (defun vc-bzr-dir-state (dir &optional localp) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
460 "Find the VC state of all files in DIR. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
461 Optional argument LOCALP is always ignored." |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
462 (let ((bzr-root-directory (vc-bzr-root dir)) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
463 (at-start t) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
464 current-bzr-state current-vc-state) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
465 ;; Check that DIR is a bzr repository. |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
466 (unless (file-name-absolute-p bzr-root-directory) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
467 (error "Cannot find bzr repository for directory `%s'" dir)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
468 ;; `bzr ls --versioned' lists all versioned files; |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
469 ;; assume they are up-to-date, unless we are given |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
470 ;; evidence of the contrary. |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
471 (setq at-start t) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
472 (with-temp-buffer |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
473 (vc-bzr-command "ls" t 0 nil "--versioned" "--non-recursive") |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
474 (goto-char (point-min)) |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
475 (while (or at-start |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
476 (eq 0 (forward-line))) |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
477 (setq at-start nil) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
478 (let ((file (expand-file-name |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
479 (buffer-substring-no-properties |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
480 (line-beginning-position) (line-end-position)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
481 bzr-root-directory))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
482 (vc-file-setprop file 'vc-state 'up-to-date) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
483 ;; XXX: is this correct? what happens if one |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
484 ;; mixes different SCMs in the same dir? |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
485 (vc-file-setprop file 'vc-backend 'BZR)))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
486 ;; `bzr status' reports on added/modified/renamed and unknown/ignored files |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
487 (setq at-start t) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
488 (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
|
489 (vc-bzr-command "status" t 0 nil) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
490 (goto-char (point-min)) |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
491 (while (or at-start |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
492 (eq 0 (forward-line))) |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
493 (setq at-start nil) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
494 (cond |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
495 ((looking-at "^added") |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
496 (setq current-vc-state 'edited) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
497 (setq current-bzr-state 'added)) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
498 ((looking-at "^modified") |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
499 (setq current-vc-state 'edited) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
500 (setq current-bzr-state 'modified)) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
501 ((looking-at "^renamed") |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
502 (setq current-vc-state 'edited) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
503 (setq current-bzr-state 'renamed)) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
504 ((looking-at "^\\(unknown\\|ignored\\)") |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
505 (setq current-vc-state nil) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
506 (setq current-bzr-state 'not-versioned)) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
507 ((looking-at " ") |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
508 ;; file names are indented by two spaces |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
509 (when current-vc-state |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
510 (let ((file (expand-file-name |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
511 (buffer-substring-no-properties |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
512 (match-end 0) (line-end-position)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
513 bzr-root-directory))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
514 (vc-file-setprop file 'vc-state current-vc-state) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
515 (vc-file-setprop file 'vc-bzr-state current-bzr-state) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
516 (when (eq 'added current-bzr-state) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
517 (vc-file-setprop file 'vc-workfile-version "0")))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
518 (when (eq 'not-versioned current-bzr-state) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
519 (let ((file (expand-file-name |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
520 (buffer-substring-no-properties |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
521 (match-end 0) (line-end-position)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
522 bzr-root-directory))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
523 (vc-file-setprop file 'vc-backend 'none) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
524 (vc-file-setprop file 'vc-state nil)))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
525 (t |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
526 ;; skip this part of `bzr status' output |
81512
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
527 (setq current-vc-state nil) |
1214f1b9e278
(vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81477
diff
changeset
|
528 (setq current-bzr-state nil))))))) |
81307
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
529 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
530 (defun vc-bzr-dired-state-info (file) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
531 "Bzr-specific version of `vc-dired-state-info'." |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
532 (if (eq 'edited (vc-state file)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
533 (let ((bzr-state (vc-file-getprop file 'vc-bzr-state))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
534 (if bzr-state |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
535 (concat "(" (symbol-name bzr-state) ")") |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
536 ;; else fall back to default vc representation |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
537 (vc-default-dired-state-info 'BZR file))))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
538 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
539 ;; 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
|
540 ;; way to do it. |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
541 (add-to-list 'vc-handled-backends 'BZR) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
542 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
543 (eval-after-load "vc" |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
544 '(add-to-list 'vc-directory-exclusion-list ".bzr" t)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
545 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
546 (defconst vc-bzr-unload-hook |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
547 (lambda () |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
548 (setq vc-handled-backends (delq 'BZR vc-handled-backends)) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
549 (remove-hook 'vc-post-command-functions 'vc-bzr-post-command-function))) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
550 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
551 (provide 'vc-bzr) |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
552 ;; arch-tag: 8101bad8-4e92-4e7d-85ae-d8e08b4e7c06 |
a5186dc625d4
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
553 ;;; vc-bzr.el ends here |