Skip to content

Commit 5c703c5

Browse files
Aaron Hometa-codesync[bot]
authored andcommitted
Add priority-based impact reason ordering
Summary: btd v1 checks change reasons in priority order (Inputs > Labels > Hash > CiSrcs > Package > Rule) in a single pass, so the highest-priority reason wins. btd v2 discovers changes in two phases — graph update finds Labels/Hash/Rule first, then owners query finds Inputs later. With first-writer-wins in record_impact, Hash was winning over Inputs. This adds priority() to RootImpactKind and makes record_impact override lower-priority reasons with higher-priority ones. Now when the owners query finds a target already marked as Hash, it overrides with Inputs, matching v1's attribution. Also fixes deduplicate_target_categories to remove targets from non_recursive_targets when they also appear in recursive_targets (e.g. Labels overridden by Inputs changes non-recursive to recursive). Reviewed By: aniketmathur Differential Revision: D93274880 fbshipit-source-id: b0bb6a0f66b5c90fe62c4c519dd52a7ef01dafc1
1 parent 6c6bd42 commit 5c703c5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

btd/src/diff.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,20 @@ impl RootImpactKind {
248248
| Self::ManualForRerun => true,
249249
}
250250
}
251+
252+
/// Higher value wins when multiple reasons apply to the same target.
253+
pub const fn priority(self) -> u8 {
254+
match self {
255+
Self::New | Self::Remove | Self::ManualForRerun => 7,
256+
Self::Inputs => 6,
257+
Self::Labels => 5,
258+
Self::Hash => 4,
259+
Self::CiSrcs => 3,
260+
Self::Package => 2,
261+
Self::Rule => 1,
262+
Self::PackageValues | Self::UniversalFile | Self::SelectAll => 0,
263+
}
264+
}
251265
}
252266

253267
pub fn immediate_target_changes<'a>(

0 commit comments

Comments
 (0)