GNU bug report logs - #21067
25.0.50; [PATCH] With mercurial, vc-print-log puts point at eob

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Wolfgang Jenkner <wjenkner@HIDDEN>; Keywords: patch; dated Wed, 15 Jul 2015 18:25:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 21067 <at> debbugs.gnu.org:


Received: (at 21067) by debbugs.gnu.org; 19 Jul 2015 00:08:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 18 20:08:41 2015
Received: from localhost ([127.0.0.1]:53413 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZGc9p-0001qu-2A
	for submit <at> debbugs.gnu.org; Sat, 18 Jul 2015 20:08:41 -0400
Received: from mail-wg0-f51.google.com ([74.125.82.51]:36847)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <raaahh@HIDDEN>) id 1ZGc9m-0001qd-Pt
 for 21067 <at> debbugs.gnu.org; Sat, 18 Jul 2015 20:08:39 -0400
Received: by wgbcc4 with SMTP id cc4so12912974wgb.3
 for <21067 <at> debbugs.gnu.org>; Sat, 18 Jul 2015 17:08:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=sender:subject:to:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-type:content-transfer-encoding;
 bh=tp1+XgNOwq6lgbaKN0EfeJSy1WoxK0bQKXvGWDvW2BM=;
 b=HJRHRLy7wLt2riYUz5LRC+ECOEo6oF//QK3WvEQaUD5K50fRISWFAB6A1acMqUjB5k
 aAsRcH4kdAzDPzNtPdDTD1DDCospMvzBFBuuuWWX8WXV60gMQxaQqSWDmtqGphWHHHi7
 Fwb98oW2C2kWqUHUajVAbY/1jk+WlijIoJaIIUtDgLsI4y4l/RFLJ5rtEZXItu38lO0A
 ZtkSOESWjUQDI/GYzYNzegv4Uzr8SMg6oebwJxsUi2Cg/9Y0pw3M+T9d1IV1HQN94KN4
 VsTIaRCPWq49tMXyJWfO/YFHK5NLbTdRp2WTAekD9TD4LhQEJmAVoHU9mHXhIiS+qYnM
 Zyxw==
X-Received: by 10.180.9.6 with SMTP id v6mr8370993wia.83.1437264513282;
 Sat, 18 Jul 2015 17:08:33 -0700 (PDT)
Received: from [192.168.1.2] ([185.105.175.24])
 by smtp.googlemail.com with ESMTPSA id k2sm4767123wif.4.2015.07.18.17.08.31
 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Sat, 18 Jul 2015 17:08:32 -0700 (PDT)
Subject: Re: bug#21067: 25.0.50; [PATCH] With mercurial, vc-print-log puts
 point at eob
To: Wolfgang Jenkner <wjenkner@HIDDEN>, 21067 <at> debbugs.gnu.org
References: <85lheh8ekr.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <55AAEA7C.2060609@HIDDEN>
Date: Sun, 19 Jul 2015 03:08:28 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.0
MIME-Version: 1.0
In-Reply-To: <85lheh8ekr.fsf@HIDDEN>
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 21067
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

On 07/15/2015 02:09 PM, Wolfgang Jenkner wrote:

> So I wonder whether it wouldn't be worthwile to make their job easier
> (and thereby avoid bugs like the one described above) by handling async
> and sync processes alike in this respect.  The condition for this to
> work is that backend functions don't expect point to be preserved,
> except, of course, if it is actually their purpose to compute point
> (like for vc-git-show-log-entry).

I like the idea, but FWIW the patch breaks diff-hl-revert-hunk (diff-hl 
is in GNU ELPA). Haven't investigated it further yet.

And the particular bug you've described, naturally, can also be fixed by 
making vc-hg-print-log asynchronous:

diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 556174a..f634e2e 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -272,7 +272,7 @@ If LIMIT is non-nil, show no more than this many 
entries."
    (let ((inhibit-read-only t))
      (with-current-buffer
  	buffer
-      (apply 'vc-hg-command buffer 0 files "log"
+      (apply 'vc-hg-command buffer 'async files "log"
  	     (nconc
  	      (when start-revision (list (format "-r%s:0" start-revision)))
  	      (when limit (list "-l" (format "%s" limit)))





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21067; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 15 Jul 2015 18:24:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 15 14:24:14 2015
Received: from localhost ([127.0.0.1]:50335 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZFRLp-00038i-N4
	for submit <at> debbugs.gnu.org; Wed, 15 Jul 2015 14:24:14 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49317)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <xdsl0000474440@HIDDEN>) id 1ZFRLm-00038U-N7
 for submit <at> debbugs.gnu.org; Wed, 15 Jul 2015 14:24:11 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <xdsl0000474440@HIDDEN>) id 1ZFRLg-0003nW-Dl
 for submit <at> debbugs.gnu.org; Wed, 15 Jul 2015 14:24:05 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: **
X-Spam-Status: No, score=2.3 required=5.0 tests=BAYES_50,DATE_IN_PAST_06_12
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:57370)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <xdsl0000474440@HIDDEN>) id 1ZFRLg-0003nQ-Au
 for submit <at> debbugs.gnu.org; Wed, 15 Jul 2015 14:24:04 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34549)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <xdsl0000474440@HIDDEN>) id 1ZFRLb-0000GJ-KL
 for bug-gnu-emacs@HIDDEN; Wed, 15 Jul 2015 14:24:04 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <xdsl0000474440@HIDDEN>) id 1ZFRLV-0003j0-Fm
 for bug-gnu-emacs@HIDDEN; Wed, 15 Jul 2015 14:23:59 -0400
Received: from b2bfep13.mx.upcmail.net ([62.179.121.58]:35355)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <xdsl0000474440@HIDDEN>) id 1ZFRLV-0003h7-5J
 for bug-gnu-emacs@HIDDEN; Wed, 15 Jul 2015 14:23:53 -0400
Received: from edge11.upcmail.net ([192.168.13.81]) by b2bfep13.mx.upcmail.net
 (InterMail vM.8.01.05.11 201-2260-151-128-20120928) with ESMTP
 id <20150715182349.YLRK2939.b2bfep13-int.chello.at@HIDDEN>
 for <bug-gnu-emacs@HIDDEN>; Wed, 15 Jul 2015 20:23:49 +0200
Received: from iznogoud.viz ([91.119.221.196]) by edge11.upcmail.net with edge
 id siPp1q0084EqxsT0BiPpjU; Wed, 15 Jul 2015 20:23:49 +0200
X-SourceIP: 91.119.221.196
Received: from wolfgang by iznogoud.viz with local (Exim 4.85 (FreeBSD))
 (envelope-from <wolfgang@HIDDEN>) id 1ZFRLQ-0002NZ-SU
 for bug-gnu-emacs@HIDDEN; Wed, 15 Jul 2015 20:23:48 +0200
From: Wolfgang Jenkner <wjenkner@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 25.0.50; [PATCH] With mercurial, vc-print-log puts point at eob
Date: Wed, 15 Jul 2015 13:09:22 +0200
Message-ID: <85lheh8ekr.fsf@HIDDEN>
User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (berkeley-unix)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -3.9 (---)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.9 (---)

Call vc-dir for some repo under hg version control and then type l in
the resulting *vc-dir* buffer.

As expected, this produces a *vc-change-log* buffer with the most recent
change at the beginning.  However, point is at the end of the buffer.
I would expect point to be put next to the most recent commit, as it is
the case for, e.g., git.  Note that explicitly selecting a revision
(typing C-u l) does work.

The different behaviour is due to the hg log subprocess being run
synchronously while the git subprocess is run asynchronously.

For an async process the following happens:

vc-process-filter inserts each output chunk at the process mark and
updates the latter; vc-run-delayed has advised the sentinel to go to the
process mark and insert additional stuff (buttons) when the process is
finished.  All those insertions happen inside save-excursion forms.
However, the sentinel sets point to the value of vc-sentinel-movepoint
(if non-nil).

For a sync process the following happens:

The output is inserted and additional stuff set up with vc-run-delayed
is inserted at point.  Those insertions don't happen inside
save-excursion forms and vc-sentinel-movepoint is ignored.

Now, while it is true that the name of vc-sentinel-movepoint doesn't
sound like it was meant for synchronous processes anyway, it is also
true that generic functions like vc-print-log and callees don't know
whether the subprocess will be run synchronously or asynchronously.

So I wonder whether it wouldn't be worthwile to make their job easier
(and thereby avoid bugs like the one described above) by handling async
and sync processes alike in this respect.  The condition for this to
work is that backend functions don't expect point to be preserved,
except, of course, if it is actually their purpose to compute point
(like for vc-git-show-log-entry).

Here's a patch.

-- >8 --
Subject: [PATCH] Handle point for sync vc processes like for async ones

* lisp/vc/vc-dispatcher.el (vc--process-sentinel): Cut some code.
(vc-exec-after): Move it here.  Remove comment which has not been
matching the code for a while.
(vc-do-command): Use save-excursion around the sync process call.
---
 lisp/vc/vc-dispatcher.el | 39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el
index ec55867..4f44d35 100644
--- a/lisp/vc/vc-dispatcher.el
+++ b/lisp/vc/vc-dispatcher.el
@@ -199,25 +199,7 @@ Another is that undo information is not kept."
                 ;; Leave mode-line uncluttered, normally.
                 (unless (eq 'exit status)
                   (format " (%s)" status))))
-        (let (vc-sentinel-movepoint
-              (m (process-mark p)))
-          ;; Normally, we want async code such as sentinels to not move point.
-          (save-excursion
-            (goto-char m)
-            ;; 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 code)
-            (move-marker m (point)))
-          ;; 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))))))))))
+        (vc-exec-after code)))))
 
 (defun vc-set-mode-line-busy-indicator ()
   (setq mode-line-process
@@ -241,7 +223,20 @@ CODE should be a function of no arguments."
      ((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))
-      (if (functionp code) (funcall code) (eval code)))
+      (let (vc-sentinel-movepoint)
+        ;; Normally, we want code to not move point.
+        (save-excursion
+          (let ((m (when proc (process-mark proc))))
+            (goto-char (or m (point-max)))
+            (if (functionp code) (funcall code) (eval code))
+            (when m (move-marker m (point)))))
+        ;; 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)))))))
      ;; If a process is running, add CODE to the sentinel
      ((eq (process-status proc) 'run)
       (vc-set-mode-line-busy-indicator)
@@ -337,7 +332,9 @@ case, and the process object in the asynchronous case."
 	    (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)))
+              ;; Use `save-excursion' like `vc-process-filter' does.
+	      (setq status (save-excursion
+                             (apply 'process-file command nil t nil squeezed))))
 	    (when (and (not (eq t okstatus))
 		       (or (not (integerp status))
 			   (and okstatus (< okstatus status))))
-- 
2.4.5





Acknowledgement sent to Wolfgang Jenkner <wjenkner@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#21067; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 19 Jul 2015 00:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.