annotate lisp/vc-bzr.el @ 91104:84f80c052155

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Sun, 18 Nov 2007 09:13:01 +0000
parents 4b09bb044f38
children 56a72e2bd635
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 ;;; vc-bzr.el --- VC backend for the bzr revision control system
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
3 ;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
4
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
5 ;; Author: Dave Love <fx@gnu.org>, Riccardo Murri <riccardo.murri@gmail.com>
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6 ;; Keywords: tools
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
7 ;; Created: Sept 2006
78748
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
8 ;; Version: 2007-09-05
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
9 ;; URL: http://launchpad.net/vc-bzr
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
10
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
11 ;; This file is free software; you can redistribute it and/or modify
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 3, or (at your option)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
14 ;; any later version.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
15
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
16 ;; This file is distributed in the hope that it will be useful,
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
19 ;; GNU General Public License for more details.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
20
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
24 ;; Boston, MA 02110-1301, USA.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
25
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
26
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
27 ;;; Commentary:
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
28
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
29 ;; See <URL:http://bazaar-vcs.org/> concerning bzr.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31 ;; Load this library to register bzr support in VC. It covers basic VC
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32 ;; functionality, but was only lightly exercised with a few Emacs/bzr
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
33 ;; version combinations, namely those current on the authors' PCs.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34 ;; See various Fixmes below.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37 ;; Known bugs
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38 ;; ==========
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 ;; When edititing a symlink and *both* the symlink and its target
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41 ;; are bzr-versioned, `vc-bzr` presently runs `bzr status` on the
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 ;; symlink, thereby not detecting whether the actual contents
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
43 ;; (that is, the target contents) are changed.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 ;; See https://bugs.launchpad.net/vc-bzr/+bug/116607
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 ;; For an up-to-date list of bugs, please see:
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 ;; https://bugs.launchpad.net/vc-bzr/+bugs
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 ;;; Code:
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 (eval-when-compile
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 (require 'cl)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54 (require 'vc)) ; for vc-exec-after
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 ;; Clear up the cache to force vc-call to check again and discover
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 ;; new functions when we reload this file.
78404
27f00e50116a Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents: 78387
diff changeset
58 (put 'Bzr 'vc-functions nil)
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 (defgroup vc-bzr nil
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 "VC bzr backend."
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
62 :version "22.2"
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 :group 'vc)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 (defcustom vc-bzr-program "bzr"
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 "Name of the bzr command (excluding any arguments)."
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67 :group 'vc-bzr
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 :type 'string)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70 ;; Fixme: there's probably no call for this.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71 (defcustom vc-bzr-program-args nil
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72 "List of global arguments to pass to `vc-bzr-program'."
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
73 :group 'vc-bzr
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
74 :type '(repeat string))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76 (defcustom vc-bzr-diff-switches nil
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 "String/list of strings specifying extra switches for bzr diff under VC."
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
78 :type '(choice (const :tag "None" nil)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
79 (string :tag "Argument String")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
80 (repeat :tag "Argument List" :value ("") string))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
81 :group 'vc-bzr)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
82
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83 ;; since v0.9, bzr supports removing the progress indicators
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
84 ;; by setting environment variable BZR_PROGRESS_BAR to "none".
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
85 (defun vc-bzr-command (bzr-command buffer okstatus file-or-list &rest args)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86 "Wrapper round `vc-do-command' using `vc-bzr-program' as COMMAND.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87 Invoke the bzr command adding `BZR_PROGRESS_BAR=none' to the environment."
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
88 (let ((process-environment
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89 (list* "BZR_PROGRESS_BAR=none" ; Suppress progress output (bzr >=0.9)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 "LC_ALL=C" ; Force English output
78435
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
91 process-environment)))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 (apply 'vc-do-command buffer okstatus vc-bzr-program
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
93 file-or-list bzr-command (append vc-bzr-program-args args))))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
94
81512
1214f1b9e278 (vc-bzr-dir-state): Use setq rather than set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 81477
diff changeset
95
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
96 ;;;###autoload
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
97 (defconst vc-bzr-admin-dirname ".bzr" ; FIXME: "_bzr" on w32?
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
98 "Name of the directory containing Bzr repository status files.")
78435
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
99 ;;;###autoload
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
100 (defconst vc-bzr-admin-checkout-format-file
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
101 (concat vc-bzr-admin-dirname "/checkout/format"))
78435
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
102 (defconst vc-bzr-admin-dirstate
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
103 (concat vc-bzr-admin-dirname "/checkout/dirstate"))
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
104 (defconst vc-bzr-admin-branch-format-file
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
105 (concat vc-bzr-admin-dirname "/branch/format"))
78435
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
106 (defconst vc-bzr-admin-revhistory
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
107 (concat vc-bzr-admin-dirname "/branch/revision-history"))
78748
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
108 (defconst vc-bzr-admin-lastrev
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
109 (concat vc-bzr-admin-dirname "/branch/last-revision"))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
110
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
111 ;;;###autoload (defun vc-bzr-registered (file)
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
112 ;;;###autoload (if (vc-find-root file vc-bzr-admin-checkout-format-file)
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
113 ;;;###autoload (progn
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
114 ;;;###autoload (load "vc-bzr")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
115 ;;;###autoload (vc-bzr-registered file))))
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
116
78435
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
117 (defun vc-bzr-root (file)
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
118 "Return the root directory of the bzr repository containing FILE."
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
119 ;; Cache technique copied from vc-arch.el.
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
120 (or (vc-file-getprop file 'bzr-root)
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
121 (vc-file-setprop
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
122 file 'bzr-root
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
123 (vc-find-root file vc-bzr-admin-checkout-format-file))))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
124
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
125 (defun vc-bzr-registered (file)
78435
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
126 "Return non-nil if FILE is registered with bzr.
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
127
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
128 For speed, this function tries first to parse Bzr internal file
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
129 `checkout/dirstate', but it may fail if Bzr internal file format
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
130 has changed. As a safeguard, the `checkout/dirstate' file is
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
131 only parsed if it contains the string `#bazaar dirstate flat
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
132 format 3' in the first line.
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
133
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
134 If the `checkout/dirstate' file cannot be parsed, fall back to
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
135 running `vc-bzr-state'."
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
136 (lexical-let ((root (vc-bzr-root file)))
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
137 (when root ; Short cut.
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
138 ;; This looks at internal files. May break if they change
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
139 ;; their format.
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
140 (lexical-let ((dirstate (expand-file-name vc-bzr-admin-dirstate root)))
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
141 (if (not (file-readable-p dirstate))
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
142 (vc-bzr-state file) ; Expensive.
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
143 (with-temp-buffer
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
144 (insert-file-contents dirstate)
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
145 (goto-char (point-min))
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
146 (if (not (looking-at "#bazaar dirstate flat format 3"))
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
147 (vc-bzr-state file) ; Some other unknown format?
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
148 (let* ((relfile (file-relative-name file root))
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
149 (reldir (file-name-directory relfile)))
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
150 (re-search-forward
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
151 (concat "^\0"
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
152 (if reldir (regexp-quote (directory-file-name reldir)))
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
153 "\0"
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
154 (regexp-quote (file-name-nondirectory relfile))
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
155 "\0")
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
156 nil t)))))))))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
157
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
158 (defconst vc-bzr-state-words
78521
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
159 "added\\|ignored\\|kind changed\\|modified\\|removed\\|renamed\\|unknown"
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
160 "Regexp matching file status words as reported in `bzr' output.")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
161
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
162 (defun vc-bzr-file-name-relative (filename)
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
163 "Return file name FILENAME stripped of the initial Bzr repository path."
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
164 (lexical-let*
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
165 ((filename* (expand-file-name filename))
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
166 (rootdir (vc-bzr-root (file-name-directory filename*))))
78748
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
167 (when rootdir
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
168 (file-relative-name filename* rootdir))))
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
169
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
170 ;; FIXME: Also get this in a non-registered sub-directory.
78521
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
171 ;; It already works for me. -- Riccardo
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
172 (defun vc-bzr-status (file)
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
173 "Return FILE status according to Bzr.
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
174 Return value is a cons (STATUS . WARNING), where WARNING is a
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
175 string or nil, and STATUS is one of the symbols: `added',
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
176 `ignored', `kindchanged', `modified', `removed', `renamed', `unknown',
78521
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
177 which directly correspond to `bzr status' output, or 'unchanged
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
178 for files whose copy in the working tree is identical to the one
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
179 in the branch repository, or nil for files that are not
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
180 registered with Bzr.
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
181
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
182 If any error occurred in running `bzr status', then return nil."
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
183 (with-temp-buffer
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
184 (let ((ret (condition-case nil
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
185 (vc-bzr-command "status" t 0 file)
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
186 (file-error nil))) ; vc-bzr-program not found.
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
187 (status 'unchanged))
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
188 ;; the only secure status indication in `bzr status' output
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
189 ;; is a couple of lines following the pattern::
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
190 ;; | <status>:
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
191 ;; | <file name>
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
192 ;; if the file is up-to-date, we get no status report from `bzr',
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
193 ;; so if the regexp search for the above pattern fails, we consider
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
194 ;; the file to be up-to-date.
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
195 (goto-char (point-min))
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
196 (when (re-search-forward
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
197 ;; bzr prints paths relative to the repository root.
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
198 (concat "^\\(" vc-bzr-state-words "\\):[ \t\n]+"
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
199 (regexp-quote (vc-bzr-file-name-relative file))
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
200 (if (file-directory-p file) "/?" "")
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
201 "[ \t\n]*$")
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
202 nil t)
78748
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
203 (lexical-let ((statusword (match-string 1)))
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
204 ;; Erase the status text that matched.
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
205 (delete-region (match-beginning 0) (match-end 0))
78521
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
206 (setq status
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
207 (and (equal ret 0) ; Seems redundant. --Stef
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
208 (intern (replace-regexp-in-string " " ""
78748
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
209 statusword))))))
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
210 (when status
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
211 (goto-char (point-min))
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
212 (skip-chars-forward " \n\t") ;Throw away spaces.
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
213 (cons status
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
214 ;; "bzr" will output warnings and informational messages to
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
215 ;; stderr; due to Emacs' `vc-do-command' (and, it seems,
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
216 ;; `start-process' itself) limitations, we cannot catch stderr
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
217 ;; and stdout into different buffers. So, if there's anything
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
218 ;; left in the buffer after removing the above status
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
219 ;; keywords, let us just presume that any other message from
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
220 ;; "bzr" is a user warning, and display it.
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
221 (unless (eobp) (buffer-substring (point) (point-max))))))))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
222
78521
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
223 (defun vc-bzr-state (file)
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
224 (lexical-let ((result (vc-bzr-status file)))
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
225 (when (consp result)
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
226 (if (cdr result)
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
227 (message "Warnings in `bzr' output: %s" (cdr result)))
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
228 (cdr (assq (car result)
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
229 '((added . edited)
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
230 (kindchanged . edited)
78521
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
231 (renamed . edited)
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
232 (modified . edited)
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
233 (removed . edited)
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
234 (ignored . nil)
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
235 (unknown . nil)
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
236 (unchanged . up-to-date)))))))
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
237
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
238 (defun vc-bzr-workfile-unchanged-p (file)
78521
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
239 (eq 'unchanged (car (vc-bzr-status file))))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
240
85139
8ba0e30716a5 Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 85114
diff changeset
241 (defun vc-bzr-working-revision (file)
78435
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
242 (lexical-let*
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
243 ((rootdir (vc-bzr-root file))
78748
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
244 (branch-format-file (expand-file-name vc-bzr-admin-branch-format-file
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
245 rootdir))
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
246 (revhistory-file (expand-file-name vc-bzr-admin-revhistory rootdir))
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
247 (lastrev-file (expand-file-name vc-bzr-admin-lastrev rootdir)))
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
248 ;; This looks at internal files to avoid forking a bzr process.
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
249 ;; May break if they change their format.
78435
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
250 (if (file-exists-p branch-format-file)
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
251 (with-temp-buffer
78435
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
252 (insert-file-contents branch-format-file)
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
253 (goto-char (point-min))
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
254 (cond
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
255 ((or
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
256 (looking-at "Bazaar-NG branch, format 0.0.4")
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
257 (looking-at "Bazaar-NG branch format 5"))
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
258 ;; count lines in .bzr/branch/revision-history
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
259 (insert-file-contents revhistory-file)
78435
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
260 (number-to-string (count-lines (line-end-position) (point-max))))
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
261 ((looking-at "Bazaar Branch Format 6 (bzr 0.15)")
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
262 ;; revno is the first number in .bzr/branch/last-revision
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
263 (insert-file-contents lastrev-file)
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
264 (if (re-search-forward "[0-9]+" nil t)
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
265 (buffer-substring (match-beginning 0) (match-end 0))))))
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
266 ;; fallback to calling "bzr revno"
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
267 (lexical-let*
78435
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
268 ((result (vc-bzr-command-discarding-stderr
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
269 vc-bzr-program "revno" file))
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
270 (exitcode (car result))
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
271 (output (cdr result)))
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
272 (cond
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
273 ((eq exitcode 0) (substring output 0 -1))
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
274 (t nil))))))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
275
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
276 (defun vc-bzr-checkout-model (file)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
277 'implicit)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
278
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
279 (defun vc-bzr-create-repo ()
78404
27f00e50116a Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents: 78387
diff changeset
280 "Create a new Bzr repository."
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
281 (vc-bzr-command "init" nil 0 nil))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
282
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
283 (defun vc-bzr-register (files &optional rev comment)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
284 "Register FILE under bzr.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
285 Signal an error unless REV is nil.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
286 COMMENT is ignored."
85141
b16f7408cd3f Carry through today's big terminology change to a few places where I
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 85139
diff changeset
287 (if rev (error "Can't register explicit revision with bzr"))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
288 (vc-bzr-command "add" nil 0 files))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
289
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
290 ;; Could run `bzr status' in the directory and see if it succeeds, but
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
291 ;; that's relatively expensive.
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
292 (defalias 'vc-bzr-responsible-p 'vc-bzr-root
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
293 "Return non-nil if FILE is (potentially) controlled by bzr.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
294 The criterion is that there is a `.bzr' directory in the same
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
295 or a superior directory.")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
296
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
297 (defun vc-bzr-could-register (file)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
298 "Return non-nil if FILE could be registered under bzr."
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
299 (and (vc-bzr-responsible-p file) ; shortcut
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
300 (condition-case ()
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
301 (with-temp-buffer
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
302 (vc-bzr-command "add" t 0 file "--dry-run")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
303 ;; The command succeeds with no output if file is
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
304 ;; registered (in bzr 0.8).
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
305 (goto-char (point-min))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
306 (looking-at "added "))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
307 (error))))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
308
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
309 (defun vc-bzr-unregister (file)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
310 "Unregister FILE from bzr."
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
311 (vc-bzr-command "remove" nil 0 file))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
312
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
313 (defun vc-bzr-checkin (files rev comment)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
314 "Check FILE in to bzr with log message COMMENT.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
315 REV non-nil gets an error."
85141
b16f7408cd3f Carry through today's big terminology change to a few places where I
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 85139
diff changeset
316 (if rev (error "Can't check in a specific revision with bzr"))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
317 (vc-bzr-command "commit" nil 0 files "-m" comment))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
318
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
319 (defun vc-bzr-checkout (file &optional editable rev destfile)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
320 "Checkout revision REV of FILE from bzr to DESTFILE.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
321 EDITABLE is ignored."
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
322 (unless destfile
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
323 (setq destfile (vc-version-backup-file-name file rev)))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
324 (let ((coding-system-for-read 'binary)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
325 (coding-system-for-write 'binary))
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
326 (with-temp-file destfile
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
327 (if rev
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
328 (vc-bzr-command "cat" t 0 file "-r" rev)
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
329 (vc-bzr-command "cat" t 0 file)))))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
330
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
331 (defun vc-bzr-revert (file &optional contents-done)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
332 (unless contents-done
78521
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
333 (with-temp-buffer (vc-bzr-command "revert" t 0 file))))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
334
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
335 (defvar log-view-message-re)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
336 (defvar log-view-file-re)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
337 (defvar log-view-font-lock-keywords)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
338 (defvar log-view-current-tag-function)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
339
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
340 (define-derived-mode vc-bzr-log-view-mode log-view-mode "Bzr-Log-View"
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
341 (remove-hook 'log-view-mode-hook 'vc-bzr-log-view-mode) ;Deactivate the hack.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
342 (require 'add-log)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
343 ;; Don't have file markers, so use impossible regexp.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
344 (set (make-local-variable 'log-view-file-re) "\\'\\`")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
345 (set (make-local-variable 'log-view-message-re)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
346 "^ *-+\n *\\(?:revno: \\([0-9]+\\)\\|merged: .+\\)")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
347 (set (make-local-variable 'log-view-font-lock-keywords)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
348 ;; log-view-font-lock-keywords is careful to use the buffer-local
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
349 ;; value of log-view-message-re only since Emacs-23.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
350 (append `((,log-view-message-re . 'log-view-message-face))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
351 ;; log-view-font-lock-keywords
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
352 '(("^ *committer: \
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
353 \\([^<(]+?\\)[ ]*[(<]\\([[:alnum:]_.+-]+@[[:alnum:]_.-]+\\)[>)]"
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
354 (1 'change-log-name)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
355 (2 'change-log-email))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
356 ("^ *timestamp: \\(.*\\)" (1 'change-log-date-face))))))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
357
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
358 (defun vc-bzr-print-log (files &optional buffer) ; get buffer arg in Emacs 22
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
359 "Get bzr change log for FILES into specified BUFFER."
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
360 ;; Fixme: This might need the locale fixing up if things like `revno'
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
361 ;; got localized, but certainly it shouldn't use LC_ALL=C.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
362 (vc-bzr-command "log" buffer 0 files)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
363 ;; FIXME: Until Emacs-23, VC was missing a hook to sort out the mode for
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
364 ;; the buffer, or at least set the regexps right.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
365 (unless (fboundp 'vc-default-log-view-mode)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
366 (add-hook 'log-view-mode-hook 'vc-bzr-log-view-mode)))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
367
85141
b16f7408cd3f Carry through today's big terminology change to a few places where I
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 85139
diff changeset
368 (defun vc-bzr-show-log-entry (revision)
b16f7408cd3f Carry through today's big terminology change to a few places where I
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 85139
diff changeset
369 "Find entry for patch name REVISION in bzr change log buffer."
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
370 (goto-char (point-min))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
371 (let (case-fold-search)
85141
b16f7408cd3f Carry through today's big terminology change to a few places where I
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 85139
diff changeset
372 (if (re-search-forward (concat "^-+\nrevno: " revision "$") nil t)
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
373 (beginning-of-line 0)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
374 (goto-char (point-min)))))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
375
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
376 (autoload 'vc-diff-switches-list "vc" nil nil t)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
377
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
378 (defun vc-bzr-diff (files &optional rev1 rev2 buffer)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
379 "VC bzr backend for diff."
85139
8ba0e30716a5 Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 85114
diff changeset
380 (let ((working (vc-working-revision (if (consp files) (car files) files))))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
381 (if (and (equal rev1 working) (not rev2))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
382 (setq rev1 nil))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
383 (if (and (not rev1) rev2)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
384 (setq rev1 working))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
385 ;; bzr diff produces condition code 1 for some reason.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
386 (apply #'vc-bzr-command "diff" (or buffer "*vc-diff*") 1 files
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
387 "--diff-options" (mapconcat 'identity (vc-diff-switches-list bzr)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
388 " ")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
389 (when rev1
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
390 (if rev2
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
391 (list "-r" (format "%s..%s" rev1 rev2))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
392 (list "-r" rev1))))))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
393
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
394
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
395
85141
b16f7408cd3f Carry through today's big terminology change to a few places where I
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 85139
diff changeset
396 ;; FIXME: vc-{next,previous}-revision need fixing in vc.el to deal with
b16f7408cd3f Carry through today's big terminology change to a few places where I
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 85139
diff changeset
397 ;; straight integer revisions.
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
398
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
399 (defun vc-bzr-delete-file (file)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
400 "Delete FILE and delete it in the bzr repository."
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
401 (condition-case ()
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
402 (delete-file file)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
403 (file-error nil))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
404 (vc-bzr-command "remove" nil 0 file))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
405
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
406 (defun vc-bzr-rename-file (old new)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
407 "Rename file from OLD to NEW using `bzr mv'."
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
408 (vc-bzr-command "mv" nil 0 new old))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
409
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
410 (defvar vc-bzr-annotation-table nil
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
411 "Internal use.")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
412 (make-variable-buffer-local 'vc-bzr-annotation-table)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
413
85141
b16f7408cd3f Carry through today's big terminology change to a few places where I
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 85139
diff changeset
414 (defun vc-bzr-annotate-command (file buffer &optional revision)
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
415 "Prepare BUFFER for `vc-annotate' on FILE.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
416 Each line is tagged with the revision number, which has a `help-echo'
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
417 property containing author and date information."
78748
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
418 (apply #'vc-bzr-command "annotate" buffer 0 file "--long" "--all"
85141
b16f7408cd3f Carry through today's big terminology change to a few places where I
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 85139
diff changeset
419 (if revision (list "-r" revision)))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
420 (with-current-buffer buffer
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
421 ;; Store the tags for the annotated source lines in a hash table
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
422 ;; to allow saving space by sharing the text properties.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
423 (setq vc-bzr-annotation-table (make-hash-table :test 'equal))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
424 (goto-char (point-min))
78748
0b7bd1d9ffbf (vc-bzr-admin-lastrev): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78564
diff changeset
425 (while (re-search-forward "^\\( *[0-9]+\\) +\\(.+\\) +\\([0-9]\\{8\\}\\) |"
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
426 nil t)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
427 (let* ((rev (match-string 1))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
428 (author (match-string 2))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
429 (date (match-string 3))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
430 (key (match-string 0))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
431 (tag (gethash key vc-bzr-annotation-table)))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
432 (unless tag
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
433 (setq tag (propertize rev 'help-echo (concat "Author: " author
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
434 ", date: " date)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
435 'mouse-face 'highlight))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
436 (puthash key tag vc-bzr-annotation-table))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
437 (replace-match "")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
438 (insert tag " |")))))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
439
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
440 ;; Definition from Emacs 22
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
441 (unless (fboundp 'vc-annotate-convert-time)
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
442 (defun vc-annotate-convert-time (time)
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
443 "Convert a time value to a floating-point number of days.
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
444 The argument TIME is a list as returned by `current-time' or
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
445 `encode-time', only the first two elements of that list are considered."
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
446 (/ (+ (* (float (car time)) (lsh 1 16)) (cadr time)) 24 3600)))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
447
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
448 (defun vc-bzr-annotate-time ()
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
449 (when (re-search-forward "^ *[0-9]+ |" nil t)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
450 (let ((prop (get-text-property (line-beginning-position) 'help-echo)))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
451 (string-match "[0-9]+\\'" prop)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
452 (vc-annotate-convert-time
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
453 (encode-time 0 0 0
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
454 (string-to-number (substring (match-string 0 prop) 6 8))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
455 (string-to-number (substring (match-string 0 prop) 4 6))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
456 (string-to-number (substring (match-string 0 prop) 0 4))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
457 )))))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
458
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
459 (defun vc-bzr-annotate-extract-revision-at-line ()
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
460 "Return revision for current line of annoation buffer, or nil.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
461 Return nil if current line isn't annotated."
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
462 (save-excursion
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
463 (beginning-of-line)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
464 (if (looking-at " *\\([0-9]+\\) | ")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
465 (match-string-no-properties 1))))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
466
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
467 ;; Not needed for Emacs 22
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
468 (defun vc-bzr-annotate-difference (point)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
469 (let ((next-time (vc-bzr-annotate-time)))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
470 (if next-time
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
471 (- (vc-annotate-convert-time (current-time)) next-time))))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
472
78435
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
473 (defun vc-bzr-command-discarding-stderr (command &rest args)
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
474 "Execute shell command COMMAND (with ARGS); return its output and exitcode.
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
475 Return value is a cons (EXITCODE . OUTPUT), where EXITCODE is
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
476 the (numerical) exit code of the process, and OUTPUT is a string
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
477 containing whatever the process sent to its standard output
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
478 stream. Standard error output is discarded."
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
479 (with-temp-buffer
78435
adc16e5bfb60 Remove comments about vc-bzr.el being a modified unofficial version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78431
diff changeset
480 (cons
78521
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
481 (apply #'call-process command nil (list (current-buffer) nil) nil args)
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
482 (buffer-substring (point-min) (point-max)))))
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
483
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
484 ;; TODO: it would be nice to mark the conflicted files in VC Dired,
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
485 ;; and implement a command to run ediff and `bzr resolve' once the
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
486 ;; changes have been merged.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
487 (defun vc-bzr-dir-state (dir &optional localp)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
488 "Find the VC state of all files in DIR.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
489 Optional argument LOCALP is always ignored."
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
490 (let ((bzr-root-directory (vc-bzr-root dir))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
491 (at-start t)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
492 current-bzr-state current-vc-state)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
493 ;; Check that DIR is a bzr repository.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
494 (unless (file-name-absolute-p bzr-root-directory)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
495 (error "Cannot find bzr repository for directory `%s'" dir))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
496 ;; `bzr ls --versioned' lists all versioned files;
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
497 ;; assume they are up-to-date, unless we are given
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
498 ;; evidence of the contrary.
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
499 (setq at-start t)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
500 (with-temp-buffer
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
501 (vc-bzr-command "ls" t 0 nil "--versioned" "--non-recursive")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
502 (goto-char (point-min))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
503 (while (or at-start
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
504 (eq 0 (forward-line)))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
505 (setq at-start nil)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
506 (let ((file (expand-file-name
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
507 (buffer-substring-no-properties
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
508 (line-beginning-position) (line-end-position))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
509 bzr-root-directory)))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
510 (vc-file-setprop file 'vc-state 'up-to-date)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
511 ;; XXX: is this correct? what happens if one
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
512 ;; mixes different SCMs in the same dir?
78404
27f00e50116a Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents: 78387
diff changeset
513 (vc-file-setprop file 'vc-backend 'Bzr))))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
514 ;; `bzr status' reports on added/modified/renamed and unknown/ignored files
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
515 (setq at-start t)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
516 (with-temp-buffer
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
517 (vc-bzr-command "status" t 0 nil)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
518 (goto-char (point-min))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
519 (while (or at-start
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
520 (eq 0 (forward-line)))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
521 (setq at-start nil)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
522 (cond
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
523 ((looking-at "^added")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
524 (setq current-vc-state 'edited)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
525 (setq current-bzr-state 'added))
78521
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
526 ((looking-at "^kind changed")
98c39e79e082 (vc-bzr-registered): Use \0 instead of literal NULs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78435
diff changeset
527 (setq current-vc-state 'edited)
78564
8f9613d80af0 Don't fiddle with vc-handled-backend.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78521
diff changeset
528 (setq current-bzr-state 'kindchanged))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
529 ((looking-at "^modified")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
530 (setq current-vc-state 'edited)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
531 (setq current-bzr-state 'modified))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
532 ((looking-at "^renamed")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
533 (setq current-vc-state 'edited)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
534 (setq current-bzr-state 'renamed))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
535 ((looking-at "^\\(unknown\\|ignored\\)")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
536 (setq current-vc-state nil)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
537 (setq current-bzr-state 'not-versioned))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
538 ((looking-at " ")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
539 ;; file names are indented by two spaces
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
540 (when current-vc-state
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
541 (let ((file (expand-file-name
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
542 (buffer-substring-no-properties
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
543 (match-end 0) (line-end-position))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
544 bzr-root-directory)))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
545 (vc-file-setprop file 'vc-state current-vc-state)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
546 (vc-file-setprop file 'vc-bzr-state current-bzr-state)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
547 (when (eq 'added current-bzr-state)
85139
8ba0e30716a5 Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 85114
diff changeset
548 (vc-file-setprop file 'vc-working-revision "0"))))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
549 (when (eq 'not-versioned current-bzr-state)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
550 (let ((file (expand-file-name
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
551 (buffer-substring-no-properties
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
552 (match-end 0) (line-end-position))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
553 bzr-root-directory)))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
554 (vc-file-setprop file 'vc-backend 'none)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
555 (vc-file-setprop file 'vc-state nil))))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
556 (t
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
557 ;; skip this part of `bzr status' output
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
558 (setq current-vc-state nil)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
559 (setq current-bzr-state nil)))))))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
560
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
561 (defun vc-bzr-dired-state-info (file)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
562 "Bzr-specific version of `vc-dired-state-info'."
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
563 (if (eq 'edited (vc-state file))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
564 (let ((bzr-state (vc-file-getprop file 'vc-bzr-state)))
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
565 (if bzr-state
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
566 (concat "(" (symbol-name bzr-state) ")")
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
567 ;; else fall back to default vc representation
78404
27f00e50116a Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents: 78387
diff changeset
568 (vc-default-dired-state-info 'Bzr file)))))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
569
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
570 (eval-after-load "vc"
78431
abd7f08fa06b (vc-bzr-registered): Gracefully handle missing "bzr"
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78404
diff changeset
571 '(add-to-list 'vc-directory-exclusion-list vc-bzr-admin-dirname t))
78372
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
572
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
573 (provide 'vc-bzr)
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
574 ;; arch-tag: 8101bad8-4e92-4e7d-85ae-d8e08b4e7c06
53ed644d1a88 * vc-bzr.el: New file (copied from the trunk).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
575 ;;; vc-bzr.el ends here