OXYGENHUB

oxy describe defaults to the most recent head under the working copy 79d03f826ecd

Author
Andy McCall @andymccall <[email protected]>
When
· 2026-09-26 19:31 UTC
Signature
✔ signed by Andy McCall
Hash
79d03f826ecd90a893751f33fe16af0da86cfbaf510e86ce583f2c036a106e7a
Depends on
614541c3cebd fce44ae9ad29
Depended on by
387335ff7f4d 75167672ebcd
In bookmarks
agents-in-readme bare-hashes carried-not-removed carry-identical doctor-trust identical-sides keyless-tags main merge-remote-bookmark only-help-103 paths-for-resolutions-and-amend push-notes show-stat subrepo-pin-state switch-says
In tags
v0.1.0 v0.10.0 v0.11.0 v0.2.0 v0.3.0 v0.3.1 v0.4.0 v0.4.1 v0.4.2 v0.4.3 v0.4.4 v0.4.5 v0.4.6 v0.5.0 v0.5.1 v0.6.0 v0.7.0 v0.8.0 v0.9.0
Edits
4 atoms, 0 tree operations, 1 file

Browse the tree at this change

modified src/cli/workspace.rs +14 −2
…
201 unchanged lines
202 202
    Ok(0)
203 203
}
204 204
205 -
/// The single head the working copy sits on, for commands that default to it.
205 +
/// The head the working copy sits on, for commands that default to it. With
206 +
/// several heads beneath the working copy, the most recently made one is
207 +
/// chosen and announced.
206 208
fn current_head(repo: &Repo) -> Result<oxy_core::hash::ChangeHash> {
207 209
    let snap = repo.snapshot("oxy")?;
208 210
    let base = snap.base.maximal(&snap.wc.deps);
209 211
    match base.as_slice() {
212 +
        [] => anyhow::bail!("the working copy sits on no change yet"),
210 213
        [h] => Ok(*h),
211 -
        _ => anyhow::bail!("the working copy sits on {} heads; name the change explicitly", base.len()),
214 +
        many => {
215 +
            let latest = many
216 +
                .iter()
217 +
                .max_by_key(|h| snap.base.get(h).map(|c| (c.hlc, **h)))
218 +
                .copied()
219 +
                .unwrap();
220 +
            let c = repo.store().get_change(&latest)?;
221 +
            println!("Defaulting to {} #{} (most recent of the {} heads under the working copy)", short_id(&c), latest.short(12), many.len());
222 +
            Ok(latest)
223 +
        }
212 224
    }
213 225
}
214 226
…
28 unchanged lines