2586f655bb
First, replace all usages in files in-place. I used my editor for this. If someone wants to add a one-liner that'd be fun. Then, update directory and file names: ``` # Run twice for nested directories find . -type d -print0 | xargs -0 rename s/puffin/uv/g find . -type d -print0 | xargs -0 rename s/puffin/uv/g # Update files find . -type f -print0 | xargs -0 rename s/puffin/uv/g ``` Then add all the files again ``` # Add all the files again git add crates git add python/uv # This one needs a force-add git add -f crates/uv-trampoline ```
35 lines
1007 B
Rust
35 lines
1007 B
Rust
use std::cmp::Reverse;
|
|
|
|
use rustc_hash::FxHashMap;
|
|
|
|
use uv_normalize::PackageName;
|
|
|
|
use crate::pubgrub::package::PubGrubPackage;
|
|
|
|
#[derive(Debug, Default)]
|
|
pub(crate) struct PubGrubPriorities(FxHashMap<PackageName, usize>);
|
|
|
|
impl PubGrubPriorities {
|
|
/// Add a package to the priority map.
|
|
pub(crate) fn add(&mut self, package: PackageName) {
|
|
let priority = self.0.len();
|
|
self.0.entry(package).or_insert(priority);
|
|
}
|
|
|
|
/// Return the priority of the given package, if it exists.
|
|
pub(crate) fn get(&self, package: &PubGrubPackage) -> Option<PubGrubPriority> {
|
|
match package {
|
|
PubGrubPackage::Root(_) => Some(Reverse(0)),
|
|
PubGrubPackage::Python(_) => Some(Reverse(0)),
|
|
PubGrubPackage::Package(name, _, _) => self
|
|
.0
|
|
.get(name)
|
|
.copied()
|
|
.map(|priority| priority + 1)
|
|
.map(Reverse),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub(crate) type PubGrubPriority = Reverse<usize>;
|