From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.bugs Subject: bug#11490: vc-next-action overwrites changes in non-checked-out RCS file Date: Sat, 5 Jan 2013 09:35:56 +0000 (UTC) Message-ID: <87mwthp9dd.fsf@gnu.org> References: <4FB40003.3050502@kamens.us> <4FB451AE.60508@kamens.us> <4FB65ECA.6000205@kamens.us> <87txqxr6y8.fsf@gnu.org> <50E649D6.4090808@kamens.us> <55obh51vlw.fsf@fencepost.gnu.org> <50E64D8D.1010201@kamens.us> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1357378556 11150 80.91.229.3 (5 Jan 2013 09:35:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 5 Jan 2013 09:35:56 +0000 (UTC) Cc: Jonathan Kamens , 11490@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 05 10:36:12 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TrQAk-0006Mt-6d for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Jan 2013 10:36:10 +0100 Original-Received: from localhost ([::1]:37935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TrQAU-0006P7-SQ for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Jan 2013 04:35:54 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:47162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TrQAQ-0006Oz-Uw for bug-gnu-emacs@gnu.org; Sat, 05 Jan 2013 04:35:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TrQ6Z-00020z-AQ for bug-gnu-emacs@gnu.org; Sat, 05 Jan 2013 04:32:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34039) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TrQ6Z-00020r-56 for bug-gnu-emacs@gnu.org; Sat, 05 Jan 2013 04:31:51 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TrQ6k-0001NO-8t for bug-gnu-emacs@gnu.org; Sat, 05 Jan 2013 04:32:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Chong Yidong Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 05 Jan 2013 09:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11490 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed help Original-Received: via spool by 11490-submit@debbugs.gnu.org id=B11490.13573782755264 (code B ref 11490); Sat, 05 Jan 2013 09:32:02 +0000 Original-Received: (at 11490) by debbugs.gnu.org; 5 Jan 2013 09:31:15 +0000 Original-Received: from localhost ([127.0.0.1]:44290 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TrQ5z-0001Mr-89 for submit@debbugs.gnu.org; Sat, 05 Jan 2013 04:31:15 -0500 Original-Received: from mail-pb0-f47.google.com ([209.85.160.47]:43623) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TrQ5x-0001Mk-28 for 11490@debbugs.gnu.org; Sat, 05 Jan 2013 04:31:14 -0500 Original-Received: by mail-pb0-f47.google.com with SMTP id un1so9614281pbc.6 for <11490@debbugs.gnu.org>; Sat, 05 Jan 2013 01:30:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=H+mEtHlWY+9t7nlCcUtAacGfU5r3YSV4RRqhGaSaBSg=; b=RJeEZZckPQyQ0yfPB1sOClXYvV71RnU5X7h4sOsb5NnJBxoF/q/DRYxFiNtEMS3TA8 QSTPRqgJm4t+u+azagKyysyiFKafS9h6kwt19XMkp+wPssLDBWgWIoJu2vt766p69/6Z qZxz/3paM9s0k0d3QBNtiTG35FFlFhIJrJKLjpivvT8ewSXmQRr40sM/cbjQsnuFWIyK 67On1oBocOnPh5E6/242rM2kfI8JWC5fk12IG2OUXxdvjQXrcAUfCRIybn/aCQAEFaHF f8o6Cov/qU0Ed7Z6oajZEiRo/aBd4GeYJXMVUVNRiGNGUPdBBEarlBTe5wUBF0LIxR1k vLUQ== X-Received: by 10.68.235.2 with SMTP id ui2mr169201240pbc.163.1357378259765; Sat, 05 Jan 2013 01:30:59 -0800 (PST) Original-Received: from tsparkle (cm107.delta179.maxonline.com.sg. [59.189.179.107]) by mx.google.com with ESMTPS id is6sm33807502pbc.55.2013.01.05.01.30.56 (version=SSLv3 cipher=OTHER); Sat, 05 Jan 2013 01:30:58 -0800 (PST) Original-Date: Tue, 02 Apr 2013 17:30:54 +0800 In-Reply-To: <50E64D8D.1010201@kamens.us> (Jonathan Kamens's message of "Thu, 03 Jan 2013 22:33:33 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.91 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:69403 Archived-At: Jonathan Kamens writes: > Please read the WHOLE LIST OF COMMANDS I SENT in my test case. > > I made the file writable in that list only to modify it. If you read > the whole list of commands, you will see that I make it unwritable > again before editing it with emacs. And that's exactly the problem... > if the file isn't writable, emacs assumes that it's not checked out > and not modified it and checks it out when you hit C-x v v, > overwriting the changes in it. OK, so the original bug is fixed by changing `vc-mistrust-permissions' to t, indeed. As for the problem Glenn just pointed out, it arises because VC caches the state of the file when it is first visited (via vc-state-refresh). The following patch (against trunk) should fix this, but I haven't had time to give it much testing yet. === modified file 'lisp/vc/vc-hooks.el' *** lisp/vc/vc-hooks.el 2013-01-02 16:13:04 +0000 --- lisp/vc/vc-hooks.el 2013-04-02 09:23:22 +0000 *************** *** 703,719 **** ;; the state to 'edited and redisplay the mode line. (let* ((file buffer-file-name) (backend (vc-backend file))) ! (and backend ! (or (and (equal (vc-file-getprop file 'vc-checkout-time) ! (nth 5 (file-attributes file))) ! ;; File has been saved in the same second in which ! ;; it was checked out. Clear the checkout-time ! ;; to avoid confusion. ! (vc-file-setprop file 'vc-checkout-time nil)) ! t) ! (eq (vc-checkout-model backend (list file)) 'implicit) ! (vc-state-refresh file backend) ! (vc-mode-line file backend)) ;; Try to avoid unnecessary work, a *vc-dir* buffer is ;; present if this is true. (when vc-dir-buffers --- 703,723 ---- ;; the state to 'edited and redisplay the mode line. (let* ((file buffer-file-name) (backend (vc-backend file))) ! (when backend ! (if (eq (vc-checkout-model backend (list file)) 'implicit) ! (progn ! ;; If the file was saved in the same second in which it ! ;; was checked out, clear the checkout-time to avoid ! ;; confusion. ! (if (equal (vc-file-getprop file 'vc-checkout-time) ! (nth 5 (file-attributes file))) ! (vc-file-setprop file 'vc-checkout-time nil)) ! (if (vc-state-refresh file backend) ! (vc-mode-line file backend))) ! ;; If we saved an unlocked file on a locking based VCS, that ! ;; file is not longer up-to-date. ! (if (eq (vc-file-getprop file 'vc-state) 'up-to-date) ! (vc-file-setprop file 'vc-state nil)))) ;; Try to avoid unnecessary work, a *vc-dir* buffer is ;; present if this is true. (when vc-dir-buffers === modified file 'lisp/vc/vc.el' *** lisp/vc/vc.el 2013-01-02 16:13:04 +0000 --- lisp/vc/vc.el 2013-04-02 09:30:28 +0000 *************** *** 1072,1077 **** --- 1072,1087 ---- ;; among all the `files'. (model (nth 4 vc-fileset))) + ;; If a buffer has unsaved changes, a checkout would discard them. + (when (and (not (eq model 'implicit)) + (eq state 'up-to-date)) + (let ((files files) + buffer) + (while files + (setq buffer (get-file-buffer (car files))) + (and buffer (buffer-modified-p buffer) + (setq state 'unlocked-changes files nil))))) + ;; Do the right thing (cond ((eq state 'missing)