[PATCH RFC] commands: draft a "followlines" command (RFC)

Augie Fackler raf at durin42.com
Sat Sep 30 10:06:09 EDT 2017

> On Sep 28, 2017, at 11:04, Denis Laxalde <denis at laxalde.org> wrote:
> # HG changeset patch
> # User Denis Laxalde <denis at laxalde.org>
> # Date 1506589297 -7200
> #      Thu Sep 28 11:01:37 2017 +0200
> # Node ID 0e0fef8d525d9cf60d9ca23de614e994aca5c9d8
> # Parent  2d0c306a88c226d96cf29036b6d6b08bd0abc3b4
> # EXP-Topic followlines-cli-rfc
> commands: draft a "followlines" command (RFC)

Patch is awfully big - it'd be helpful to split out some of the precursor work (e.g. stuff in cmdutil.py) into some extra patches that we could land sooner.

> This introduces a new "followlines" command to show history of files by line
> range. The command relies on a special syntax to specify file's line range:
> FILE,FROMLINE-TOLINE where FILE may be a (rel)path pattern. The command
> handles several files and, similarly to the followlines() revset, it also
> accepts a --descend and a --startrev option. Most "hg log" options are
> supported (with the noticeable exception of --graph, but should be doable).
> I'm also willing to add a --rev option and possibly some diff options (ignore
> white spaces changes, for instance).

If we could figure out how to tuck this in 'hg log' I think I'd be happier. Maybe we could do --line-range 'START:END' flag that would only work if exactly one file was specified for 'hg log'?

> Basically, this command is meant to bring CLI on par with what currently only
> exists in hgweb through line selection in "file" and "annotate" views
> resulting in a file log with filtered patch to only display followed line
> range.
> I've thought about extending "hg log" but finally opted for a new command.
> Main reasons for this.
> * It does not appear feasible (or at least without significant refactoring) to
>  adjust the log command to handle the followlines situation in which we have
>  to iterate through filectx and line range information, instead of bare
>  revisions (obtained from processing log options and file patterns in
>  `cmdutil._makelogrevset()`).
> * The semantics of this command is arguably a bit different from 'hg log'.
>  In particular, when following a block of lines, it seems meaningful to have
>  the log displayed in a particular direction (ascending by default, possibly
>  descending). Doing this in 'hg log' would require toggling --follow option
>  implicitly.

Requiring --follow (and defaulting it to on) for --line-range seems eminently reasonable.

> Still, I'm very open to suggestion to embed this in 'hg log'.

Why don't we try and land everything but the top-level command, and then we can look at the options a little more carefully in terms of adding this to log vs adding a new command. Sound good?

I'm excited to have this functionality usable from the command line!

More information about the Mercurial-devel mailing list