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

revset: Implement 'oldest' function that complements the 'latest' function in the revset language #5565

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AjithPanneerselvam
Copy link

@AjithPanneerselvam AjithPanneerselvam commented Feb 3, 2025

This PR implements a new function oldest(x[, count]) that returns the oldest count commits in x, based on committer timestamp and the default count is 1. This is an exact complementary function to latest() available in the revset language.

Here are a few use cases that I could think about

  • oldest(author(martinvonz), 5) returns the oldest 5 commits from the author martinvonz.
  • oldest(all(), 5) returns the oldest 5 commits in this repository.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

@PhilipMetzger
Copy link
Contributor

Hello, welcome to the project. This can be all one commit and should be titled something like revset:, per https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#code-reviews

@martinvonz
Copy link
Member

nit: it seems like it should be lastest() and earliest() (or newest() and oldest()). Or maybe the inconsistency is fine.

@AjithPanneerselvam
Copy link
Author

nit: it seems like it should be lastest() and earliest() (or newest() and oldest()). Or maybe the inconsistency is fine.

Yeah, it makes sense! I'll go with earliest to stay consistent with the existing latest function.

@emilazy
Copy link
Contributor

emilazy commented Feb 4, 2025

I like the rename to newest()/oldest(), because currently people often use latest() when they want heads(). The renames seem less confusable with the topological notion that is usually more relevant.

@AjithPanneerselvam AjithPanneerselvam changed the title [feat]: Add oldest() function that complements the latest() function in the revset language [feat]: Add earliest function that complements the latest() function in the revset language Feb 4, 2025
@AjithPanneerselvam AjithPanneerselvam changed the title [feat]: Add earliest function that complements the latest() function in the revset language [revset]: Add earliest function that complements the latest() function in the revset language Feb 4, 2025
@AjithPanneerselvam AjithPanneerselvam changed the title [revset]: Add earliest function that complements the latest() function in the revset language [revset]: Add 'earliest' function that complements the 'latest' function in the revset language Feb 4, 2025
@AjithPanneerselvam AjithPanneerselvam changed the title [revset]: Add 'earliest' function that complements the 'latest' function in the revset language revset: Add 'earliest' function that complements the 'latest' function in the revset language Feb 4, 2025
@AjithPanneerselvam
Copy link
Author

AjithPanneerselvam commented Feb 4, 2025

I like the rename to newest()/oldest(), because currently people often use latest() when they want heads(). The renames seem less confusable with the topological notion that is usually more relevant.

Ah, I just renamed the references in this PR to earliest() 😅 That's okay I can revert this commit.

@emilazy I reckon the renaming from latest() to newest() is a breaking change. Can I rename it in a separate PR?

cc: @martinvonz

@emilazy
Copy link
Contributor

emilazy commented Feb 4, 2025

Yeah not trying to hold up this PR, just saying that I think renaming them both actually seems like a good idea in general. We’d want to keep a backwards compatibility alias etc. for a while.

@AjithPanneerselvam AjithPanneerselvam force-pushed the push-lnvtwvnsuotx branch 2 times, most recently from cb13a8b to ca3df73 Compare February 4, 2025 15:55
@AjithPanneerselvam AjithPanneerselvam changed the title revset: Add 'earliest' function that complements the 'latest' function in the revset language revset: Implement 'oldest' function that complements the 'latest' function in the revset language Feb 4, 2025
@PhilipMetzger
Copy link
Contributor

Sorry, it is the commit message which should contain revset: not the PR title.

@yuja
Copy link
Contributor

yuja commented Feb 5, 2025

I like the rename to newest()/oldest(), because currently people often use latest() when they want heads(). The renames seem less confusable with the topological notion that is usually more relevant.

fwiw, latest() could have some topological notion assuming that all ancestors commits are (usually) older than the commit itself. The current implementation scans all commits, which is inefficient.

@AjithPanneerselvam AjithPanneerselvam marked this pull request as ready for review February 7, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants