Skip to content

Commit 9dc56c6

Browse files
committed
Deduplicate nodes across roots.
1 parent b1fd8e9 commit 9dc56c6

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

src/cargo/ops/tree/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,15 @@ fn print(opts: &TreeOptions, roots: Vec<usize>, graph: &Graph<'_>) -> CargoResul
182182
Prefix::Indent
183183
};
184184

185+
// The visited deps is used to display a (*) whenever a dep has
186+
// already been printed (ignored with --no-dedupe).
187+
let mut visited_deps = HashSet::new();
188+
185189
for (i, root_index) in roots.into_iter().enumerate() {
186190
if i != 0 {
187191
println!();
188192
}
189193

190-
// The visited deps is used to display a (*) whenever a dep has
191-
// already been printed (ignored with --no-dedupe).
192-
let mut visited_deps = HashSet::new();
193194
// A stack of bools used to determine where | symbols should appear
194195
// when printing a line.
195196
let mut levels_continue = vec![];

tests/testsuite/tree.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ b v0.1.0 ([..]/foo/b)
109109
├── c v1.0.0 ([..]/foo/c)
110110
└── somedep v1.0.0
111111
112-
c v1.0.0 ([..]/foo/c)
112+
c v1.0.0 ([..]/foo/c) (*)
113113
",
114114
)
115115
.run();
@@ -821,7 +821,7 @@ dog v1.0.0
821821
└── a v0.1.0 ([..]/foo/a)
822822
823823
dog v2.0.0
824-
└── a v0.1.0 ([..]/foo/a)
824+
└── a v0.1.0 ([..]/foo/a) (*)
825825
",
826826
)
827827
.run();
@@ -834,7 +834,7 @@ cat v1.0.0
834834
└── b v0.1.0 ([..]/foo/b)
835835
836836
cat v2.0.0
837-
└── b v0.1.0 ([..]/foo/b)
837+
└── b v0.1.0 ([..]/foo/b) (*)
838838
",
839839
)
840840
.run();
@@ -1103,7 +1103,7 @@ bar v1.0.0
11031103
11041104
bar v1.0.0
11051105
[build-dependencies]
1106-
└── foo v0.1.0 ([..]/foo)
1106+
└── foo v0.1.0 ([..]/foo) (*)
11071107
",
11081108
)
11091109
.run();
@@ -1205,7 +1205,7 @@ somedep v1.0.0
12051205
12061206
somedep v1.0.0
12071207
└── pm v1.0.0
1208-
└── foo v0.1.0 ([..]/foo)
1208+
└── foo v0.1.0 ([..]/foo) (*)
12091209
",
12101210
)
12111211
.run();
@@ -1344,8 +1344,7 @@ a v0.1.0 ([..]/foo/a)
13441344
└── optdep v1.0.0
13451345
13461346
b v0.1.0 ([..]/foo/b)
1347-
└── somedep v1.0.0
1348-
└── optdep v1.0.0
1347+
└── somedep v1.0.0 (*)
13491348
",
13501349
)
13511350
.run();

tests/testsuite/tree_graph_features.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ a v0.1.0 ([..]/foo/a)
143143
└── b feature \"feat2\"
144144
└── b v0.1.0 ([..]/foo/b) (*)
145145
146-
b v0.1.0 ([..]/foo/b)
146+
b v0.1.0 ([..]/foo/b) (*)
147147
",
148148
)
149149
.run();
@@ -158,10 +158,7 @@ a v0.1.0 ([..]/foo/a)
158158
159159
b v0.1.0 ([..]/foo/b)
160160
├── b feature \"default\" (command-line)
161-
│ └── a v0.1.0 ([..]/foo/a)
162-
│ ├── a feature \"a1\"
163-
│ │ └── a feature \"default\" (command-line)
164-
│ └── a feature \"default\" (command-line) (*)
161+
│ └── a v0.1.0 ([..]/foo/a) (*)
165162
├── b feature \"feat1\"
166163
│ └── b feature \"default\" (command-line) (*)
167164
└── b feature \"feat2\"

0 commit comments

Comments
 (0)