From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#25410: 26.0.50; Refine an unified diff hunk only if adds lines Date: Wed, 11 Jan 2017 11:49:45 +0900 Message-ID: <87fukqe2eu.fsf@gmail.com> References: <8737grz0q3.fsf@gmail.com> <8737gr0zbn.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1484105974 16857 195.159.176.226 (11 Jan 2017 03:39:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 11 Jan 2017 03:39:34 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 25410@debbugs.gnu.org, Tino Calancha To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 11 04:39:30 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cR9ku-00035H-5P for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Jan 2017 04:39:20 +0100 Original-Received: from localhost ([::1]:51113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cR9ky-0008PJ-N5 for geb-bug-gnu-emacs@m.gmane.org; Tue, 10 Jan 2017 22:39:24 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cR8zI-0003NE-4P for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 21:50:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cR8zD-0007WS-8Z for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 21:50:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33872) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cR8zD-0007WA-5B for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 21:50:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cR8zC-0007xe-Qg for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 21:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 Jan 2017 02:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25410 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25410-submit@debbugs.gnu.org id=B25410.148410299830587 (code B ref 25410); Wed, 11 Jan 2017 02:50:02 +0000 Original-Received: (at 25410) by debbugs.gnu.org; 11 Jan 2017 02:49:58 +0000 Original-Received: from localhost ([127.0.0.1]:49271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cR8z8-0007xG-G1 for submit@debbugs.gnu.org; Tue, 10 Jan 2017 21:49:58 -0500 Original-Received: from mail-pf0-f182.google.com ([209.85.192.182]:35359) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cR8z6-0007wx-8I for 25410@debbugs.gnu.org; Tue, 10 Jan 2017 21:49:56 -0500 Original-Received: by mail-pf0-f182.google.com with SMTP id f144so47776415pfa.2 for <25410@debbugs.gnu.org>; Tue, 10 Jan 2017 18:49:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=nDoVce2refDbbZssMc0+25RQX2wmrZUNdc9ipGNAlBM=; b=u0ktRthTaYN6bjxwuep9APRz9PwYx08KNuz0WDB9SenUCZ8uMw3jUpBy1qMDmvpfQv 1jWfJE9NjGHDecjMfHuQrtXvbBrzdxczDaQKH2VGqrObV5qkB4E4fr+E/WTeJW369Lw4 8zZtSOW1m9LRgGeTBoKFoV+zbT6tTWQ0yMxhfsBoLPnaD0+5DykuhHvJUwTBA48MUHyY OR4m84WqzxISneIzJwyqoPAwdTW53eqIlneXUdJRfDOP6YU+pAMuqJMQsN+kr/ifdUlb 6zsAteGIAm/QHE5YWhkW2F1zgB5Bbs/FEebhPv0b4KYz9ZXLPtH4vh38di6wHjvz/ZLE gMww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=nDoVce2refDbbZssMc0+25RQX2wmrZUNdc9ipGNAlBM=; b=JgS4hlZzUbEPgkoAdiw1pTWXjNP87MHkGY5TiJgFFd1zd+xWEx0Gppav3eGjnkPUS/ SnzQHwKnTS1ytRStwoi9dI4oSpJhgc1pWEVcsiS1O2VEh9ilAPWwrICsOBsHFl9U4MDE RnV9aPvu5/Uv/+qkk1K+J3O6pFPS1BQYOOTx9F6uHAIrDxUxIVfYCledWx2jjTaiLQ1/ Sx3euYW8Le9E93xv1sQiSh8e0WRoTQZQxr31DmhbHCk+54jOEHHDg3ncMTzi+Mn5iIRV 1iRB3x2lJqCnTZKHZ69KN7+r3ayb+QF3Y84SrlP5ANEbx9iws0mXQXYbbTjtAyHFHzLZ Thgg== X-Gm-Message-State: AIkVDXLk9g1PzJRrXf8kFG2dQ85rYDtN9M5YD7Lz/0zRxZedAMdvfGn5lVQjMje248wCoA== X-Received: by 10.99.109.206 with SMTP id i197mr7457807pgc.4.1484102990450; Tue, 10 Jan 2017 18:49:50 -0800 (PST) Original-Received: from calancha-pc (217.225.128.101.dy.bbexcite.jp. [101.128.225.217]) by smtp.gmail.com with ESMTPSA id a24sm8803240pfh.57.2017.01.10.18.49.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Jan 2017 18:49:49 -0800 (PST) In-Reply-To: <8737gr0zbn.fsf@users.sourceforge.net> (npostavs's message of "Tue, 10 Jan 2017 09:22:36 -0500") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:127980 Archived-At: npostavs@users.sourceforge.net writes: > Tino Calancha writes: > >> After deletion of a large file from CVS, a diff shows >> a very large hunk with just deleted lines. Then, for unified diffs, a call >> to `diff-refine-hunk' on that hunk takes a huge time. >> Instead, it's better to first check if the hunk adds new lines: only when >> this is true, then proceed with the hunk refinement. > > What about a diff that adds a very large file? Perhaps we should only > refine if there added lines *and* deleted lines? I have updated the patch. Now it checks before the `pcase' that the hunk adds and removes lines. Only when this is true, we enter in the `pcase'. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From 0ff79ca6f106f121a05b8c5de55990b88fecb4d2 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Wed, 11 Jan 2017 11:42:56 +0900 Subject: [PATCH] Only refine diff hunks that both remove and add lines * lisp/vc/diff-mode.el (diff-refine-hunk): Refine the hunk only if it adds and removes some lines (Bug#25410). --- lisp/vc/diff-mode.el | 77 ++++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 9dfcd944bb..f0c53e6f8a 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2075,44 +2075,45 @@ diff-refine-hunk (props-c '((diff-mode . fine) (face diff-refine-changed))) (props-r '((diff-mode . fine) (face diff-refine-removed))) (props-a '((diff-mode . fine) (face diff-refine-added)))) - - (remove-overlays beg end 'diff-mode 'fine) - - (goto-char beg) - (pcase style - (`unified - (while (re-search-forward - (eval-when-compile - (let ((no-LF-at-eol-re "\\(?:\\\\.*\n\\)?")) - (concat "^\\(?:-.*\n\\)+" no-LF-at-eol-re - "\\(\\)" - "\\(?:\\+.*\n\\)+" no-LF-at-eol-re))) - end t) - (smerge-refine-subst (match-beginning 0) (match-end 1) - (match-end 1) (match-end 0) - nil 'diff-refine-preproc props-r props-a))) - (`context - (let* ((middle (save-excursion (re-search-forward "^---"))) - (other middle)) - (while (re-search-forward "^\\(?:!.*\n\\)+" middle t) - (smerge-refine-subst (match-beginning 0) (match-end 0) - (save-excursion - (goto-char other) - (re-search-forward "^\\(?:!.*\n\\)+" end) - (setq other (match-end 0)) - (match-beginning 0)) - other - (if diff-use-changed-face props-c) - 'diff-refine-preproc - (unless diff-use-changed-face props-r) - (unless diff-use-changed-face props-a))))) - (_ ;; Normal diffs. - (let ((beg1 (1+ (point)))) - (when (re-search-forward "^---.*\n" end t) - ;; It's a combined add&remove, so there's something to do. - (smerge-refine-subst beg1 (match-beginning 0) - (match-end 0) end - nil 'diff-refine-preproc props-r props-a)))))))) + ;; Only refine the hunk if both adds and removes lines (Bug#25410). + (when (and (save-excursion (re-search-forward "^-.*\n" end t)) + (re-search-forward "^\\+.*\n" end t)) + (remove-overlays beg end 'diff-mode 'fine) + (goto-char beg) + (pcase style + (`unified + (while (re-search-forward + (eval-when-compile + (let ((no-LF-at-eol-re "\\(?:\\\\.*\n\\)?")) + (concat "^\\(?:-.*\n\\)+" no-LF-at-eol-re + "\\(\\)" + "\\(?:\\+.*\n\\)+" no-LF-at-eol-re))) + end t) + (smerge-refine-subst (match-beginning 0) (match-end 1) + (match-end 1) (match-end 0) + nil 'diff-refine-preproc props-r props-a))) + (`context + (let* ((middle (save-excursion (re-search-forward "^---"))) + (other middle)) + (while (re-search-forward "^\\(?:!.*\n\\)+" middle t) + (smerge-refine-subst (match-beginning 0) (match-end 0) + (save-excursion + (goto-char other) + (re-search-forward "^\\(?:!.*\n\\)+" end) + (setq other (match-end 0)) + (match-beginning 0)) + other + (if diff-use-changed-face props-c) + 'diff-refine-preproc + (unless diff-use-changed-face props-r) + (unless diff-use-changed-face props-a))))) + (_ ;; Normal diffs. + (let ((beg1 (1+ (point)))) + (when (re-search-forward "^---.*\n" end t) + ;; It's a combined add&remove, so there's something to do. + (smerge-refine-subst beg1 (match-beginning 0) + (match-end 0) end + nil 'diff-refine-preproc props-r props-a))))))))) (defun diff-undo (&optional arg) "Perform `undo', ignoring the buffer's read-only status." -- 2.11.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.5) of 2017-01-10 Repository revision: fa0a2b4e7c81f57aecc1d94df00588a4dd5c281d