Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Introduce a filesets expression language #3239

Closed
thoughtpolice opened this issue Mar 6, 2024 · 0 comments
Closed

FR: Introduce a filesets expression language #3239

thoughtpolice opened this issue Mar 6, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request polish🪒🐃 Make existing features more convenient and more consistent

Comments

@thoughtpolice
Copy link
Member

thoughtpolice commented Mar 6, 2024

Many commands that take paths naturally take multiple paths, and sometimes expressing the proper paths you want is awkward because there is no way to do so beyond giving the literal path itself. You may even do some inline shell scripting to figure out the set of files for some commands; the horror...

In short, commands on path can also (mostly, in theory) operate on sets of paths, the same way many functions that take revisions also often work on sets of revisions. And we have an expression language we use to compose those revision sets in a natural way: revsets, which we all know and love. Instead, we want a composable expression language for paths instead.

Mercurial calls this feature filesets.

As an example, #2286 describes a problem where if you have 100 changed files, and want to jj split the files into a pair of commits with 99 commits in the first and 1 in the second, it's really awkward. However, with a fileset we could imagine a command like jj split -p 'not(./foo.txt)' in order to achieve the desired result instantly.

Similarly, #2915 described a request to exclude files from a diff. This is as easy as -p not(Cargo.lock) using the same imaginary syntax. (Perhaps even a config such as ui.diff.ignored-filesets = "not(Cargo.lock)" could be created that is read by jj diff automatically, though that's not relevant to this particular ticket.)

Many commands that then take a path or series of path arguments can then be migrated to use -p style flags that take fileset expressions.

Yuya has noted some of the syntax and issues with Mercurial's approach here: #2915 (comment)

Waleed also called these "pathsets" in #2915. We already reuse the word "revset" from Mercurial, so I think reusing "filesets" is fine, though I kind of like "pathset" too...

@PhilipMetzger PhilipMetzger added enhancement New feature or request polish🪒🐃 Make existing features more convenient and more consistent labels Mar 7, 2024
@yuja yuja self-assigned this Apr 5, 2024
yuja added a commit to yuja/jj that referenced this issue Apr 6, 2024
Naming convention is described in FilePattern::from_str_kind(). It's based
on Mercurial's pattern prefixes, but hopefully fixes some inconsistencies.
jj-vcs#2915 (comment)

jj-vcs#3239
yuja added a commit that referenced this issue Apr 7, 2024
Naming convention is described in FilePattern::from_str_kind(). It's based
on Mercurial's pattern prefixes, but hopefully fixes some inconsistencies.
#2915 (comment)

#3239
yuja added a commit to yuja/jj that referenced this issue Apr 8, 2024
Path parsing will be migrated to parse_union_filesets(), but I haven't decided
how we'll go forward:
 a. migrate everything to fileset
 b. require flag like "-e FILESET" (note -p conflicts with log -p)
 c. require flag like "-e FILESET" and deprecate positional PATHs jj-vcs#2554
 d. require prefix like "set:FILESET" (not consistent with -r REVSET)

I'm currently dogfooding (a). It works for me, but I don't use exotic file
names that would require quoting in zsh.

jj-vcs#3239
yuja added a commit that referenced this issue Apr 9, 2024
Path parsing will be migrated to parse_union_filesets(), but I haven't decided
how we'll go forward:
 a. migrate everything to fileset
 b. require flag like "-e FILESET" (note -p conflicts with log -p)
 c. require flag like "-e FILESET" and deprecate positional PATHs #2554
 d. require prefix like "set:FILESET" (not consistent with -r REVSET)

I'm currently dogfooding (a). It works for me, but I don't use exotic file
names that would require quoting in zsh.

#3239
yuja added a commit to yuja/jj that referenced this issue Apr 10, 2024
If this doesn't work out, maybe we can try one of these:
 a. fall back to bare file name if expression doesn't contain any operator-like
    characters (e.g. "f(x" is an error, but "f x" can be parsed as bare string)
 b. introduce command-line flag to opt in (e.g. -e FILESET)
 c. introduce pattern prefix to opt in (e.g. set:FILESET)

Closes jj-vcs#3239, jj-vcs#2915, jj-vcs#2286
yuja added a commit to yuja/jj that referenced this issue Apr 10, 2024
If this doesn't work out, maybe we can try one of these:
 a. fall back to bare file name if expression doesn't contain any operator-like
    characters (e.g. "f(x" is an error, but "f x" can be parsed as bare string)
 b. introduce command-line flag to opt in (e.g. -e FILESET)
 c. introduce pattern prefix to opt in (e.g. set:FILESET)

Closes jj-vcs#3239, jj-vcs#2915, jj-vcs#2286
yuja added a commit to yuja/jj that referenced this issue Apr 10, 2024
If this doesn't work out, maybe we can try one of these:
 a. fall back to bare file name if expression doesn't contain any operator-like
    characters (e.g. "f(x" is an error, but "f x" can be parsed as bare string)
 b. introduce command-line flag to opt in (e.g. -e FILESET)
 c. introduce pattern prefix to opt in (e.g. set:FILESET)

Closes jj-vcs#3239, jj-vcs#2915, jj-vcs#2286
yuja added a commit to yuja/jj that referenced this issue Apr 11, 2024
If this doesn't work out, maybe we can try one of these:
 a. fall back to bare file name if expression doesn't contain any operator-like
    characters (e.g. "f(x" is an error, but "f x" can be parsed as bare string)
 b. introduce command-line flag to opt in (e.g. -e FILESET)
 c. introduce pattern prefix to opt in (e.g. set:FILESET)

Closes jj-vcs#3239, jj-vcs#2915, jj-vcs#2286
yuja added a commit to yuja/jj that referenced this issue Apr 12, 2024
If this doesn't work out, maybe we can try one of these:
 a. fall back to bare file name if expression doesn't contain any operator-like
    characters (e.g. "f(x" is an error, but "f x" can be parsed as bare string)
 b. introduce command-line flag to opt in (e.g. -e FILESET)
 c. introduce pattern prefix to opt in (e.g. set:FILESET)

Closes jj-vcs#3239, jj-vcs#2915, jj-vcs#2286
@yuja yuja closed this as completed in 30984da Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request polish🪒🐃 Make existing features more convenient and more consistent
Projects
None yet
Development

No branches or pull requests

3 participants