Concept of the day: filesets?

Kevin Bullock kbullock+mercurial at ringworld.org
Wed Nov 17 01:22:21 CST 2010


On 17 Nov 2010, at 12:40 AM, Nicolas Dumazet wrote:

> 2010/11/17 Matt Mackall <mpm at selenic.com>:
>> What if we applied the revset query language concept to file patterns?
>> 
>> We have long had the ability to do:
>> 
>>  hg ci "re:(foo|bar).*"
>> 
>> We can specify re/glob/path just about wherever filenames are taken. If
>> we add a new set type, we can now do:
>> 
>>  hg ci "set: modified() and contains('mpm') and exec() and not glob('**.py')"
> 
> I'm afraid of duplication:
> 
> find -not -name "*.py" -executable | xargs grep -l mpm | xargs hg st
> -mn | xargs hg ci

Not everyone has the benefit of xargs, nor knowledge of how to use pipes advantageously. Sad, I know, but true. ;)

In seriousness, I can see your point. It's another embedded query language to maintain.

OTOH, there's a nice symmetry, now that we have a changeset query language, in adding a file query language. What are the fundamental things hg deals with? Sets (well, trees) of files, in snapshots as changesets. And if there's mutual recursion points between revsets and filesets, it's more like a single query language with two return types.

I think I'm still in favor.

>> Want to check in only files not in a subrepo?
>> 
>>  hg ci "set: not subrepo()"
> 
> And here I'd add a flag to status to add/exclude subrepo files to do
> hg st --nosubrepo | xargs hg ci

Plain `hg st` would do for that, no need for an extra flag (as it stands in 1.7).

> Or are we only targetting users that do not have "proper" shells and
> toolchains? *cough* *cough*?
> 
> 
> In reality, I feel that it would take us away from the "There should
> be one-- and preferably only one --obvious way to do it." Zen, but if
> you can do this without affecting other parts of Mercurial, I won't
> mind.

Well, ideally filesets would become the one obvious way to do it, on any platform, for anyone. Using pipes and xargs would remain a pretty obvious second way in the Unix world.

pacem in terris / mir / shanti / salaam / heiwa
Kevin R. Bullock



More information about the Mercurial-devel mailing list