all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: Seeing which commits modified a range of lines?
Date: Wed, 05 Nov 2014 17:31:40 -0500	[thread overview]
Message-ID: <jwvtx2dp9yo.fsf-monnier+gmane.emacs.help@gnu.org> (raw)
In-Reply-To: loom.20141105T211714-80@post.gmane.org

>> 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<begline>,<endline>:<file>".

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




  reply	other threads:[~2014-11-05 22:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.12815.1415132057.1147.help-gnu-emacs@gnu.org>
2014-11-04 22:36 ` Seeing which commits modified a range of lines? Stefan Monnier
2014-11-05 20:27   ` Tom
2014-11-05 22:31     ` Stefan Monnier [this message]
2014-11-06 20:56       ` Tom
     [not found]       ` <mailman.13069.1415307407.1147.help-gnu-emacs@gnu.org>
2014-11-06 22:42         ` Stefan Monnier
2014-11-04 20:13 Tom
2014-11-05  8:37 ` Tassilo Horn
2014-11-05 20:30   ` Tom
2014-11-06  7:13     ` Tassilo Horn
2014-11-06 20:46       ` Tom
2014-11-07  7:53         ` Thien-Thi Nguyen
2014-11-07 21:42           ` Tom
2014-11-08  8:26             ` Thien-Thi Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvtx2dp9yo.fsf-monnier+gmane.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.