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

Revive debug.find.global and debug.names.global #5258

Merged
merged 5 commits into from
Aug 1, 2024
Merged

Conversation

ChrisPenner
Copy link
Contributor

@ChrisPenner ChrisPenner commented Jul 31, 2024

Overview

Re-adds find.global and names.global as debug.find.global and debug.names.global respectively. I felt it was prudent to add the debug prefix because using these commands is likely to be a pretty bad experience (they're very slow) and I don't want folks thinking they're commands they should be using all the time.

These commands are effectively equivalent to running their corresponding names or find command at the root of every single project branch.

It does NOT search through history (IIRC the originals didn't either).
It DOES include lib in each search.

scratch/unused-bindings> debug.names.global #dcgdua2

  Found results in @adambissonnette/mud/main

  Term
  Hash:   #dcgdua2lj6
  Names:  lib.base.data.Map.internal.ratio


  Found results in @alvaroc1/actor/main

  Term
  Hash:   #dcgdua2lj6
  Names:  lib.base.data.Map.internal.ratio lib.logging.lib.base.data.Map.internal.ratio
scratch/unused-bindings> debug.find.global Config

  Found results in @adambissonnette/mud/main

  1.   builtin type .lib.base.IO.net.Tls.ClientConfig
  2.   builtin type .lib.base.IO.net.Tls.ServerConfig
  3.   type .lib.cloud_5_3_0.Cloud.ClientConfig
  4.   .lib.cloud_5_3_0.Cloud.ClientConfig.CloudClientConfig : HostName
...

Implementation notes

  • Adds a new helper module which allows mapping over every project branch.
  • Refactors each of names.global, find.global, and their outputs to support incremental output, so we don't have to finish the whole search to output stuff we find.

Interesting/controversial decisions

I think we should hide these behind debug.*, but you may disagree.

Test coverage

Revived existing transcripts

@@ -45,7 +45,5 @@ scratch/main> names term1
Term
Hash: #8hum58rlih
Names: term1 term2

Tip: Use `names.global` to see more results.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this tip because it's not going to be a reasonable course of action in most cases 🤷🏼‍♂️

@ChrisPenner ChrisPenner requested a review from aryairani July 31, 2024 23:56
@ChrisPenner
Copy link
Contributor Author

ChrisPenner commented Aug 1, 2024

Huh, the reflog transcript failed and it's completely unrelated (a re-run fixed it), two entries swapped places from the saved reflog output, so I'm guessing it's just a matter that the operations happened faster than the resolution of timestamps we're saving in Sqlite, maybe they got the exact same timestamp and so sorted in a different order 🤷🏼‍♂️
Can probably fix that by adding a separate clause to the order-by, or increasing our timestamp resolution, or just using fake sequential timestamps in transcripts.

Comment on lines +116 to +159
debug.find.global
`find` lists all definitions in the
current namespace.
`find foo` lists all definitions with a
name similar to 'foo' in the
current namespace (excluding
those under 'lib').
`find foo bar` lists all definitions with a
name similar to 'foo' or
'bar' in the current
namespace (excluding those
under 'lib').
`find-in namespace` lists all definitions in the
specified subnamespace.
`find-in namespace foo bar` lists all definitions with a
name similar to 'foo' or
'bar' in the specified
subnamespace.
find.all foo lists all definitions with a
name similar to 'foo' in the
current namespace (including
one level of 'lib').
`find-in.all namespace` lists all definitions in the
specified subnamespace
(including one level of its
'lib').
`find-in.all namespace foo bar` lists all definitions with a
name similar to 'foo' or
'bar' in the specified
subnamespace (including one
level of its 'lib').
debug.find.global foo Iteratively searches all
projects and branches and
lists all definitions with a
name similar to 'foo'. Note
that this is a very slow
operation.

debug.names.global
`debug.names.global foo` Iteratively search across all
projects and branches for names matching `foo`. Note that this
is expected to be quite slow and is primarily for debugging
issues with your codebase.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess all of the find variants print this whole thing? They should probably just print ... a subset, and maybe reference a help-topic that lists all the variants of find?

@aryairani aryairani merged commit 8a3e2ef into trunk Aug 1, 2024
1 check passed
@aryairani aryairani deleted the cp/global-search branch August 1, 2024 21:56
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