aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-03-15 19:37:17 +0000
committerStefan Monnier2008-03-15 19:37:17 +0000
commit39f4444267b7175a5b4b73d23d1f509bf36409c6 (patch)
tree8469867b1da7f5603cdbefac972eb30831d0bf5c
parent0e2501ed344f5c8e251bcdca981f5d81dd78f663 (diff)
downloademacs-39f4444267b7175a5b4b73d23d1f509bf36409c6.tar.gz
emacs-39f4444267b7175a5b4b73d23d1f509bf36409c6.zip
(vc-bzr-diff): Use a faster invocation when possible.
(vc-bzr-complete-with-prefix, vc-bzr-revision-completion-table): New functions.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/vc-bzr.el66
2 files changed, 66 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 90eabaf24f2..3545dda4b8e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12008-03-15 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * vc-bzr.el (vc-bzr-diff): Use a faster invocation when possible.
4 (vc-bzr-complete-with-prefix, vc-bzr-revision-completion-table):
5 New functions.
6
12008-03-15 Glenn Morris <rgm@gnu.org> 72008-03-15 Glenn Morris <rgm@gnu.org>
2 8
3 * calendar/diary-lib.el (diary-list-entries-1, diary-mark-entries-1): 9 * calendar/diary-lib.el (diary-list-entries-1, diary-mark-entries-1):
diff --git a/lisp/vc-bzr.el b/lisp/vc-bzr.el
index 54a4f866949..d3af75203b0 100644
--- a/lisp/vc-bzr.el
+++ b/lisp/vc-bzr.el
@@ -428,14 +428,17 @@ EDITABLE is ignored."
428 428
429(defun vc-bzr-diff (files &optional rev1 rev2 buffer) 429(defun vc-bzr-diff (files &optional rev1 rev2 buffer)
430 "VC bzr backend for diff." 430 "VC bzr backend for diff."
431 ;; `bzr diff' exits with code 1 if diff is non-empty 431 ;; `bzr diff' exits with code 1 if diff is non-empty.
432 (apply #'vc-bzr-command "diff" (or buffer "*vc-diff*") 1 files 432 (apply #'vc-bzr-command "diff" (or buffer "*vc-diff*") 1 files
433 "--diff-options" (mapconcat 'identity 433 "--diff-options" (mapconcat 'identity
434 (vc-diff-switches-list bzr) 434 (vc-diff-switches-list bzr)
435 " ") 435 " ")
436 (list "-r" (format "%s..%s" 436 ;; This `when' is just an optimization because bzr-1.2 is *much*
437 (or rev1 "revno:-1") 437 ;; faster when the revision argument is not given.
438 (or rev2 ""))))) 438 (when (or rev1 rev2)
439 (list "-r" (format "%s..%s"
440 (or rev1 "revno:-1")
441 (or rev2 ""))))))
439 442
440 443
441;; FIXME: vc-{next,previous}-revision need fixing in vc.el to deal with 444;; FIXME: vc-{next,previous}-revision need fixing in vc.el to deal with
@@ -605,6 +608,57 @@ Optional argument LOCALP is always ignored."
605 ;; else fall back to default vc.el representation 608 ;; else fall back to default vc.el representation
606 (vc-default-dired-state-info 'Bzr file))) 609 (vc-default-dired-state-info 'Bzr file)))
607 610
611;;; Revision completion
612
613(defun vc-bzr-complete-with-prefix (prefix action table string pred)
614 (let ((comp (complete-with-action action table string pred)))
615 (if (stringp comp)
616 (concat prefix comp)
617 comp)))
618
619(defun vc-bzr-revision-completion-table (files)
620 (lexical-let ((files files))
621 ;; What about using `files'?!? --Stef
622 (lambda (string pred action)
623 (cond
624 ((string-match "\\`\\(ancestor\\|branch\\|\\(revno:\\)?[-0-9]+:\\):"
625 string)
626 (vc-bzr-complete-with-prefix (substring string 0 (match-end 0))
627 action
628 'read-file-name-internal
629 (substring string (match-end 0))
630 ;; Dropping `pred'. Maybe we should just
631 ;; stash it in `read-file-name-predicate'?
632 nil))
633 ((string-match "\\`\\(before\\):" string)
634 (vc-bzr-complete-with-prefix (substring string 0 (match-end 0))
635 action
636 (vc-bzr-revision-completion-table files)
637 (substring string (match-end 0))
638 pred))
639 ((string-match "\\`\\(tag\\):" string)
640 (let ((prefix (substring string 0 (match-end 0)))
641 (tag (substring string (match-end 0)))
642 (table nil))
643 (with-temp-buffer
644 ;; "bzr-1.2 tags" is much faster with --show-ids.
645 (call-process vc-bzr-program nil '(t) nil "tags" "--show-ids")
646 ;; The output is ambiguous, unless we assume that revids do not
647 ;; contain spaces.
648 (goto-char (point-min))
649 (while (re-search-forward "^\\(.*[^ \n]\\) +[^ \n]*$" nil t)
650 (push (match-string-no-properties 1) table)))
651 (vc-bzr-complete-with-prefix prefix action table tag pred)))
652
653 ((string-match "\\`\\(revid\\):" string)
654 ;; FIXME: How can I get a list of revision ids?
655 )
656 (t
657 (complete-with-action action '("revno:" "revid:" "last:" "before:"
658 "tag:" "date:" "ancestor:" "branch:"
659 "submit:")
660 string pred))))))
661
608(eval-after-load "vc" 662(eval-after-load "vc"
609 '(add-to-list 'vc-directory-exclusion-list vc-bzr-admin-dirname t)) 663 '(add-to-list 'vc-directory-exclusion-list vc-bzr-admin-dirname t))
610 664