X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/3a880af4a79688e90da45311a8d85bae2d59a811..ab422c4d6899b1442cb6954c1829c1fb656b006c:/lisp/vc/vc.el diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 89e0d0c3ec..35c15f1721 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1,6 +1,6 @@ ;;; vc.el --- drive a version-control system from within Emacs -*- lexical-binding: t -*- -;; Copyright (C) 1992-1998, 2000-2012 Free Software Foundation, Inc. +;; Copyright (C) 1992-1998, 2000-2013 Free Software Foundation, Inc. ;; Author: FSF (see below for full credits) ;; Maintainer: Andre Spiegel @@ -1105,24 +1105,27 @@ For old-style locking-based version control systems, like RCS: ;; Files have local changes ((vc-compatible-state state 'edited) (let ((ready-for-commit files)) - ;; If files are edited but read-only, give user a chance to correct. - (dolist (file files) - ;; If committing a mix of removed and edited files, the - ;; fileset has state = 'edited. Rather than checking the - ;; state of each individual file in the fileset, it seems - ;; simplest to just check if the file exists. Bug#9781. - (when (and (file-exists-p file) (not (file-writable-p file))) - ;; Make the file+buffer read-write. - (unless (y-or-n-p (format "%s is edited but read-only; make it writable and continue? " file)) - (error "Aborted")) - ;; Maybe we somehow lost permissions on the directory. - (condition-case nil - (set-file-modes file (logior (file-modes file) 128)) - (error (error "Unable to make file writable"))) - (let ((visited (get-file-buffer file))) - (when visited - (with-current-buffer visited - (read-only-mode -1)))))) + ;; CVS, SVN and bzr don't care about read-only (bug#9781). + ;; RCS does, SCCS might (someone should check...). + (when (memq backend '(RCS SCCS)) + ;; If files are edited but read-only, give user a chance to correct. + (dolist (file files) + ;; If committing a mix of removed and edited files, the + ;; fileset has state = 'edited. Rather than checking the + ;; state of each individual file in the fileset, it seems + ;; simplest to just check if the file exists. Bug#9781. + (when (and (file-exists-p file) (not (file-writable-p file))) + ;; Make the file+buffer read-write. + (unless (y-or-n-p (format "%s is edited but read-only; make it writable and continue? " file)) + (error "Aborted")) + ;; Maybe we somehow lost permissions on the directory. + (condition-case nil + (set-file-modes file (logior (file-modes file) 128)) + (error (error "Unable to make file writable"))) + (let ((visited (get-file-buffer file))) + (when visited + (with-current-buffer visited + (read-only-mode -1))))))) ;; Allow user to revert files with no changes (save-excursion (dolist (file files) @@ -1581,21 +1584,21 @@ Return t if the buffer had changes, nil otherwise." (let ((vc-disable-async-diff (not async))) (vc-call-backend (car vc-fileset) 'diff files rev1 rev2 buffer)) (set-buffer buffer) + (diff-mode) + (set (make-local-variable 'diff-vc-backend) (car vc-fileset)) + (set (make-local-variable 'revert-buffer-function) + `(lambda (ignore-auto noconfirm) + (vc-diff-internal ,async ',vc-fileset ,rev1 ,rev2 ,verbose))) + ;; Make the *vc-diff* buffer read only, the diff-mode key + ;; bindings are nicer for read only buffers. pcl-cvs does the + ;; same thing. + (setq buffer-read-only t) (if (and (zerop (buffer-size)) (not (get-buffer-process (current-buffer)))) ;; Treat this case specially so as not to pop the buffer. (progn (message "%s" (cdr messages)) nil) - (diff-mode) - (set (make-local-variable 'diff-vc-backend) (car vc-fileset)) - (set (make-local-variable 'revert-buffer-function) - `(lambda (ignore-auto noconfirm) - (vc-diff-internal ,async ',vc-fileset ,rev1 ,rev2 ,verbose))) - ;; Make the *vc-diff* buffer read only, the diff-mode key - ;; bindings are nicer for read only buffers. pcl-cvs does the - ;; same thing. - (setq buffer-read-only t) ;; Display the buffer, but at the end because it can change point. (pop-to-buffer (current-buffer)) ;; The diff process may finish early, so call `vc-diff-finish'