2008-05-11 15:36:33 +00:00
|
|
|
|
;;; vc-dispatcher.el -- generic command-dispatcher facility.
|
2008-05-03 07:06:34 +00:00
|
|
|
|
|
2011-01-26 08:36:39 +00:00
|
|
|
|
;; Copyright (C) 2008-2011 Free Software Foundation, Inc.
|
2008-05-03 07:06:34 +00:00
|
|
|
|
|
|
|
|
|
;; Author: FSF (see below for full credits)
|
|
|
|
|
;; Maintainer: Eric S. Raymond <esr@thyrsus.com>
|
* lisp/finder.el (finder-known-keywords): Add keyword "vc"
for version control.
* add-log.el, cvs-status.el, diff.el, diff-mode.el, ediff.el,
* emerge.el, log-edit.el, log-view.el, pcvs.el, smerge-mode.el,
* vc-annotate.el, vc-bzr.el, vc-dir.el, vc-dispatcher.el, vc-git.el,
* vc-hg.el, vc-mtn.el, vc.el: Add keyword "vc".
2010-06-11 19:09:57 +00:00
|
|
|
|
;; Keywords: vc tools
|
2010-08-29 16:17:13 +00:00
|
|
|
|
;; Package: vc
|
2008-05-03 07:06:34 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2008-05-03 07:06:34 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
2008-05-03 07:06:34 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
2008-05-03 07:06:34 +00:00
|
|
|
|
|
|
|
|
|
;;; Credits:
|
|
|
|
|
|
|
|
|
|
;; Designed and implemented by Eric S. Raymond, originally as part of VC mode.
|
2008-05-06 15:00:20 +00:00
|
|
|
|
;; Stefan Monnier and Dan Nicolaescu contributed substantial work on the
|
2008-05-06 01:41:34 +00:00
|
|
|
|
;; vc-dir front end.
|
2008-05-03 07:06:34 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; Goals:
|
|
|
|
|
;;
|
|
|
|
|
;; There is a class of front-ending problems that Emacs might be used
|
|
|
|
|
;; to address that involves selecting sets of files, or possibly
|
|
|
|
|
;; directories, and passing the selection set to slave commands. The
|
|
|
|
|
;; prototypical example, from which this code is derived, is talking
|
2008-05-17 22:55:57 +00:00
|
|
|
|
;; to version-control systems.
|
2008-05-03 07:06:34 +00:00
|
|
|
|
;;
|
|
|
|
|
;; vc-dispatcher.el is written to decouple the UI issues in such front
|
2008-05-17 22:55:57 +00:00
|
|
|
|
;; ends from their application-specific logic. It also provides a
|
2008-05-03 07:06:34 +00:00
|
|
|
|
;; service layer for running the slave commands either synchronously
|
|
|
|
|
;; or asynchronously and managing the message/error logs from the
|
|
|
|
|
;; command runs.
|
|
|
|
|
;;
|
|
|
|
|
;; Similar UI problems can be expected to come up in applications
|
|
|
|
|
;; areas other than VCSes; IDEs and document search are two obvious ones.
|
|
|
|
|
;; This mode is intended to ensure that the Emacs interfaces for all such
|
|
|
|
|
;; beasts are consistent and carefully designed. But even if nothing
|
|
|
|
|
;; but VC ever uses it, getting the layer separation right will be
|
|
|
|
|
;; a valuable thing.
|
|
|
|
|
|
|
|
|
|
;; Dispatcher's universe:
|
|
|
|
|
;;
|
|
|
|
|
;; The universe consists of the file tree rooted at the current
|
2008-05-17 22:55:57 +00:00
|
|
|
|
;; directory. The dispatcher's upper layer deduces some subset
|
|
|
|
|
;; of the file tree from the state of the currently visited buffer
|
2008-05-03 07:06:34 +00:00
|
|
|
|
;; and returns that subset, presumably to a client mode.
|
|
|
|
|
;;
|
2008-05-09 18:59:45 +00:00
|
|
|
|
;; The user may be looking at either of two different views; a buffer
|
|
|
|
|
;; visiting a file, or a directory buffer generated by vc-dispatcher.
|
2008-05-03 07:06:34 +00:00
|
|
|
|
;;
|
|
|
|
|
;; The lower layer of this mode runs commands in subprocesses, either
|
|
|
|
|
;; synchronously or asynchronously. Commands may be launched in one
|
|
|
|
|
;; of two ways: they may be run immediately, or the calling mode can
|
|
|
|
|
;; create a closure associated with a text-entry buffer, to be
|
2008-05-17 22:55:57 +00:00
|
|
|
|
;; executed when the user types C-c to ship the buffer contents. In
|
2008-05-03 07:06:34 +00:00
|
|
|
|
;; either case the command messages and error (if any) will remain
|
|
|
|
|
;; available in a status buffer.
|
|
|
|
|
|
2008-05-03 12:06:42 +00:00
|
|
|
|
;; Special behavior of dispatcher directory buffers:
|
|
|
|
|
;;
|
2008-05-05 18:17:09 +00:00
|
|
|
|
;; In dispatcher directory buffers, facilities to perform basic
|
2008-05-03 12:06:42 +00:00
|
|
|
|
;; navigation and selection operations are provided by keymap and menu
|
|
|
|
|
;; entries that dispatcher sets up itself, so they'll be uniform
|
2008-05-05 18:17:09 +00:00
|
|
|
|
;; across all dispatcher-using client modes. Client modes are
|
2008-05-03 12:06:42 +00:00
|
|
|
|
;; expected to append to these to provide mode-specific bindings.
|
|
|
|
|
;;
|
|
|
|
|
;; The standard map associates a 'state' slot (that the client mode
|
|
|
|
|
;; may set) with each directory entry. The dispatcher knows nothing
|
|
|
|
|
;; about the semantics of individual states, but mark and unmark commands
|
2008-05-17 22:55:57 +00:00
|
|
|
|
;; treat all entries with the same state as the currently selected one as
|
2008-05-05 18:17:09 +00:00
|
|
|
|
;; a unit.
|
2008-05-06 01:41:34 +00:00
|
|
|
|
|
2008-05-11 14:49:39 +00:00
|
|
|
|
;; The interface:
|
2008-05-06 01:41:34 +00:00
|
|
|
|
;;
|
|
|
|
|
;; The main interface to the lower level is vc-do-command. This launches a
|
2008-05-17 22:55:57 +00:00
|
|
|
|
;; command, synchronously or asynchronously, making the output available
|
2009-09-20 19:55:36 +00:00
|
|
|
|
;; in a command log buffer. Two other functions, (vc-start-logentry) and
|
2008-05-06 01:41:34 +00:00
|
|
|
|
;; (vc-finish-logentry), allow you to associate a command closure with an
|
2008-05-17 22:55:57 +00:00
|
|
|
|
;; annotation buffer so that when the user confirms the comment the closure
|
2008-05-06 01:41:34 +00:00
|
|
|
|
;; is run (with the comment as part of its context).
|
|
|
|
|
;;
|
|
|
|
|
;; The interface to the upper level has the two main entry points (vc-dir)
|
|
|
|
|
;; and (vc-dispatcher-selection-set) and a couple of convenience functions.
|
|
|
|
|
;; (vc-dir) sets up a dispatcher browsing buffer; (vc-dispatcher-selection-set)
|
|
|
|
|
;; returns a selection set of files, either the marked files in a browsing
|
|
|
|
|
;; buffer or the singleton set consisting of the file visited by the current
|
2008-05-17 22:55:57 +00:00
|
|
|
|
;; buffer (when that is appropriate). It also does what is needed to ensure
|
|
|
|
|
;; that on-disk files and the contents of their visiting Emacs buffers
|
2008-05-06 16:00:54 +00:00
|
|
|
|
;; coincide.
|
|
|
|
|
;;
|
2010-06-09 01:12:53 +00:00
|
|
|
|
;; When the client mode adds a local vc-mode-line-hook to a buffer, it
|
2008-05-06 16:00:54 +00:00
|
|
|
|
;; will be called with the buffer file name as argument whenever the
|
|
|
|
|
;; dispatcher resynchs the buffer.
|
2008-05-06 01:41:34 +00:00
|
|
|
|
|
2008-05-03 12:06:42 +00:00
|
|
|
|
;; To do:
|
|
|
|
|
;;
|
2008-05-15 12:36:31 +00:00
|
|
|
|
;; - log buffers need font-locking.
|
2008-05-03 12:06:42 +00:00
|
|
|
|
;;
|
2008-05-03 09:45:20 +00:00
|
|
|
|
|
2008-05-17 00:04:07 +00:00
|
|
|
|
;; General customization
|
2008-05-03 09:45:20 +00:00
|
|
|
|
(defcustom vc-logentry-check-hook nil
|
|
|
|
|
"Normal hook run by `vc-finish-logentry'.
|
|
|
|
|
Use this to impose your own rules on the entry in addition to any the
|
2008-05-03 10:47:28 +00:00
|
|
|
|
dispatcher client mode imposes itself."
|
2008-05-03 09:45:20 +00:00
|
|
|
|
:type 'hook
|
|
|
|
|
:group 'vc)
|
|
|
|
|
|
2008-05-03 10:18:08 +00:00
|
|
|
|
(defcustom vc-delete-logbuf-window t
|
2008-05-15 15:01:29 +00:00
|
|
|
|
"If non-nil, delete the log buffer and window after each logical action.
|
2008-05-03 10:18:08 +00:00
|
|
|
|
If nil, bury that buffer instead.
|
|
|
|
|
This is most useful if you have multiple windows on a frame and would like to
|
|
|
|
|
preserve the setting."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'vc)
|
|
|
|
|
|
|
|
|
|
(defcustom vc-command-messages nil
|
|
|
|
|
"If non-nil, display run messages from back-end commands."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'vc)
|
|
|
|
|
|
2008-05-06 01:41:34 +00:00
|
|
|
|
(defcustom vc-suppress-confirm nil
|
|
|
|
|
"If non-nil, treat user as expert; suppress yes-no prompts on some things."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'vc)
|
|
|
|
|
|
2008-05-03 09:45:20 +00:00
|
|
|
|
;; Variables the user doesn't need to know about.
|
2008-05-03 10:18:08 +00:00
|
|
|
|
|
2008-05-03 09:45:20 +00:00
|
|
|
|
(defvar vc-log-operation nil)
|
|
|
|
|
(defvar vc-log-after-operation-hook nil)
|
|
|
|
|
(defvar vc-log-fileset)
|
|
|
|
|
|
|
|
|
|
;; In a log entry buffer, this is a local variable
|
|
|
|
|
;; that points to the buffer for which it was made
|
2008-05-15 14:32:49 +00:00
|
|
|
|
;; (either a file, or a directory buffer).
|
2008-05-03 09:45:20 +00:00
|
|
|
|
(defvar vc-parent-buffer nil)
|
|
|
|
|
(put 'vc-parent-buffer 'permanent-local t)
|
|
|
|
|
(defvar vc-parent-buffer-name nil)
|
|
|
|
|
(put 'vc-parent-buffer-name 'permanent-local t)
|
|
|
|
|
|
2008-05-03 07:06:34 +00:00
|
|
|
|
;; Common command execution logic
|
|
|
|
|
|
|
|
|
|
(defun vc-process-filter (p s)
|
|
|
|
|
"An alternative output filter for async process P.
|
|
|
|
|
One difference with the default filter is that this inserts S after markers.
|
|
|
|
|
Another is that undo information is not kept."
|
|
|
|
|
(let ((buffer (process-buffer p)))
|
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((buffer-undo-list t)
|
|
|
|
|
(inhibit-read-only t))
|
|
|
|
|
(goto-char (process-mark p))
|
|
|
|
|
(insert s)
|
|
|
|
|
(set-marker (process-mark p) (point))))))))
|
|
|
|
|
|
2008-05-03 07:39:17 +00:00
|
|
|
|
(defun vc-setup-buffer (buf)
|
|
|
|
|
"Prepare BUF for executing a slave command and make it current."
|
2008-05-03 07:06:34 +00:00
|
|
|
|
(let ((camefrom (current-buffer))
|
|
|
|
|
(olddir default-directory))
|
|
|
|
|
(set-buffer (get-buffer-create buf))
|
|
|
|
|
(kill-all-local-variables)
|
|
|
|
|
(set (make-local-variable 'vc-parent-buffer) camefrom)
|
|
|
|
|
(set (make-local-variable 'vc-parent-buffer-name)
|
|
|
|
|
(concat " from " (buffer-name camefrom)))
|
|
|
|
|
(setq default-directory olddir)
|
|
|
|
|
(let ((buffer-undo-list t)
|
|
|
|
|
(inhibit-read-only t))
|
|
|
|
|
(erase-buffer))))
|
|
|
|
|
|
|
|
|
|
(defvar vc-sentinel-movepoint) ;Dynamically scoped.
|
|
|
|
|
|
|
|
|
|
(defun vc-process-sentinel (p s)
|
|
|
|
|
(let ((previous (process-get p 'vc-previous-sentinel))
|
|
|
|
|
(buf (process-buffer p)))
|
|
|
|
|
;; Impatient users sometime kill "slow" buffers; check liveness
|
|
|
|
|
;; to avoid "error in process sentinel: Selecting deleted buffer".
|
|
|
|
|
(when (buffer-live-p buf)
|
|
|
|
|
(when previous (funcall previous p s))
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(setq mode-line-process
|
|
|
|
|
(let ((status (process-status p)))
|
|
|
|
|
;; Leave mode-line uncluttered, normally.
|
|
|
|
|
(unless (eq 'exit status)
|
|
|
|
|
(format " (%s)" status))))
|
|
|
|
|
(let (vc-sentinel-movepoint)
|
|
|
|
|
;; Normally, we want async code such as sentinels to not move point.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (process-mark p))
|
|
|
|
|
(let ((cmds (process-get p 'vc-sentinel-commands)))
|
|
|
|
|
(process-put p 'vc-sentinel-commands nil)
|
|
|
|
|
(dolist (cmd cmds)
|
|
|
|
|
;; Each sentinel may move point and the next one should be run
|
|
|
|
|
;; at that new point. We could get the same result by having
|
|
|
|
|
;; each sentinel read&set process-mark, but since `cmd' needs
|
|
|
|
|
;; to work both for async and sync processes, this would be
|
|
|
|
|
;; difficult to achieve.
|
|
|
|
|
(vc-exec-after cmd))))
|
|
|
|
|
;; But sometimes the sentinels really want to move point.
|
|
|
|
|
(when vc-sentinel-movepoint
|
|
|
|
|
(let ((win (get-buffer-window (current-buffer) 0)))
|
|
|
|
|
(if (not win)
|
|
|
|
|
(goto-char vc-sentinel-movepoint)
|
|
|
|
|
(with-selected-window win
|
|
|
|
|
(goto-char vc-sentinel-movepoint))))))))))
|
|
|
|
|
|
|
|
|
|
(defun vc-set-mode-line-busy-indicator ()
|
|
|
|
|
(setq mode-line-process
|
|
|
|
|
(concat " " (propertize "[waiting...]"
|
|
|
|
|
'face 'mode-line-emphasis
|
|
|
|
|
'help-echo
|
2008-05-15 14:32:49 +00:00
|
|
|
|
"A command is in progress in this buffer"))))
|
2008-05-03 07:06:34 +00:00
|
|
|
|
|
|
|
|
|
(defun vc-exec-after (code)
|
|
|
|
|
"Eval CODE when the current buffer's process is done.
|
|
|
|
|
If the current buffer has no process, just evaluate CODE.
|
|
|
|
|
Else, add CODE to the process' sentinel."
|
|
|
|
|
(let ((proc (get-buffer-process (current-buffer))))
|
|
|
|
|
(cond
|
|
|
|
|
;; If there's no background process, just execute the code.
|
|
|
|
|
;; We used to explicitly call delete-process on exited processes,
|
|
|
|
|
;; but this led to timing problems causing process output to be
|
|
|
|
|
;; lost. Terminated processes get deleted automatically
|
|
|
|
|
;; anyway. -- cyd
|
|
|
|
|
((or (null proc) (eq (process-status proc) 'exit))
|
|
|
|
|
;; Make sure we've read the process's output before going further.
|
|
|
|
|
(when proc (accept-process-output proc))
|
|
|
|
|
(eval code))
|
|
|
|
|
;; If a process is running, add CODE to the sentinel
|
|
|
|
|
((eq (process-status proc) 'run)
|
|
|
|
|
(vc-set-mode-line-busy-indicator)
|
|
|
|
|
(let ((previous (process-sentinel proc)))
|
|
|
|
|
(unless (eq previous 'vc-process-sentinel)
|
|
|
|
|
(process-put proc 'vc-previous-sentinel previous))
|
|
|
|
|
(set-process-sentinel proc 'vc-process-sentinel))
|
|
|
|
|
(process-put proc 'vc-sentinel-commands
|
|
|
|
|
;; We keep the code fragments in the order given
|
|
|
|
|
;; so that vc-diff-finish's message shows up in
|
|
|
|
|
;; the presence of non-nil vc-command-messages.
|
|
|
|
|
(append (process-get proc 'vc-sentinel-commands)
|
|
|
|
|
(list code))))
|
|
|
|
|
(t (error "Unexpected process state"))))
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
(defvar vc-post-command-functions nil
|
|
|
|
|
"Hook run at the end of `vc-do-command'.
|
|
|
|
|
Each function is called inside the buffer in which the command was run
|
|
|
|
|
and is passed 3 arguments: the COMMAND, the FILES and the FLAGS.")
|
|
|
|
|
|
|
|
|
|
(defvar w32-quote-process-args)
|
|
|
|
|
|
|
|
|
|
(defun vc-delistify (filelist)
|
|
|
|
|
"Smash a FILELIST into a file list string suitable for info messages."
|
|
|
|
|
;; FIXME what about file names with spaces?
|
|
|
|
|
(if (not filelist) "." (mapconcat 'identity filelist " ")))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun vc-do-command (buffer okstatus command file-or-list &rest flags)
|
2008-05-09 18:59:45 +00:00
|
|
|
|
"Execute a slave command, notifying user and checking for errors.
|
2008-05-10 13:27:16 +00:00
|
|
|
|
Output from COMMAND goes to BUFFER, or the current buffer if
|
|
|
|
|
BUFFER is t. If the destination buffer is not already current,
|
|
|
|
|
set it up properly and erase it. The command is considered
|
|
|
|
|
successful if its exit status does not exceed OKSTATUS (if
|
|
|
|
|
OKSTATUS is nil, that means to ignore error status, if it is
|
|
|
|
|
`async', that means not to wait for termination of the
|
|
|
|
|
subprocess; if it is t it means to ignore all execution errors).
|
|
|
|
|
FILE-OR-LIST is the name of a working file; it may be a list of
|
|
|
|
|
files or be nil (to execute commands that don't expect a file
|
|
|
|
|
name or set of files). If an optional list of FLAGS is present,
|
2009-09-20 19:55:36 +00:00
|
|
|
|
that is inserted into the command line before the filename.
|
|
|
|
|
Return the return value of the slave command in the synchronous
|
|
|
|
|
case, and the process object in the asynchronous case."
|
2008-05-03 07:06:34 +00:00
|
|
|
|
;; FIXME: file-relative-name can return a bogus result because
|
|
|
|
|
;; it doesn't look at the actual file-system to see if symlinks
|
|
|
|
|
;; come into play.
|
|
|
|
|
(let* ((files
|
|
|
|
|
(mapcar (lambda (f) (file-relative-name (expand-file-name f)))
|
|
|
|
|
(if (listp file-or-list) file-or-list (list file-or-list))))
|
|
|
|
|
(full-command
|
|
|
|
|
;; What we're doing here is preparing a version of the command
|
2008-05-17 22:55:57 +00:00
|
|
|
|
;; for display in a debug-progress message. If it's fewer than
|
2008-05-03 07:06:34 +00:00
|
|
|
|
;; 20 characters display the entire command (without trailing
|
|
|
|
|
;; newline). Otherwise display the first 20 followed by an ellipsis.
|
|
|
|
|
(concat (if (string= (substring command -1) "\n")
|
|
|
|
|
(substring command 0 -1)
|
|
|
|
|
command)
|
|
|
|
|
" "
|
|
|
|
|
(vc-delistify (mapcar (lambda (s) (if (> (length s) 20) (concat (substring s 0 2) "...") s)) flags))
|
|
|
|
|
" " (vc-delistify files))))
|
|
|
|
|
(save-current-buffer
|
|
|
|
|
(unless (or (eq buffer t)
|
|
|
|
|
(and (stringp buffer)
|
|
|
|
|
(string= (buffer-name) buffer))
|
|
|
|
|
(eq buffer (current-buffer)))
|
2008-05-10 13:27:16 +00:00
|
|
|
|
(vc-setup-buffer buffer))
|
2008-05-03 07:06:34 +00:00
|
|
|
|
;; If there's some previous async process still running, just kill it.
|
|
|
|
|
(let ((oldproc (get-buffer-process (current-buffer))))
|
|
|
|
|
;; If we wanted to wait for oldproc to finish before doing
|
|
|
|
|
;; something, we'd have used vc-eval-after.
|
|
|
|
|
;; Use `delete-process' rather than `kill-process' because we don't
|
|
|
|
|
;; want any of its output to appear from now on.
|
2009-09-20 19:55:36 +00:00
|
|
|
|
(when oldproc (delete-process oldproc)))
|
2008-05-03 07:06:34 +00:00
|
|
|
|
(let ((squeezed (remq nil flags))
|
|
|
|
|
(inhibit-read-only t)
|
|
|
|
|
(status 0))
|
|
|
|
|
(when files
|
|
|
|
|
(setq squeezed (nconc squeezed files)))
|
2010-03-19 14:19:54 +00:00
|
|
|
|
(let (;; Since some functions need to parse the output
|
2010-01-16 21:37:46 +00:00
|
|
|
|
;; from external commands, set LC_MESSAGES to C.
|
2010-03-19 14:19:54 +00:00
|
|
|
|
(process-environment (cons "LC_MESSAGES=C" process-environment))
|
2008-05-03 07:06:34 +00:00
|
|
|
|
(w32-quote-process-args t))
|
|
|
|
|
(if (eq okstatus 'async)
|
|
|
|
|
;; Run asynchronously.
|
|
|
|
|
(let ((proc
|
|
|
|
|
(let ((process-connection-type nil))
|
|
|
|
|
(apply 'start-file-process command (current-buffer)
|
|
|
|
|
command squeezed))))
|
2009-09-20 19:55:36 +00:00
|
|
|
|
(when vc-command-messages
|
|
|
|
|
(message "Running %s in background..." full-command))
|
2008-05-03 07:06:34 +00:00
|
|
|
|
;;(set-process-sentinel proc (lambda (p msg) (delete-process p)))
|
|
|
|
|
(set-process-filter proc 'vc-process-filter)
|
2009-09-20 19:55:36 +00:00
|
|
|
|
(setq status proc)
|
|
|
|
|
(when vc-command-messages
|
|
|
|
|
(vc-exec-after
|
|
|
|
|
`(message "Running %s in background... done" ',full-command))))
|
2008-05-17 22:55:57 +00:00
|
|
|
|
;; Run synchronously
|
2008-05-03 07:06:34 +00:00
|
|
|
|
(when vc-command-messages
|
|
|
|
|
(message "Running %s in foreground..." full-command))
|
|
|
|
|
(let ((buffer-undo-list t))
|
|
|
|
|
(setq status (apply 'process-file command nil t nil squeezed)))
|
|
|
|
|
(when (and (not (eq t okstatus))
|
|
|
|
|
(or (not (integerp status))
|
|
|
|
|
(and okstatus (< okstatus status))))
|
|
|
|
|
(unless (eq ?\s (aref (buffer-name (current-buffer)) 0))
|
|
|
|
|
(pop-to-buffer (current-buffer))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(shrink-window-if-larger-than-buffer))
|
|
|
|
|
(error "Running %s...FAILED (%s)" full-command
|
2009-09-20 19:55:36 +00:00
|
|
|
|
(if (integerp status) (format "status %d" status) status)))
|
|
|
|
|
(when vc-command-messages
|
|
|
|
|
(message "Running %s...OK = %d" full-command status))))
|
2008-05-03 07:06:34 +00:00
|
|
|
|
(vc-exec-after
|
|
|
|
|
`(run-hook-with-args 'vc-post-command-functions
|
|
|
|
|
',command ',file-or-list ',flags))
|
|
|
|
|
status))))
|
|
|
|
|
|
2011-01-28 23:10:55 +00:00
|
|
|
|
(defun vc-do-async-command (buffer root command &rest args)
|
|
|
|
|
"Run COMMAND asynchronously with ARGS, displaying the result.
|
|
|
|
|
Send the output to BUFFER, which should be a buffer or the name
|
|
|
|
|
of a buffer, which is created.
|
|
|
|
|
ROOT should be the directory in which the command should be run.
|
|
|
|
|
Display the buffer in some window, but don't select it."
|
|
|
|
|
(let* ((dir default-directory)
|
2011-02-19 21:23:51 +00:00
|
|
|
|
(inhibit-read-only t)
|
2011-01-28 23:10:55 +00:00
|
|
|
|
window new-window-start)
|
|
|
|
|
(setq buffer (get-buffer-create buffer))
|
|
|
|
|
(if (get-buffer-process buffer)
|
|
|
|
|
(error "Another VC action on %s is running" root))
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(setq default-directory root)
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(unless (eq (point) (point-min))
|
|
|
|
|
(insert "\n"))
|
|
|
|
|
(setq new-window-start (point))
|
2011-01-29 03:12:32 +00:00
|
|
|
|
(insert "Running \"" command)
|
2011-01-28 23:10:55 +00:00
|
|
|
|
(dolist (arg args)
|
|
|
|
|
(insert " " arg))
|
|
|
|
|
(insert "\"...\n")
|
|
|
|
|
;; Run in the original working directory.
|
|
|
|
|
(let ((default-directory dir))
|
|
|
|
|
(apply 'vc-do-command t 'async command nil args)))
|
|
|
|
|
(setq window (display-buffer buffer))
|
|
|
|
|
(if window
|
2011-01-29 21:19:21 +00:00
|
|
|
|
(set-window-start window new-window-start))
|
|
|
|
|
buffer))
|
|
|
|
|
|
|
|
|
|
(defun vc-set-async-update (process-buffer)
|
|
|
|
|
"Set a `vc-exec-after' action appropriate to the current buffer.
|
|
|
|
|
This action will update the current buffer after the current
|
|
|
|
|
asynchronous VC command has completed. PROCESS-BUFFER is the
|
|
|
|
|
buffer for the asynchronous VC process.
|
|
|
|
|
|
|
|
|
|
If the current buffer is a VC Dir buffer, call `vc-dir-refresh'.
|
|
|
|
|
If the current buffer is a Dired buffer, revert it."
|
|
|
|
|
(let* ((buf (current-buffer))
|
|
|
|
|
(tick (buffer-modified-tick buf)))
|
|
|
|
|
(cond
|
|
|
|
|
((derived-mode-p 'vc-dir-mode)
|
|
|
|
|
(with-current-buffer process-buffer
|
|
|
|
|
(vc-exec-after
|
|
|
|
|
`(if (buffer-live-p ,buf)
|
|
|
|
|
(with-current-buffer ,buf
|
|
|
|
|
(vc-dir-refresh))))))
|
|
|
|
|
((derived-mode-p 'dired-mode)
|
|
|
|
|
(with-current-buffer process-buffer
|
|
|
|
|
(vc-exec-after
|
|
|
|
|
`(and (buffer-live-p ,buf)
|
|
|
|
|
(= (buffer-modified-tick ,buf) ,tick)
|
|
|
|
|
(with-current-buffer ,buf
|
|
|
|
|
(revert-buffer)))))))))
|
2011-01-28 23:10:55 +00:00
|
|
|
|
|
2008-05-03 10:18:08 +00:00
|
|
|
|
;; These functions are used to ensure that the view the user sees is up to date
|
2008-05-17 22:55:57 +00:00
|
|
|
|
;; even if the dispatcher client mode has messed with file contents (as in,
|
2008-05-03 10:18:08 +00:00
|
|
|
|
;; for example, VCS keyword expansion).
|
|
|
|
|
|
|
|
|
|
(declare-function view-mode-exit "view" (&optional return-to-alist exit-action all-win))
|
|
|
|
|
|
|
|
|
|
(defun vc-position-context (posn)
|
|
|
|
|
"Save a bit of the text around POSN in the current buffer.
|
|
|
|
|
Used to help us find the corresponding position again later
|
|
|
|
|
if markers are destroyed or corrupted."
|
|
|
|
|
;; A lot of this was shamelessly lifted from Sebastian Kremer's
|
|
|
|
|
;; rcs.el mode.
|
|
|
|
|
(list posn
|
|
|
|
|
(buffer-size)
|
|
|
|
|
(buffer-substring posn
|
|
|
|
|
(min (point-max) (+ posn 100)))))
|
|
|
|
|
|
|
|
|
|
(defun vc-find-position-by-context (context)
|
|
|
|
|
"Return the position of CONTEXT in the current buffer.
|
|
|
|
|
If CONTEXT cannot be found, return nil."
|
|
|
|
|
(let ((context-string (nth 2 context)))
|
|
|
|
|
(if (equal "" context-string)
|
|
|
|
|
(point-max)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((diff (- (nth 1 context) (buffer-size))))
|
|
|
|
|
(when (< diff 0) (setq diff (- diff)))
|
|
|
|
|
(goto-char (nth 0 context))
|
|
|
|
|
(if (or (search-forward context-string nil t)
|
|
|
|
|
;; Can't use search-backward since the match may continue
|
|
|
|
|
;; after point.
|
|
|
|
|
(progn (goto-char (- (point) diff (length context-string)))
|
|
|
|
|
;; goto-char doesn't signal an error at
|
|
|
|
|
;; beginning of buffer like backward-char would
|
|
|
|
|
(search-forward context-string nil t)))
|
|
|
|
|
;; to beginning of OSTRING
|
|
|
|
|
(- (point) (length context-string))))))))
|
|
|
|
|
|
|
|
|
|
(defun vc-context-matches-p (posn context)
|
|
|
|
|
"Return t if POSN matches CONTEXT, nil otherwise."
|
|
|
|
|
(let* ((context-string (nth 2 context))
|
|
|
|
|
(len (length context-string))
|
|
|
|
|
(end (+ posn len)))
|
|
|
|
|
(if (> end (1+ (buffer-size)))
|
|
|
|
|
nil
|
|
|
|
|
(string= context-string (buffer-substring posn end)))))
|
|
|
|
|
|
|
|
|
|
(defun vc-buffer-context ()
|
|
|
|
|
"Return a list (POINT-CONTEXT MARK-CONTEXT REPARSE).
|
|
|
|
|
Used by `vc-restore-buffer-context' to later restore the context."
|
|
|
|
|
(let ((point-context (vc-position-context (point)))
|
|
|
|
|
;; Use mark-marker to avoid confusion in transient-mark-mode.
|
2008-05-07 18:18:04 +00:00
|
|
|
|
(mark-context (when (eq (marker-buffer (mark-marker)) (current-buffer))
|
2008-05-03 10:18:08 +00:00
|
|
|
|
(vc-position-context (mark-marker))))
|
|
|
|
|
;; Make the right thing happen in transient-mark-mode.
|
2008-05-07 18:18:04 +00:00
|
|
|
|
(mark-active nil))
|
|
|
|
|
(list point-context mark-context nil)))
|
2008-05-03 10:18:08 +00:00
|
|
|
|
|
|
|
|
|
(defun vc-restore-buffer-context (context)
|
|
|
|
|
"Restore point/mark, and reparse any affected compilation buffers.
|
|
|
|
|
CONTEXT is that which `vc-buffer-context' returns."
|
|
|
|
|
(let ((point-context (nth 0 context))
|
2008-05-07 18:18:04 +00:00
|
|
|
|
(mark-context (nth 1 context)))
|
2008-05-03 10:18:08 +00:00
|
|
|
|
;; if necessary, restore point and mark
|
|
|
|
|
(if (not (vc-context-matches-p (point) point-context))
|
|
|
|
|
(let ((new-point (vc-find-position-by-context point-context)))
|
|
|
|
|
(when new-point (goto-char new-point))))
|
|
|
|
|
(and mark-active
|
|
|
|
|
mark-context
|
|
|
|
|
(not (vc-context-matches-p (mark) mark-context))
|
|
|
|
|
(let ((new-mark (vc-find-position-by-context mark-context)))
|
|
|
|
|
(when new-mark (set-mark new-mark))))))
|
|
|
|
|
|
|
|
|
|
(defun vc-revert-buffer-internal (&optional arg no-confirm)
|
|
|
|
|
"Revert buffer, keeping point and mark where user expects them.
|
|
|
|
|
Try to be clever in the face of changes due to expanded version-control
|
|
|
|
|
key words. This is important for typeahead to work as expected.
|
|
|
|
|
ARG and NO-CONFIRM are passed on to `revert-buffer'."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(widen)
|
|
|
|
|
(let ((context (vc-buffer-context)))
|
|
|
|
|
;; Use save-excursion here, because it may be able to restore point
|
|
|
|
|
;; and mark properly even in cases where vc-restore-buffer-context
|
|
|
|
|
;; would fail. However, save-excursion might also get it wrong --
|
|
|
|
|
;; in this case, vc-restore-buffer-context gives it a second try.
|
|
|
|
|
(save-excursion
|
|
|
|
|
;; t means don't call normal-mode;
|
|
|
|
|
;; that's to preserve various minor modes.
|
|
|
|
|
(revert-buffer arg no-confirm t))
|
|
|
|
|
(vc-restore-buffer-context context)))
|
|
|
|
|
|
2010-06-09 01:12:53 +00:00
|
|
|
|
(defvar vc-mode-line-hook nil)
|
|
|
|
|
(make-variable-buffer-local 'vc-mode-line-hook)
|
|
|
|
|
(put 'vc-mode-line-hook 'permanent-local t)
|
|
|
|
|
|
2010-06-09 06:48:29 +00:00
|
|
|
|
(defun vc-resynch-window (file &optional keep noquery reset-vc-info)
|
2008-05-03 10:18:08 +00:00
|
|
|
|
"If FILE is in the current buffer, either revert or unvisit it.
|
|
|
|
|
The choice between revert (to see expanded keywords) and unvisit
|
|
|
|
|
depends on KEEP. NOQUERY if non-nil inhibits confirmation for
|
|
|
|
|
reverting. NOQUERY should be t *only* if it is known the only
|
|
|
|
|
difference between the buffer and the file is due to
|
|
|
|
|
modifications by the dispatcher client code, rather than user
|
|
|
|
|
editing!"
|
|
|
|
|
(and (string= buffer-file-name file)
|
|
|
|
|
(if keep
|
2009-10-01 03:32:25 +00:00
|
|
|
|
(when (file-exists-p file)
|
2010-06-09 06:48:29 +00:00
|
|
|
|
(when reset-vc-info
|
|
|
|
|
(vc-file-clearprops file))
|
2008-05-03 10:18:08 +00:00
|
|
|
|
(vc-revert-buffer-internal t noquery)
|
2009-08-07 08:24:29 +00:00
|
|
|
|
|
|
|
|
|
;; VC operations might toggle the read-only state. In
|
|
|
|
|
;; that case we need to adjust the `view-mode' status
|
|
|
|
|
;; when `view-read-only' is non-nil.
|
2008-05-03 10:18:08 +00:00
|
|
|
|
(and view-read-only
|
|
|
|
|
(if (file-writable-p file)
|
|
|
|
|
(and view-mode
|
|
|
|
|
(let ((view-old-buffer-read-only nil))
|
|
|
|
|
(view-mode-exit)))
|
|
|
|
|
(and (not view-mode)
|
|
|
|
|
(not (eq (get major-mode 'mode-class) 'special))
|
|
|
|
|
(view-mode-enter))))
|
2009-08-07 08:24:29 +00:00
|
|
|
|
|
2010-06-09 01:12:53 +00:00
|
|
|
|
;; FIXME: Why use a hook? Why pass it buffer-file-name?
|
|
|
|
|
(run-hook-with-args 'vc-mode-line-hook buffer-file-name))
|
2008-05-03 10:18:08 +00:00
|
|
|
|
(kill-buffer (current-buffer)))))
|
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(declare-function vc-dir-resynch-file "vc-dir" (&optional fname))
|
2008-07-05 18:09:32 +00:00
|
|
|
|
(declare-function vc-string-prefix-p "vc" (prefix string))
|
|
|
|
|
|
2010-06-09 06:48:29 +00:00
|
|
|
|
(defun vc-resynch-buffers-in-directory (directory &optional keep noquery reset-vc-info)
|
2008-07-05 18:09:32 +00:00
|
|
|
|
"Resync all buffers that visit files in DIRECTORY."
|
|
|
|
|
(dolist (buffer (buffer-list))
|
|
|
|
|
(let ((fname (buffer-file-name buffer)))
|
|
|
|
|
(when (and fname (vc-string-prefix-p directory fname))
|
2009-07-24 05:41:17 +00:00
|
|
|
|
(with-current-buffer buffer
|
2010-06-09 06:48:29 +00:00
|
|
|
|
(vc-resynch-buffer fname keep noquery reset-vc-info))))))
|
2008-06-22 19:04:22 +00:00
|
|
|
|
|
2010-06-09 06:48:29 +00:00
|
|
|
|
(defun vc-resynch-buffer (file &optional keep noquery reset-vc-info)
|
2008-05-03 10:18:08 +00:00
|
|
|
|
"If FILE is currently visited, resynch its buffer."
|
|
|
|
|
(if (string= buffer-file-name file)
|
2010-06-09 06:48:29 +00:00
|
|
|
|
(vc-resynch-window file keep noquery reset-vc-info)
|
2008-07-05 18:09:32 +00:00
|
|
|
|
(if (file-directory-p file)
|
2010-06-09 06:48:29 +00:00
|
|
|
|
(vc-resynch-buffers-in-directory file keep noquery reset-vc-info)
|
2008-07-05 18:09:32 +00:00
|
|
|
|
(let ((buffer (get-file-buffer file)))
|
|
|
|
|
(when buffer
|
|
|
|
|
(with-current-buffer buffer
|
2010-06-09 06:48:29 +00:00
|
|
|
|
(vc-resynch-window file keep noquery reset-vc-info))))))
|
2008-05-27 05:36:03 +00:00
|
|
|
|
;; Try to avoid unnecessary work, a *vc-dir* buffer is only present
|
|
|
|
|
;; if this is true.
|
2009-10-01 03:32:25 +00:00
|
|
|
|
(when vc-dir-buffers
|
2008-05-27 05:36:03 +00:00
|
|
|
|
(vc-dir-resynch-file file)))
|
2008-05-03 10:18:08 +00:00
|
|
|
|
|
2008-05-11 14:49:39 +00:00
|
|
|
|
(defun vc-buffer-sync (&optional not-urgent)
|
|
|
|
|
"Make sure the current buffer and its working file are in sync.
|
|
|
|
|
NOT-URGENT means it is ok to continue if the user says not to save."
|
|
|
|
|
(when (buffer-modified-p)
|
|
|
|
|
(if (or vc-suppress-confirm
|
|
|
|
|
(y-or-n-p (format "Buffer %s modified; save it? " (buffer-name))))
|
|
|
|
|
(save-buffer)
|
|
|
|
|
(unless not-urgent
|
|
|
|
|
(error "Aborted")))))
|
|
|
|
|
|
2008-05-03 09:45:20 +00:00
|
|
|
|
;; Command closures
|
|
|
|
|
|
2008-05-11 14:49:39 +00:00
|
|
|
|
;; Set up key bindings for use while editing log messages
|
|
|
|
|
|
2010-03-19 09:37:41 +00:00
|
|
|
|
(defun vc-log-edit (fileset mode)
|
2008-05-15 14:32:49 +00:00
|
|
|
|
"Set up `log-edit' for use on FILE."
|
2008-05-11 14:49:39 +00:00
|
|
|
|
(setq default-directory
|
|
|
|
|
(with-current-buffer vc-parent-buffer default-directory))
|
|
|
|
|
(log-edit 'vc-finish-logentry
|
|
|
|
|
nil
|
2010-04-21 02:05:24 +00:00
|
|
|
|
`((log-edit-listfun . (lambda ()
|
|
|
|
|
;; FIXME: Should expand the list
|
|
|
|
|
;; for directories.
|
|
|
|
|
(mapcar 'file-relative-name
|
|
|
|
|
',fileset)))
|
2010-03-19 09:37:41 +00:00
|
|
|
|
(log-edit-diff-function . (lambda () (vc-diff nil))))
|
|
|
|
|
nil
|
|
|
|
|
mode)
|
2008-05-11 14:49:39 +00:00
|
|
|
|
(set (make-local-variable 'vc-log-fileset) fileset)
|
|
|
|
|
(set-buffer-modified-p nil)
|
|
|
|
|
(setq buffer-file-name nil))
|
|
|
|
|
|
2010-04-21 02:05:24 +00:00
|
|
|
|
(defun vc-start-logentry (files comment initial-contents msg logbuf mode action &optional after-hook)
|
|
|
|
|
"Accept a comment for an operation on FILES.
|
2008-05-15 15:01:29 +00:00
|
|
|
|
If COMMENT is nil, pop up a LOGBUF buffer, emit MSG, and set the
|
2008-05-03 09:45:20 +00:00
|
|
|
|
action on close to ACTION. If COMMENT is a string and
|
|
|
|
|
INITIAL-CONTENTS is non-nil, then COMMENT is used as the initial
|
|
|
|
|
contents of the log entry buffer. If COMMENT is a string and
|
|
|
|
|
INITIAL-CONTENTS is nil, do action immediately as if the user had
|
|
|
|
|
entered COMMENT. If COMMENT is t, also do action immediately with an
|
|
|
|
|
empty comment. Remember the file's buffer in `vc-parent-buffer'
|
2010-03-24 03:30:53 +00:00
|
|
|
|
\(current one if no file). Puts the log-entry buffer in major-mode
|
|
|
|
|
MODE, defaulting to `log-edit-mode' if MODE is nil.
|
|
|
|
|
AFTER-HOOK specifies the local value for `vc-log-after-operation-hook'."
|
2008-05-03 09:45:20 +00:00
|
|
|
|
(let ((parent
|
2008-05-07 21:27:41 +00:00
|
|
|
|
(if (vc-dispatcher-browsing)
|
|
|
|
|
;; If we are called from a directory browser, the parent buffer is
|
2008-05-03 09:45:20 +00:00
|
|
|
|
;; the current buffer.
|
|
|
|
|
(current-buffer)
|
|
|
|
|
(if (and files (equal (length files) 1))
|
|
|
|
|
(get-file-buffer (car files))
|
|
|
|
|
(current-buffer)))))
|
|
|
|
|
(if (and comment (not initial-contents))
|
2008-05-15 15:01:29 +00:00
|
|
|
|
(set-buffer (get-buffer-create logbuf))
|
|
|
|
|
(pop-to-buffer (get-buffer-create logbuf)))
|
2008-05-03 09:45:20 +00:00
|
|
|
|
(set (make-local-variable 'vc-parent-buffer) parent)
|
|
|
|
|
(set (make-local-variable 'vc-parent-buffer-name)
|
|
|
|
|
(concat " from " (buffer-name vc-parent-buffer)))
|
2010-03-19 09:37:41 +00:00
|
|
|
|
(vc-log-edit files mode)
|
2008-05-03 09:45:20 +00:00
|
|
|
|
(make-local-variable 'vc-log-after-operation-hook)
|
|
|
|
|
(when after-hook
|
|
|
|
|
(setq vc-log-after-operation-hook after-hook))
|
|
|
|
|
(setq vc-log-operation action)
|
|
|
|
|
(when comment
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(when (stringp comment) (insert comment)))
|
|
|
|
|
(if (or (not comment) initial-contents)
|
|
|
|
|
(message "%s Type C-c C-c when done" msg)
|
|
|
|
|
(vc-finish-logentry (eq comment t)))))
|
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
(declare-function vc-dir-move-to-goal-column "vc-dir" ())
|
2010-04-21 02:05:24 +00:00
|
|
|
|
;; vc-finish-logentry is typically called from a log-edit buffer (see
|
|
|
|
|
;; vc-start-logentry).
|
2008-05-03 09:45:20 +00:00
|
|
|
|
(defun vc-finish-logentry (&optional nocomment)
|
|
|
|
|
"Complete the operation implied by the current log entry.
|
|
|
|
|
Use the contents of the current buffer as a check-in or registration
|
|
|
|
|
comment. If the optional arg NOCOMMENT is non-nil, then don't check
|
|
|
|
|
the buffer contents as a comment."
|
|
|
|
|
(interactive)
|
|
|
|
|
;; Check and record the comment, if any.
|
|
|
|
|
(unless nocomment
|
|
|
|
|
(run-hooks 'vc-logentry-check-hook))
|
|
|
|
|
;; Sync parent buffer in case the user modified it while editing the comment.
|
2008-05-27 05:36:03 +00:00
|
|
|
|
;; But not if it is a vc-dir buffer.
|
2008-05-03 09:45:20 +00:00
|
|
|
|
(with-current-buffer vc-parent-buffer
|
2008-05-07 21:27:41 +00:00
|
|
|
|
(or (vc-dispatcher-browsing) (vc-buffer-sync)))
|
2008-05-03 09:45:20 +00:00
|
|
|
|
(unless vc-log-operation
|
|
|
|
|
(error "No log operation is pending"))
|
2010-03-19 09:37:41 +00:00
|
|
|
|
|
2008-05-03 09:45:20 +00:00
|
|
|
|
;; save the parameters held in buffer-local variables
|
2008-05-15 15:01:29 +00:00
|
|
|
|
(let ((logbuf (current-buffer))
|
|
|
|
|
(log-operation vc-log-operation)
|
2010-04-21 02:05:24 +00:00
|
|
|
|
;; FIXME: When coming from VC-Dir, we should check that the
|
|
|
|
|
;; set of selected files is still equal to vc-log-fileset,
|
|
|
|
|
;; to avoid surprises.
|
2008-05-03 09:45:20 +00:00
|
|
|
|
(log-fileset vc-log-fileset)
|
|
|
|
|
(log-entry (buffer-string))
|
2010-04-20 16:52:43 +00:00
|
|
|
|
(after-hook vc-log-after-operation-hook))
|
2008-05-03 09:45:20 +00:00
|
|
|
|
(pop-to-buffer vc-parent-buffer)
|
|
|
|
|
;; OK, do it to it
|
|
|
|
|
(save-excursion
|
|
|
|
|
(funcall log-operation
|
|
|
|
|
log-fileset
|
2010-04-21 02:05:24 +00:00
|
|
|
|
log-entry))
|
2008-05-03 09:45:20 +00:00
|
|
|
|
;; Remove checkin window (after the checkin so that if that fails
|
2008-05-15 15:02:57 +00:00
|
|
|
|
;; we don't zap the log buffer and the typing therein).
|
2008-05-03 09:45:20 +00:00
|
|
|
|
;; -- IMO this should be replaced with quit-window
|
2008-05-15 15:01:29 +00:00
|
|
|
|
(cond ((and logbuf vc-delete-logbuf-window)
|
|
|
|
|
(delete-windows-on logbuf (selected-frame))
|
|
|
|
|
;; Kill buffer and delete any other dedicated windows/frames.
|
|
|
|
|
(kill-buffer logbuf))
|
2010-04-20 16:52:43 +00:00
|
|
|
|
(logbuf
|
|
|
|
|
(with-selected-window (or (get-buffer-window logbuf 0)
|
|
|
|
|
(selected-window))
|
|
|
|
|
(with-current-buffer logbuf
|
|
|
|
|
(bury-buffer)))))
|
2008-05-03 09:45:20 +00:00
|
|
|
|
;; Now make sure we see the expanded headers
|
|
|
|
|
(when log-fileset
|
|
|
|
|
(mapc
|
|
|
|
|
(lambda (file) (vc-resynch-buffer file vc-keep-workfiles t))
|
|
|
|
|
log-fileset))
|
2008-05-07 21:27:41 +00:00
|
|
|
|
(when (vc-dispatcher-browsing)
|
2008-05-03 09:45:20 +00:00
|
|
|
|
(vc-dir-move-to-goal-column))
|
|
|
|
|
(run-hooks after-hook 'vc-finish-logentry-hook)))
|
|
|
|
|
|
2008-05-05 22:33:44 +00:00
|
|
|
|
(defun vc-dispatcher-browsing ()
|
|
|
|
|
"Are we in a directory browser buffer?"
|
2008-05-09 15:30:47 +00:00
|
|
|
|
(derived-mode-p 'vc-dir-mode))
|
|
|
|
|
|
2008-06-22 19:04:22 +00:00
|
|
|
|
;; These are unused.
|
|
|
|
|
;; (defun vc-dispatcher-in-fileset-p (fileset)
|
|
|
|
|
;; (let ((member nil))
|
|
|
|
|
;; (while (and (not member) fileset)
|
|
|
|
|
;; (let ((elem (pop fileset)))
|
|
|
|
|
;; (if (if (file-directory-p elem)
|
|
|
|
|
;; (eq t (compare-strings buffer-file-name nil (length elem)
|
|
|
|
|
;; elem nil nil))
|
|
|
|
|
;; (eq (current-buffer) (get-file-buffer elem)))
|
|
|
|
|
;; (setq member t))))
|
|
|
|
|
;; member))
|
|
|
|
|
|
|
|
|
|
;; (defun vc-dispatcher-selection-set (&optional observer)
|
|
|
|
|
;; "Deduce a set of files to which to apply an operation. Return a cons
|
|
|
|
|
;; cell (SELECTION . FILESET), where SELECTION is what the user chose
|
|
|
|
|
;; and FILES is the flist with any directories replaced by the listed files
|
|
|
|
|
;; within them.
|
|
|
|
|
|
|
|
|
|
;; If we're in a directory display, the fileset is the list of marked files (if
|
|
|
|
|
;; there is one) else the file on the current line. If not in a directory
|
|
|
|
|
;; display, but the current buffer visits a file, the fileset is a singleton
|
|
|
|
|
;; containing that file. Otherwise, throw an error."
|
|
|
|
|
;; (let ((selection
|
|
|
|
|
;; (cond
|
|
|
|
|
;; ;; Browsing with vc-dir
|
|
|
|
|
;; ((vc-dispatcher-browsing)
|
|
|
|
|
;; ;; If no files are marked, temporarily mark current file
|
|
|
|
|
;; ;; and choose on that basis (so we get subordinate files)
|
|
|
|
|
;; (if (not (vc-dir-marked-files))
|
|
|
|
|
;; (prog2
|
|
|
|
|
;; (vc-dir-mark-file)
|
|
|
|
|
;; (cons (vc-dir-marked-files) (vc-dir-marked-only-files))
|
|
|
|
|
;; (vc-dir-unmark-all-files t))
|
|
|
|
|
;; (cons (vc-dir-marked-files) (vc-dir-marked-only-files))))
|
|
|
|
|
;; ;; Visiting an eligible file
|
|
|
|
|
;; ((buffer-file-name)
|
|
|
|
|
;; (cons (list buffer-file-name) (list buffer-file-name)))
|
|
|
|
|
;; ;; No eligible file -- if there's a parent buffer, deduce from there
|
|
|
|
|
;; ((and vc-parent-buffer (or (buffer-file-name vc-parent-buffer)
|
|
|
|
|
;; (with-current-buffer vc-parent-buffer
|
|
|
|
|
;; (vc-dispatcher-browsing))))
|
|
|
|
|
;; (with-current-buffer vc-parent-buffer
|
|
|
|
|
;; (vc-dispatcher-selection-set)))
|
|
|
|
|
;; ;; No good set here, throw error
|
|
|
|
|
;; (t (error "No fileset is available here")))))
|
|
|
|
|
;; ;; We assume, in order to avoid unpleasant surprises to the user,
|
|
|
|
|
;; ;; that a fileset is not in good shape to be handed to the user if the
|
|
|
|
|
;; ;; buffers visiting the fileset don't match the on-disk contents.
|
|
|
|
|
;; (unless observer
|
|
|
|
|
;; (save-some-buffers
|
|
|
|
|
;; nil (lambda () (vc-dispatcher-in-fileset-p (cdr selection)))))
|
|
|
|
|
;; selection))
|
2008-05-05 22:33:44 +00:00
|
|
|
|
|
2008-05-10 19:21:30 +00:00
|
|
|
|
(provide 'vc-dispatcher)
|
|
|
|
|
|
2008-05-03 09:28:04 +00:00
|
|
|
|
;;; vc-dispatcher.el ends here
|