aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-01-04 19:20:59 +0000
committerStefan Monnier2008-01-04 19:20:59 +0000
commitf4d0cf2342b6f04cf53123020227ab92a0cdf0b9 (patch)
tree6d4a8111b213fb0b4c4df1d2c2a3377c50a1e180
parent5378843c2327d5bd08f7c20e9e4f6c21ba888b75 (diff)
downloademacs-f4d0cf2342b6f04cf53123020227ab92a0cdf0b9.tar.gz
emacs-f4d0cf2342b6f04cf53123020227ab92a0cdf0b9.zip
Copyright and version headers update.
Remove some outdated comments through the whole file. (vc-bzr-program-args): Remove because unused. (vc-bzr-log-switches): New customization option. (vc-bzr-command): Use LC_MESSAGES=C instead of LC_ALL=C. No longer use `vc-bzr-program-args'. (vc-bzr-register): Fix for working with both 22.1 and CVS version of `vc-find-root' (patch by Andreas Hoenen). (vc-bzr-status): Update regex to match latest Bzr output. Remove redundant test. (vc-bzr-init-version): New function. (vc-bzr-unregister): Must not delete file. (vc-bzr-find-version): New function. (vc-bzr-checkout): Argument `rev' is explicit revision only if it's a non-empty string, otherwise take head revision. (vc-bzr-print-log): Pass `vc-bzr-log-switches' to "bzr log". (vc-bzr-diff): Simpler build of the revision spec string. (vc-annotate-convert-time, vc-bzr-annotate-difference): Remove: compatibility hacks for Emacs21, not needed in Emacs 22. (vc-bzr-dir-state): Add code comments. Removed redundant statement. (vc-bzr-dired-state-info): Only provide custom strings for overloaded VC state 'edited; otherwise fallback to `vc-default-dired-state-info'.
-rw-r--r--lisp/ChangeLog26
-rw-r--r--lisp/vc-bzr.el119
2 files changed, 84 insertions, 61 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 58420d8483b..ee03fe70574 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,29 @@
12008-01-04 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * vc-bzr.el: Copyright and version headers update.
4 Remove some outdated comments through the whole file.
5 (vc-bzr-program-args): Remove because unused.
6 (vc-bzr-log-switches): New customization option.
7 (vc-bzr-command): Use LC_MESSAGES=C instead of LC_ALL=C. No longer
8 use `vc-bzr-program-args'.
9 (vc-bzr-register): Fix for working with both 22.1 and CVS version of
10 `vc-find-root' (patch by Andreas Hoenen).
11 (vc-bzr-status): Update regex to match latest Bzr output.
12 Remove redundant test.
13 (vc-bzr-init-version): New function.
14 (vc-bzr-unregister): Must not delete file.
15 (vc-bzr-find-version): New function.
16 (vc-bzr-checkout): Argument `rev' is explicit revision only if it's
17 a non-empty string, otherwise take head revision.
18 (vc-bzr-print-log): Pass `vc-bzr-log-switches' to "bzr log".
19 (vc-bzr-diff): Simpler build of the revision spec string.
20 (vc-annotate-convert-time, vc-bzr-annotate-difference):
21 Remove: compatibility hacks for Emacs21, not needed in Emacs 22.
22 (vc-bzr-dir-state): Add code comments. Removed redundant statement.
23 (vc-bzr-dired-state-info): Only provide custom strings for
24 overloaded VC state 'edited; otherwise fallback to
25 `vc-default-dired-state-info'.
26
12008-01-04 Dan Nicolaescu <dann@ics.uci.edu> 272008-01-04 Dan Nicolaescu <dann@ics.uci.edu>
2 28
3 * vc-git.el (vc-git-dir-state): 29 * vc-git.el (vc-git-dir-state):
diff --git a/lisp/vc-bzr.el b/lisp/vc-bzr.el
index e30af4369c2..c1be5e18bbc 100644
--- a/lisp/vc-bzr.el
+++ b/lisp/vc-bzr.el
@@ -1,11 +1,11 @@
1;;; vc-bzr.el --- VC backend for the bzr revision control system 1;;; vc-bzr.el --- VC backend for the bzr revision control system
2 2
3;; Copyright (C) 2006, 2007 Free Software Foundation, Inc. 3;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
4 4
5;; Author: Dave Love <fx@gnu.org>, Riccardo Murri <riccardo.murri@gmail.com> 5;; Author: Dave Love <fx@gnu.org>, Riccardo Murri <riccardo.murri@gmail.com>
6;; Keywords: tools 6;; Keywords: tools
7;; Created: Sept 2006 7;; Created: Sept 2006
8;; Version: 2007-09-05 8;; Version: 2008-01-04 (Bzr revno 25)
9;; URL: http://launchpad.net/vc-bzr 9;; URL: http://launchpad.net/vc-bzr
10 10
11;; This file is free software; you can redistribute it and/or modify 11;; This file is free software; you can redistribute it and/or modify
@@ -15,7 +15,7 @@
15 15
16;; This file is distributed in the hope that it will be useful, 16;; This file is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of 17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18LC;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details. 19;; GNU General Public License for more details.
20 20
21;; You should have received a copy of the GNU General Public License 21;; You should have received a copy of the GNU General Public License
@@ -26,13 +26,11 @@
26 26
27;;; Commentary: 27;;; Commentary:
28 28
29;; See <URL:http://bazaar-vcs.org/> concerning bzr. 29;; See <URL:http://bazaar-vcs.org/> concerning bzr. See
30 30;; <URL:http://launchpad.net/vc-bzr> for alternate development
31;; Load this library to register bzr support in VC. It covers basic VC 31;; branches of `vc-bzr'.
32;; functionality, but was only lightly exercised with a few Emacs/bzr
33;; version combinations, namely those current on the authors' PCs.
34;; See various Fixmes below.
35 32
33;; Load this library to register bzr support in VC.
36 34
37;; Known bugs 35;; Known bugs
38;; ========== 36;; ==========
@@ -67,12 +65,6 @@
67 :group 'vc-bzr 65 :group 'vc-bzr
68 :type 'string) 66 :type 'string)
69 67
70;; Fixme: there's probably no call for this.
71(defcustom vc-bzr-program-args nil
72 "List of global arguments to pass to `vc-bzr-program'."
73 :group 'vc-bzr
74 :type '(repeat string))
75
76(defcustom vc-bzr-diff-switches nil 68(defcustom vc-bzr-diff-switches nil
77 "String/list of strings specifying extra switches for bzr diff under VC." 69 "String/list of strings specifying extra switches for bzr diff under VC."
78 :type '(choice (const :tag "None" nil) 70 :type '(choice (const :tag "None" nil)
@@ -80,20 +72,28 @@
80 (repeat :tag "Argument List" :value ("") string)) 72 (repeat :tag "Argument List" :value ("") string))
81 :group 'vc-bzr) 73 :group 'vc-bzr)
82 74
75(defcustom vc-bzr-log-switches nil
76 "String/list of strings specifying extra switches for `bzr log' under VC."
77 :type '(choice (const :tag "None" nil)
78 (string :tag "Argument String")
79 (repeat :tag "Argument List" :value ("") string))
80 :group 'vc-bzr)
81
83;; since v0.9, bzr supports removing the progress indicators 82;; since v0.9, bzr supports removing the progress indicators
84;; by setting environment variable BZR_PROGRESS_BAR to "none". 83;; by setting environment variable BZR_PROGRESS_BAR to "none".
85(defun vc-bzr-command (bzr-command buffer okstatus file-or-list &rest args) 84(defun vc-bzr-command (bzr-command buffer okstatus file-or-list &rest args)
86 "Wrapper round `vc-do-command' using `vc-bzr-program' as COMMAND. 85 "Wrapper round `vc-do-command' using `vc-bzr-program' as COMMAND.
87Invoke the bzr command adding `BZR_PROGRESS_BAR=none' to the environment." 86Invoke the bzr command adding `BZR_PROGRESS_BAR=none' and
87`LC_MESSAGES=C' to the environment."
88 (let ((process-environment 88 (let ((process-environment
89 (list* "BZR_PROGRESS_BAR=none" ; Suppress progress output (bzr >=0.9) 89 (list* "BZR_PROGRESS_BAR=none" ; Suppress progress output (bzr >=0.9)
90 "LC_ALL=C" ; Force English output 90 "LC_MESSAGES=C" ; Force English output
91 process-environment))) 91 process-environment)))
92 (apply 'vc-do-command buffer okstatus vc-bzr-program 92 (apply 'vc-do-command buffer okstatus vc-bzr-program
93 file-or-list bzr-command (append vc-bzr-program-args args)))) 93 file-or-list bzr-command args)))
94 94
95;;;###autoload 95;;;###autoload
96(defconst vc-bzr-admin-dirname ".bzr" ; FIXME: "_bzr" on w32? 96(defconst vc-bzr-admin-dirname ".bzr"
97 "Name of the directory containing Bzr repository status files.") 97 "Name of the directory containing Bzr repository status files.")
98;;;###autoload 98;;;###autoload
99(defconst vc-bzr-admin-checkout-format-file 99(defconst vc-bzr-admin-checkout-format-file
@@ -162,12 +162,10 @@ running `vc-bzr-state'."
162 "Return file name FILENAME stripped of the initial Bzr repository path." 162 "Return file name FILENAME stripped of the initial Bzr repository path."
163 (lexical-let* 163 (lexical-let*
164 ((filename* (expand-file-name filename)) 164 ((filename* (expand-file-name filename))
165 (rootdir (vc-bzr-root (file-name-directory filename*)))) 165 (rootdir (vc-bzr-root filename*)))
166 (when rootdir 166 (when rootdir
167 (file-relative-name filename* rootdir)))) 167 (file-relative-name filename* rootdir))))
168 168
169;; FIXME: Also get this in a non-registered sub-directory.
170;; It already works for me. -- Riccardo
171(defun vc-bzr-status (file) 169(defun vc-bzr-status (file)
172 "Return FILE status according to Bzr. 170 "Return FILE status according to Bzr.
173Return value is a cons (STATUS . WARNING), where WARNING is a 171Return value is a cons (STATUS . WARNING), where WARNING is a
@@ -196,16 +194,16 @@ If any error occurred in running `bzr status', then return nil."
196 ;; bzr prints paths relative to the repository root. 194 ;; bzr prints paths relative to the repository root.
197 (concat "^\\(" vc-bzr-state-words "\\):[ \t\n]+" 195 (concat "^\\(" vc-bzr-state-words "\\):[ \t\n]+"
198 (regexp-quote (vc-bzr-file-name-relative file)) 196 (regexp-quote (vc-bzr-file-name-relative file))
199 (if (file-directory-p file) "/?" "") 197 ;; Bzr appends a '/' to directory names and
198 ;; '*' to executable files
199 (if (file-directory-p file) "/?" "\\*?")
200 "[ \t\n]*$") 200 "[ \t\n]*$")
201 nil t) 201 nil t)
202 (lexical-let ((statusword (match-string 1))) 202 (lexical-let ((statusword (match-string 1)))
203 ;; Erase the status text that matched. 203 ;; Erase the status text that matched.
204 (delete-region (match-beginning 0) (match-end 0)) 204 (delete-region (match-beginning 0) (match-end 0))
205 (setq status 205 (setq status
206 (and (equal ret 0) ; Seems redundant. --Stef 206 (intern (replace-regexp-in-string " " "" statusword)))))
207 (intern (replace-regexp-in-string " " ""
208 statusword))))))
209 (when status 207 (when status
210 (goto-char (point-min)) 208 (goto-char (point-min))
211 (skip-chars-forward " \n\t") ;Throw away spaces. 209 (skip-chars-forward " \n\t") ;Throw away spaces.
@@ -279,6 +277,10 @@ If any error occurred in running `bzr status', then return nil."
279 "Create a new Bzr repository." 277 "Create a new Bzr repository."
280 (vc-bzr-command "init" nil 0 nil)) 278 (vc-bzr-command "init" nil 0 nil))
281 279
280(defun vc-bzr-init-version (&optional file)
281 "Always return nil, as Bzr cannot register explicit versions."
282 nil)
283
282(defun vc-bzr-register (files &optional rev comment) 284(defun vc-bzr-register (files &optional rev comment)
283 "Register FILE under bzr. 285 "Register FILE under bzr.
284Signal an error unless REV is nil. 286Signal an error unless REV is nil.
@@ -307,7 +309,7 @@ or a superior directory.")
307 309
308(defun vc-bzr-unregister (file) 310(defun vc-bzr-unregister (file)
309 "Unregister FILE from bzr." 311 "Unregister FILE from bzr."
310 (vc-bzr-command "remove" nil 0 file)) 312 (vc-bzr-command "remove" nil 0 file "--keep"))
311 313
312(defun vc-bzr-checkin (files rev comment) 314(defun vc-bzr-checkin (files rev comment)
313 "Check FILE in to bzr with log message COMMENT. 315 "Check FILE in to bzr with log message COMMENT.
@@ -315,6 +317,13 @@ REV non-nil gets an error."
315 (if rev (error "Can't check in a specific version with bzr")) 317 (if rev (error "Can't check in a specific version with bzr"))
316 (vc-bzr-command "commit" nil 0 files "-m" comment)) 318 (vc-bzr-command "commit" nil 0 files "-m" comment))
317 319
320(defun vc-bzr-find-version (file rev buffer)
321 "Fetch version REV of file FILE and put it into BUFFER."
322 (with-current-buffer buffer
323 (if (and rev (stringp rev) (not (string= rev "")))
324 (vc-bzr-command "cat" t 0 file "-r" rev)
325 (vc-bzr-command "cat" t 0 file))))
326
318(defun vc-bzr-checkout (file &optional editable rev destfile) 327(defun vc-bzr-checkout (file &optional editable rev destfile)
319 "Checkout revision REV of FILE from bzr to DESTFILE. 328 "Checkout revision REV of FILE from bzr to DESTFILE.
320EDITABLE is ignored." 329EDITABLE is ignored."
@@ -323,7 +332,7 @@ EDITABLE is ignored."
323 (let ((coding-system-for-read 'binary) 332 (let ((coding-system-for-read 'binary)
324 (coding-system-for-write 'binary)) 333 (coding-system-for-write 'binary))
325 (with-temp-file destfile 334 (with-temp-file destfile
326 (if rev 335 (if (and rev (stringp rev) (not (string= rev "")))
327 (vc-bzr-command "cat" t 0 file "-r" rev) 336 (vc-bzr-command "cat" t 0 file "-r" rev)
328 (vc-bzr-command "cat" t 0 file))))) 337 (vc-bzr-command "cat" t 0 file)))))
329 338
@@ -356,9 +365,13 @@ EDITABLE is ignored."
356 365
357(defun vc-bzr-print-log (files &optional buffer) ; get buffer arg in Emacs 22 366(defun vc-bzr-print-log (files &optional buffer) ; get buffer arg in Emacs 22
358 "Get bzr change log for FILES into specified BUFFER." 367 "Get bzr change log for FILES into specified BUFFER."
359 ;; Fixme: This might need the locale fixing up if things like `revno' 368 ;; FIXME: `vc-bzr-command' runs `bzr log' with `LC_MESSAGES=C', so
360 ;; got localized, but certainly it shouldn't use LC_ALL=C. 369 ;; the log display may not what the user wants - but I see no other
361 (vc-bzr-command "log" buffer 0 files) 370 ;; way of getting the above regexps working.
371 (apply 'vc-bzr-command "log" buffer 0 files
372 (if (stringp vc-bzr-log-switches)
373 (list vc-bzr-log-switches)
374 vc-bzr-log-switches))
362 ;; FIXME: Until Emacs-23, VC was missing a hook to sort out the mode for 375 ;; FIXME: Until Emacs-23, VC was missing a hook to sort out the mode for
363 ;; the buffer, or at least set the regexps right. 376 ;; the buffer, or at least set the regexps right.
364 (unless (fboundp 'vc-default-log-view-mode) 377 (unless (fboundp 'vc-default-log-view-mode)
@@ -376,19 +389,14 @@ EDITABLE is ignored."
376 389
377(defun vc-bzr-diff (files &optional rev1 rev2 buffer) 390(defun vc-bzr-diff (files &optional rev1 rev2 buffer)
378 "VC bzr backend for diff." 391 "VC bzr backend for diff."
379 (let ((working (vc-workfile-version (if (consp files) (car files) files)))) 392 ;; `bzr diff' exits with code 1 if diff is non-empty
380 (if (and (equal rev1 working) (not rev2))
381 (setq rev1 nil))
382 (if (and (not rev1) rev2)
383 (setq rev1 working))
384 ;; bzr diff produces condition code 1 for some reason.
385 (apply #'vc-bzr-command "diff" (or buffer "*vc-diff*") 1 files 393 (apply #'vc-bzr-command "diff" (or buffer "*vc-diff*") 1 files
386 "--diff-options" (mapconcat 'identity (vc-diff-switches-list bzr) 394 "--diff-options" (mapconcat 'identity
395 (vc-diff-switches-list bzr)
387 " ") 396 " ")
388 (when rev1 397 (list "-r" (format "%s..%s"
389 (if rev2 398 (or rev1 "revno:-1")
390 (list "-r" (format "%s..%s" rev1 rev2)) 399 (or rev2 "")))))
391 (list "-r" rev1))))))
392 400
393(defalias 'vc-bzr-diff-tree 'vc-bzr-diff) 401(defalias 'vc-bzr-diff-tree 'vc-bzr-diff)
394 402
@@ -437,14 +445,6 @@ property containing author and date information."
437 (replace-match "") 445 (replace-match "")
438 (insert tag " |"))))) 446 (insert tag " |")))))
439 447
440;; Definition from Emacs 22
441(unless (fboundp 'vc-annotate-convert-time)
442 (defun vc-annotate-convert-time (time)
443 "Convert a time value to a floating-point number of days.
444The argument TIME is a list as returned by `current-time' or
445`encode-time', only the first two elements of that list are considered."
446 (/ (+ (* (float (car time)) (lsh 1 16)) (cadr time)) 24 3600)))
447
448(defun vc-bzr-annotate-time () 448(defun vc-bzr-annotate-time ()
449 (when (re-search-forward "^ *[0-9]+ |" nil t) 449 (when (re-search-forward "^ *[0-9]+ |" nil t)
450 (let ((prop (get-text-property (line-beginning-position) 'help-echo))) 450 (let ((prop (get-text-property (line-beginning-position) 'help-echo)))
@@ -464,12 +464,6 @@ Return nil if current line isn't annotated."
464 (if (looking-at " *\\([0-9]+\\) | ") 464 (if (looking-at " *\\([0-9]+\\) | ")
465 (match-string-no-properties 1)))) 465 (match-string-no-properties 1))))
466 466
467;; Not needed for Emacs 22
468(defun vc-bzr-annotate-difference (point)
469 (let ((next-time (vc-bzr-annotate-time)))
470 (if next-time
471 (- (vc-annotate-convert-time (current-time)) next-time))))
472
473(defun vc-bzr-command-discarding-stderr (command &rest args) 467(defun vc-bzr-command-discarding-stderr (command &rest args)
474 "Execute shell command COMMAND (with ARGS); return its output and exitcode. 468 "Execute shell command COMMAND (with ARGS); return its output and exitcode.
475Return value is a cons (EXITCODE . OUTPUT), where EXITCODE is 469Return value is a cons (EXITCODE . OUTPUT), where EXITCODE is
@@ -507,9 +501,13 @@ Optional argument LOCALP is always ignored."
507 (buffer-substring-no-properties 501 (buffer-substring-no-properties
508 (line-beginning-position) (line-end-position)) 502 (line-beginning-position) (line-end-position))
509 bzr-root-directory))) 503 bzr-root-directory)))
504 ;; files are up-to-date unless they appear in the `bzr
505 ;; status' output below
510 (vc-file-setprop file 'vc-state 'up-to-date) 506 (vc-file-setprop file 'vc-state 'up-to-date)
511 ;; XXX: is this correct? what happens if one 507 ;; XXX: is this correct? what happens if one
512 ;; mixes different SCMs in the same dir? 508 ;; mixes different SCMs in the same dir?
509 ;; Anyway, we're looking at the output of `bzr ls --versioned',
510 ;; so we know these files are registered with Bzr.
513 (vc-file-setprop file 'vc-backend 'Bzr)))) 511 (vc-file-setprop file 'vc-backend 'Bzr))))
514 ;; `bzr status' reports on added/modified/renamed and unknown/ignored files 512 ;; `bzr status' reports on added/modified/renamed and unknown/ignored files
515 (setq at-start t) 513 (setq at-start t)
@@ -561,11 +559,10 @@ Optional argument LOCALP is always ignored."
561(defun vc-bzr-dired-state-info (file) 559(defun vc-bzr-dired-state-info (file)
562 "Bzr-specific version of `vc-dired-state-info'." 560 "Bzr-specific version of `vc-dired-state-info'."
563 (if (eq 'edited (vc-state file)) 561 (if (eq 'edited (vc-state file))
564 (let ((bzr-state (vc-file-getprop file 'vc-bzr-state))) 562 (concat "(" (symbol-name (or (vc-file-getprop file 'vc-bzr-state)
565 (if bzr-state 563 'edited)) ")")
566 (concat "(" (symbol-name bzr-state) ")") 564 ;; else fall back to default vc.el representation
567 ;; else fall back to default vc representation 565 (vc-default-dired-state-info 'Bzr file)))
568 (vc-default-dired-state-info 'Bzr file)))))
569 566
570(eval-after-load "vc" 567(eval-after-load "vc"
571 '(add-to-list 'vc-directory-exclusion-list vc-bzr-admin-dirname t)) 568 '(add-to-list 'vc-directory-exclusion-list vc-bzr-admin-dirname t))