summaryrefslogtreecommitdiff
path: root/lisp/vc/vc.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/vc/vc.el')
-rw-r--r--lisp/vc/vc.el78
1 files changed, 55 insertions, 23 deletions
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 35c15f1721d..5e1d27c0ea3 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -356,9 +356,11 @@
;; If LIMIT is true insert only insert LIMIT log entries. If the
;; backend does not support limiting the number of entries to show
;; it should return `limit-unsupported'.
-;; If START-REVISION is given, then show the log starting from the
-;; revision. At this point START-REVISION is only required to work
-;; in conjunction with LIMIT = 1.
+;; If START-REVISION is given, then show the log starting from that
+;; revision ("starting" in the sense of it being the _newest_
+;; revision shown, rather than the working revision, which is normally
+;; the case). Not all backends support this. At present, this is
+;; only ever used with LIMIT = 1 (by vc-annotate-show-log-revision-at-line).
;;
;; * log-outgoing (backend remote-location)
;;
@@ -659,6 +661,10 @@
(eval-when-compile
(require 'dired))
+(declare-function dired-get-filename "dired" (&optional localp noerror))
+(declare-function dired-move-to-filename "dired" (&optional err eol))
+(declare-function dired-marker-regexp "dired" ())
+
(unless (assoc 'vc-parent-buffer minor-mode-alist)
(setq minor-mode-alist
(cons '(vc-parent-buffer vc-parent-buffer-name)
@@ -1072,7 +1078,16 @@ For old-style locking-based version control systems, like RCS:
;; among all the `files'.
(model (nth 4 vc-fileset)))
- ;; Do the right thing
+ ;; If a buffer has unsaved changes, a checkout would discard those
+ ;; changes, so treat the buffer as having unlocked changes.
+ (when (and (not (eq model 'implicit)) (eq state 'up-to-date))
+ (dolist (file files)
+ (let ((buffer (get-file-buffer file)))
+ (and buffer
+ (buffer-modified-p buffer)
+ (setq state 'unlocked-changes)))))
+
+ ;; Do the right thing.
(cond
((eq state 'missing)
(error "Fileset files are missing, so cannot be operated on"))
@@ -1271,12 +1286,10 @@ first backend that could register the file is used."
;; many VCS allow that as well.
(dolist (fname files)
(let ((bname (get-file-buffer fname)))
- (unless fname (setq fname buffer-file-name))
- (when (vc-backend fname)
- (if (vc-registered fname)
- (error "This file is already registered")
- (unless (y-or-n-p "Previous master file has vanished. Make a new one? ")
- (error "Aborted"))))
+ (unless fname
+ (setq fname buffer-file-name))
+ (when (vc-call-backend backend 'registered fname)
+ (error "This file is already registered"))
;; Watch out for new buffers of size 0: the corresponding file
;; does not exist yet, even though buffer-modified-p is nil.
(when bname
@@ -2073,6 +2086,11 @@ Not all VC backends support short logs!")
(defvar log-view-vc-fileset)
(defun vc-print-log-setup-buttons (working-revision is-start-revision limit pl-return)
+ "Insert at the end of the current buffer buttons to show more log entries.
+In the new log, leave point at WORKING-REVISION (if non-nil).
+LIMIT is the number of entries currently shown.
+Does nothing if IS-START-REVISION is non-nil, or if LIMIT is nil,
+or if PL-RETURN is 'limit-unsupported."
(when (and limit (not (eq 'limit-unsupported pl-return))
(not is-start-revision))
(goto-char (point-max))
@@ -2093,6 +2111,14 @@ Not all VC backends support short logs!")
(defun vc-print-log-internal (backend files working-revision
&optional is-start-revision limit)
+ "For specified BACKEND and FILES, show the VC log.
+Leave point at WORKING-REVISION, if it is non-nil.
+If IS-START-REVISION is non-nil, start the log from WORKING-REVISION
+\(not all backends support this); i.e., show only WORKING-REVISION and
+earlier revisions. Show up to LIMIT entries (non-nil means unlimited)."
+ ;; As of 2013/04 the only thing that passes IS-START-REVISION non-nil
+ ;; is vc-annotate-show-log-revision-at-line, which sets LIMIT = 1.
+
;; Don't switch to the output buffer before running the command,
;; so that any buffer-local settings in the vc-controlled
;; buffer can be accessed by the command.
@@ -2178,7 +2204,7 @@ WORKING-REVISION and LIMIT."
(interactive
(cond
(current-prefix-arg
- (let ((rev (read-from-minibuffer "Log from revision (default: last revision): " nil
+ (let ((rev (read-from-minibuffer "Leave point at revision (default: last revision): " nil
nil nil nil))
(lim (string-to-number
(read-from-minibuffer
@@ -2556,8 +2582,12 @@ backend to NEW-BACKEND, and unregister FILE from the current backend.
;;;###autoload
(defun vc-delete-file (file)
- "Delete file and mark it as such in the version control system."
- (interactive "fVC delete file: ")
+ "Delete file and mark it as such in the version control system.
+If called interactively, read FILE, defaulting to the current
+buffer's file name if it's under version control."
+ (interactive (list (read-file-name "VC delete file: " nil
+ (when (vc-backend buffer-file-name)
+ buffer-file-name) t)))
(setq file (expand-file-name file))
(let ((buf (get-file-buffer file))
(backend (vc-backend file)))
@@ -2595,8 +2625,13 @@ backend to NEW-BACKEND, and unregister FILE from the current backend.
;;;###autoload
(defun vc-rename-file (old new)
- "Rename file OLD to NEW in both work area and repository."
- (interactive "fVC rename file: \nFRename to: ")
+ "Rename file OLD to NEW in both work area and repository.
+If called interactively, read OLD and NEW, defaulting OLD to the
+current buffer's file name if it's under version control."
+ (interactive (list (read-file-name "VC rename file: " nil
+ (when (vc-backend buffer-file-name)
+ buffer-file-name) t)
+ (read-file-name "Rename to: ")))
;; in CL I would have said (setq new (merge-pathnames new old))
(let ((old-base (file-name-nondirectory old)))
(when (and (not (string= "" old-base))
@@ -2645,14 +2680,11 @@ log entries should be gathered."
(cond ((consp current-prefix-arg) ;C-u
(list buffer-file-name))
(current-prefix-arg ;Numeric argument.
- (let ((files nil)
- (buffers (buffer-list))
- file)
- (while buffers
- (setq file (buffer-file-name (car buffers)))
- (and file (vc-backend file)
- (setq files (cons file files)))
- (setq buffers (cdr buffers)))
+ (let ((files nil))
+ (dolist (buffer (buffer-list))
+ (let ((file (buffer-file-name buffer)))
+ (and file (vc-backend file)
+ (setq files (cons file files)))))
files))
(t
;; Don't supply any filenames to backend; this means