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

Implement a RepoPathTreeIterator #2406

Closed
wants to merge 1 commit into from

Conversation

torquestomp
Copy link
Contributor

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

@martinvonz
Copy link
Member

Why do we want this? It doesn't seem to be used anywhere. Could you describe what it's for in the commit message because currently this seems to just introduce dead code? I think the idea is to use it in custom binaries. Do you think it's going to be common enough that we should carry the code in the repo instead of just having it in the Google customization? Or can it not be implemented without access to internals? (I haven't looked at the code yet.)

@torquestomp
Copy link
Contributor Author

I updated the commit description. I haven't looked through the internal code to see where this could be used (it might be useful somewhere), but yes the main intent is opening up the lib a little more to extensions.

It seems like a natural extension of the type (which has private internals), so I think it would be nice to leave in the public API. An extension could implement this on their own of course as a copy but it wouldn't make any use of jj_lib.

The internal 'set-of-dirs' structure is useful to extensions that need to do
their own tree-walking routines. It may also be useful internally in other
places.
Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some further context: Google wants to calculate the set of trees that changed in each commit so we can store that in a central index and use it for prefetching trees from the server later. We already index the set of files changed in a commit. We're thinking of calculating the set of changed directories by taking that set of files and building up a RepoPathTree from them, then looking up the tree id for each of those directories in the commit's MergedTree (we only care about the "after" state).

I wonder if we should instead teach MergedTree's diff iterator an option to also include the trees it visits. That would also be useful for the TODO in jj debug tree (which I (incidentally!) added just a few days ago). That seems cleaner because we avoid looking up the trees from the backend again after the diff iterator had just done it. It won't matter in practice, though, because the trees will be cached already at that point.

@torquestomp: If we just make the type and a few existing methods public (maybe just new(), add_dir(), and add_file()?), maybe that's all we need if we then walk the tree by using the Matcher::visit() method?

I hesitate to merge this PR because I dislike having unused code in the codebase, even though I agree that it seems plausible that we'll want it in the future. I'd at least want hear a non-Googlers opinion before we merge it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete.

To make *~ files always ignored, you can do this:

$ git config --global core.excludesFile ~/.gitignore
$ echo '*~' >> ~/.gitignore

(you can call the file .gitignore file whatever you want)

let map_component = *self.map_component.as_ref().unwrap();
child.path.push_front(map_component);
return Some(child);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: set self.tree_iter = None here so we don't visit the subdirectory for later files in this tree

@torquestomp torquestomp deleted the repo-path-tree branch January 19, 2024 17:24
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.

2 participants