From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: Seeing which commits modified a range of lines? Date: Wed, 05 Nov 2014 17:31:40 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1415226753 4356 80.91.229.3 (5 Nov 2014 22:32:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Nov 2014 22:32:33 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 05 23:32:26 2014 Return-path: Envelope-to: geh-help-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 1Xm97q-0002gd-3a for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Nov 2014 23:32:26 +0100 Original-Received: from localhost ([::1]:48810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm97p-00029i-NU for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Nov 2014 17:32:25 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm97Y-00029X-EN for help-gnu-emacs@gnu.org; Wed, 05 Nov 2014 17:32:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xm97Q-0004pq-V9 for help-gnu-emacs@gnu.org; Wed, 05 Nov 2014 17:32:08 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:36126) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm97Q-0004ph-PM for help-gnu-emacs@gnu.org; Wed, 05 Nov 2014 17:32:00 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Xm97M-0002U3-SB for help-gnu-emacs@gnu.org; Wed, 05 Nov 2014 23:31:56 +0100 Original-Received: from 75-119-235-29.dsl.teksavvy.com ([75.119.235.29]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Nov 2014 23:31:56 +0100 Original-Received: from monnier by 75-119-235-29.dsl.teksavvy.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Nov 2014 23:31:56 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 50 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 75-119-235-29.dsl.teksavvy.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:3GNc+hb7FYUMS5INcpP4OAZLvFU= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:100775 Archived-At: >> Oh, yes, I've been dreaming of it ever since I started using GNU Arch. >> IIUC the only tool which does provide the needed info is Git where >> you have "git log -L,:". BTW, I've just installed into trunk new code that gives access to this functionality (called `vc-region-history' and which currently is only supported for the Git backend). > Out of the box, yes, but the point of vc is to make the life of the > user easier and hide complexities. So this functionality could be > implmented behind the scenes. In theory, yes, but it can be pretty tedious to do (and the result can be painfully slow) if done in Elisp. In most cases it would be simpler and much more efficient to implement it directly in the VCS tool. > For example, VC tools provide annotate (blame) which can tell > the last change for lines in a file. So this can be called for > a file and then the last changes for the interesting lines > are known. Actually, one of the reasons why I want vc-region-history is specifically because annotate/blame does *not* always show you the last revision. The case where it doesn't is when you're looking for a revision that just removed some lines. Annotate/blame won't tell you that between like N and N+1 there used to be some other lines and they were removed in revision foo. vc-region-history could be implemented for Bzr by running "bzr log --show-diff" after which you "just" need to filter out the undesired commits and patch hunks. For a generic solution, you could write a loop that does: - call annotate REV to find the last commit REV' that affected those lines. - call diff between REV and REV' to adjust the line-numbers according to the changes that happened elsewhere in the mean time. - call diff between REV'-1 and REV', filtering out the hunk that are outside of the affected region (and adjusting yet again the line numbers). For most backends, such a loop will take forever to terminate (and of course, it will miss some commits, as mentioned above). An alternative is to do a "log" for the file, then a loop calling "diff" for every revision in the log. At that point you have the same data as "bzr log --show-diff" and you can "just" filter out the commit and hunks that don't affect the region. Patch welcome. Stefan