Authentication-Results: mail-b.sr.ht; dkim=pass header.d=electriccoin.co header.i=@electriccoin.co Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) by mail-b.sr.ht (Postfix) with ESMTPS id 2088D11EF61 for <~ireas/public-inbox@lists.sr.ht>; Wed, 21 Sep 2022 15:18:47 +0000 (UTC) Received: by mail-yb1-f171.google.com with SMTP id e187so8536443ybh.10 for <~ireas/public-inbox@lists.sr.ht>; Wed, 21 Sep 2022 08:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=electriccoin.co; s=google; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date; bh=lXLRoh+mfIEXTF/YAOxUV6kLxKk4brYZULZrIwD73T4=; b=bLDZnkIIWzIjAYbHoHHhE8V1m7+PJkhqKMm1ZxRizm6VXeuFZG6hQ7hF/TaOdfQfu/ CuuUd3mjgoyLzYcWWJU2k4bfUOtAFgy4fxTOfkYuMpdIPIAzUvbUVSDft5nU95HWK5Ac X1EU/MEMf//f/AP7OSFlA9HVQiWQndt1EUHAwHkKAeqDPoNxFa/66aRxEG5iPe32DWtM zY/NjIbO/EelLg0ZeFX2zNHj+hSjTs/dbPhE4yknyE9d+B4nAICheP5xBbI6qF5Sf3Je 8Qn1k9pAjC9z/ryUVgMFU4ggOq4Cj/dUWjo6VTqbK1jHjFqTOMtriu99LSCDBO6Icgi/ tKlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=lXLRoh+mfIEXTF/YAOxUV6kLxKk4brYZULZrIwD73T4=; b=A8D9fMcpfaJ64q/7FapvKnQqA9BipthyWcfs4LYNXFcgCevEmzhWvztRICAAT/Ln55 YIzUkXEZDIWaFiI2IFVVlzpGcLQYCAGUkuSqkgAAjYxNDic75y77IWR8wKjIwqrzr0og MY8y6L5MdEf1//2IInRjx6ie2wScnrrPjKMhDjKZgNSUzcCYbcH1XIzEj9wXHvYWMY2C CSXbc11FlWdw8eycDoO08IH2OtH1fWhnus5Kh2VUV4Ot+GvXOV530X6Y1RdB939n0Tgk 8XmAjdO665bLuMbiILnOUAnND84jStib+9Nsxp47CV2Tpk4kNhsbTYzg+eq0O4BWJPC4 mlQQ== X-Gm-Message-State: ACrzQf0KYHjrtl7lENBguZXEj+VFn9c6HUiFTWLaK1z25jpKmfUwzLnG Ar/wf0dYLR8mznf5lK+7PNjIC4lqwv6PE6jGePnp0g== X-Google-Smtp-Source: AMsMyM6eHON99Ggn+z/jzX+cfaN9drB2r8VWaDQocUI5YqAPt2SNBm9bPmKg/0ai3kl18s2QzOJpZ5ynaQuycMakADw= X-Received: by 2002:a05:6902:34b:b0:691:4b82:7624 with SMTP id e11-20020a056902034b00b006914b827624mr25660468ybs.614.1663773526393; Wed, 21 Sep 2022 08:18:46 -0700 (PDT) MIME-Version: 1.0 References: <20220921071716.GA1221@ireas.org> In-Reply-To: <20220921071716.GA1221@ireas.org> From: Nathan Wilcox Date: Wed, 21 Sep 2022 08:18:36 -0700 Message-ID: Subject: Re: [PATCH cargo-depgraph] To: Robin Krahl Cc: Jonas Platte , ~ireas/public-inbox@lists.sr.ht Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Apologies for the confusion! Is `jplatte+git@posteo.de` the correct destination for `cargo-depgraph` pat= ches? Yesterday I found a page saying email patches should all be sent to `~ireas/public-inbox@lists.sr.ht`, except some projects have their own mailing list. I glanced at the list of projects and didn't see `cargo-depgraph` there, so I assumed I should use the default email. Today I can't find that page, so I'm not sure how I ran across it. For someone new to sr.ht like me (who's also never submitted git patches via email before) it would help to have the correct email address on https://git.sr.ht/~jplatte/cargo-depgraph . In fact, the most helpful thing would be to alter the text which says "You can also use your local clone with ." into "You can also use your local clone with by running `git send-email --to=3D`." If that were in the base template of sr.ht (and all projects were required to declare the patch email addr), it would streamline this piece of the puzzle for newcomers. Where can I go to file an issue or submit a patch to add that feature to sr.ht ? regards, Nate On Wed, Sep 21, 2022 at 12:17 AM Robin Krahl wrote: > > Hi Nathan, > > I=E2=80=99m not affiliated with the cargo-depgraph project. You should p= robably > send the patch directly to Jonas. > > Best, > Robin > > On 2022-09-20 15:03:29, Nathan Wilcox wrote: > > This patch adds a `--workspace-only` option which constrains the graph > > to only workspace crates. This is useful for understanding > > intra-workspace dependencies. > > > > --- > > src/cli.rs | 8 ++++++++ > > src/graph.rs | 20 ++++++++++++++++++++ > > src/main.rs | 6 +++++- > > 3 files changed, 33 insertions(+), 1 deletion(-) > > > > diff --git a/src/cli.rs b/src/cli.rs > > index e9f2aa1..72b3fff 100644 > > --- a/src/cli.rs > > +++ b/src/cli.rs > > @@ -7,6 +7,7 @@ pub struct Config { > > pub dedup_transitive_deps: bool, > > pub hide: Vec, > > pub exclude: Vec, > > + pub workspace_only: bool, > > pub focus: Vec, > > > > pub features: Vec, > > @@ -76,6 +77,11 @@ pub fn parse_options() -> Config { > > dependency kind resolution", > > ), > > ) > > + .arg( > > + Arg::new("workspace_only") > > + .long("workspace-only") > > + .help("Exclude all packages outside of the wor= kspace"), > > + ) > > .arg( > > Arg::new("focus") > > .long("focus") > > @@ -155,6 +161,7 @@ pub fn parse_options() -> Config { > > let dedup_transitive_deps =3D matches.is_present("dedup_transitive= _deps"); > > let hide =3D matches.values_of("hide").map_or_else(Vec::new, colle= ct_owned); > > let exclude =3D matches.values_of("exclude").map_or_else(Vec::new, > > collect_owned); > > + let workspace_only =3D matches.is_present("workspace_only"); > > let focus =3D matches.values_of("focus").map_or_else(Vec::new, > > collect_owned); > > > > let features =3D > > matches.values_of("features").map_or_else(Vec::new, collect_owned); > > @@ -174,6 +181,7 @@ pub fn parse_options() -> Config { > > dedup_transitive_deps, > > hide, > > exclude, > > + workspace_only, > > focus, > > features, > > all_features, > > diff --git a/src/graph.rs b/src/graph.rs > > index d41c0d3..d4f329c 100644 > > --- a/src/graph.rs > > +++ b/src/graph.rs > > @@ -80,6 +80,26 @@ fn update_node(graph: &mut DepGraph, idx: NodeIndex<= u16>) { > > } > > } > > > > +pub fn remove_non_workspace_deps(graph: &mut DepGraph) { > > + let mut visit_queue: VecDeque<_> =3D > > graph.externals(Direction::Outgoing).collect(); > > + while let Some(idx) =3D visit_queue.pop_front() { > > + // A node can end up being in the list multiple times. If it > > was already removed by a > > + // previous iteration of this loop, skip it. > > + if !graph.contains_node(idx) { > > + continue; > > + } > > + > > + let pkg =3D &graph[idx]; > > + if !pkg.is_ws_member { > > + // The package node at `idx` should be removed. > > + // =3D> First add its dependencies to the visit queue > > + visit_queue.extend(graph.neighbors_directed(idx, > > Direction::Incoming)); > > + // =3D> Then actually remove it > > + graph.remove_node(idx); > > + } > > + } > > +} > > + > > pub fn remove_irrelevant_deps(graph: &mut DepGraph, focus: &[String]) = { > > let mut visit_queue: VecDeque<_> =3D > > graph.externals(Direction::Outgoing).collect(); > > while let Some(idx) =3D visit_queue.pop_front() { > > diff --git a/src/main.rs b/src/main.rs > > index c86af4f..25c7ee3 100644 > > --- a/src/main.rs > > +++ b/src/main.rs > > @@ -20,7 +20,8 @@ mod output; > > use self::{ > > cli::parse_options, > > graph::{ > > - dedup_transitive_deps, get_dep_graph, remove_deps, > > remove_irrelevant_deps, update_dep_info, > > + dedup_transitive_deps, get_dep_graph, remove_deps, > > remove_irrelevant_deps, > > + remove_non_workspace_deps, update_dep_info, > > }, > > output::dot, > > util::set_name_stats, > > @@ -59,6 +60,9 @@ fn main() -> anyhow::Result<()> { > > > > let mut graph =3D get_dep_graph(metadata, &config)?; > > update_dep_info(&mut graph); > > + if config.workspace_only { > > + remove_non_workspace_deps(&mut graph); > > + } > > if !config.focus.is_empty() { > > remove_irrelevant_deps(&mut graph, &config.focus); > > } > > -- > > 2.30.2 --=20 Nathan Wilcox Chief Research Officer nathan@electriccoin.co | @least_nathan