history at diff blocks level

Jun Wu quark at fb.com
Wed Oct 19 12:41:58 EDT 2016


Excerpts from Yuya Nishihara's message of 2016-10-18 23:38:19 +0900:
> On Tue, 18 Oct 2016 08:59:58 +0200, Denis Laxalde wrote:
> > Jun Wu a écrit :
> > > Excerpts from Denis Laxalde's message of 2016-10-03 16:38:17 +0200:
> > >>  From UI point of view, the basic idea is to specify a (file name, line
> > >> range) pair and the simplest solution I could find is something like:
> > >>
> > >>    hg log/annotate --line-range fromline,toline FILE
> > >>
> > >> but this does not work well with several files. (Perhaps something like
> > >> hg log FILE:fromline:toline would be better.) I also thought about a
> > >
> > > +1 for "FILE:fromline:toline". It is intuitive and makes sense. A new
> > > boolean flag (like "--line-ranges") that enables the syntax explicitly
> > > may be necessary. The flag can avoid conflicts with existing matcher syntax,
> > > and make it clear that some commands like "add" do not support line ranges.
> > 
> > "FILE:fromline:toline" is also my favorite option. But I'm not sure I'd
> > like to be forced to specify an extra option to be able to use this
> > syntax. I'd much prefer if this could be avoided, though we'll indeed
> > have to handle conflicts with existing matcher syntax. Or use another
> > separator? Any other idea welcome!
> 
> How about extending the fileset syntax?
> 
>   $ hg log/annotate 'set:FILE:linerange(FROMLINE-TOLINE)'
>                              # ':' attr-name '(' args ')'

I think adding new pattern like "(rel)linerange:PATH:L1-L2" is cleaner.

Reasons:

  - It's rare to specify a same line range for different files.
  - If it was added to "set:", how about other patterns like "glob:",
    "path:", "include:", ...?
    If they all need to support the new syntax. It could introduce ambiguity.

As a user, I want to type commands as short as possible. So "set:" is not
pretty. I think the "default" parameter of match.__init__ could be made to
support a list, like ['glob', 'rellinerange'] and tries them one by one. If
BC is a concern, a config option could be introduced.

Eventually, if it is just so useful, I think it can be made to be the
default behavior. A user can always use a different prefix to explicitly
select a pattern they want to use.

The only concern I have here is to disable the line range pattern by default
as many commands couldn't support it. And it can only be enabled explicitly
by the caller of match().

> We could have a shorthand operator ('%' just for example):
> 
>   $ hg log/annotate set:FILE%FROMLINE-TOLINE
> 
> This might look crazy, and I think it's actually crazy, but it could be
> extended for log --follow (issue4959):
> 
>   $ hg log --follow 'set:FILE:rev(REV)'


More information about the Mercurial-devel mailing list