OXYGENHUB
# abaa8d517631 oxygen / crates / oxy-core / src / repo / snapshot.rs
23.3 KiB · Rust · last changed Split repo.rs into repo/{config,snapshot,checkout,identity,sync,tests}; hermetic OXY_HOME in tests; identity recorded in user config 1 month ago source blame history raw
1
//! Working-copy snapshots, commits, and the change builder (spec §12.3).
2
3
use super::*;
4
5
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6
pub enum ChangeStatus {
7
    Added,
8
    Modified,
9
    Removed,
10
    ModeChanged,
11
    /// The file is conflicted in the base state and still contains conflict markers.
12
    ConflictEdited,
13
    /// The file was conflicted in the base state and the working copy resolves it.
14
    Resolved,
15
}
16
17
/// Lines that mark a conflict region in a materialized file (spec §9.5).
18
pub fn has_conflict_markers(content: &[u8]) -> bool {
19
    split_lines(content).iter().any(|l| {
20
        l.starts_with(b"<<<<<<< oxy conflict") || l.starts_with(b"======= oxy conflict") || l.starts_with(b">>>>>>> oxy conflict")
21
    })
22
}
23
24
#[derive(Clone, Debug, PartialEq, Eq)]
25
pub struct PathStatus {
26
    pub path: String,
27
    pub status: ChangeStatus,
28
}
29
30
/// Result of snapshotting the working copy.
31
pub struct SnapshotResult {
32
    pub wc_hash: ChangeHash,
33
    pub wc: Change,
34
    /// The base state (closure of the working-copy change's dependencies).
35
    pub base: State,
36
    pub base_snapshot: Snapshot,
37
    pub statuses: Vec<PathStatus>,
38
    /// Whether the snapshot rewrote the working-copy change.
39
    pub changed: bool,
40
    /// Whether the working copy resolves conflicts of its base (spec §9.6).
41
    pub resolves: bool,
42
    /// Changes that contributed to the conflicts being resolved.
43
    pub contributors: Vec<ChangeHash>,
44
}
45
46
pub fn is_binary(content: &[u8]) -> bool {
47
    content[..content.len().min(BINARY_SNIFF)].contains(&0)
48
}
49
50
impl Repo {
51
    /// Snapshot the working copy into the working-copy change (spec §12.3).
52
    pub fn snapshot(&self, command: &str) -> Result<SnapshotResult> {
53
        let (op_ref, op) = self.head_op()?;
54
        let (old_hash, old_wc) = self.working_copy()?;
55
        let base = self.load_state(&old_wc.deps)?;
56
        let base_snapshot = base.materialize();
57
        let fs_entries = self.walk_working_copy()?;
58
59
        // Reuse the NodeIds the previous working-copy version assigned to new
60
        // paths, so an unchanged working copy hashes identically (spec §12.3).
61
        let reuse = added_node_paths(&old_wc, &base_snapshot);
62
        let mut b = ChangeBuilder::new(&base, &base_snapshot, reuse);
63
        for (path, fs_entry) in &fs_entries {
64
            match base_snapshot.files.get(path) {
65
                None => b.add_path(self, path, fs_entry)?,
66
                Some(expected) => b.update_path(self, path, fs_entry, expected)?,
67
            }
68
        }
69
        for (path, expected) in &base_snapshot.files {
70
            if fs_entries.contains_key(path) {
71
                continue;
72
            }
73
            let still_needed = expected.kind == NodeKind::Dir && fs_entries.keys().any(|p| p.starts_with(&format!("{path}/")));
74
            if !still_needed {
75
                b.remove_path(path, expected);
76
            }
77
        }
78
79
        let mut wc = Change {
80
            change_id: old_wc.change_id,
81
            deps: vec![],
82
            author: self.author(),
83
            hlc: old_wc.hlc,
84
            message: old_wc.message.clone(),
85
            tree_ops: b.tree_ops,
86
            edits: b.edits,
87
            kind: ChangeKind::WorkingCopy,
88
        };
89
        let base_heads = base.maximal(&old_wc.deps);
90
        let mut deps: BTreeSet<ChangeHash> = base_heads.into_iter().collect();
91
        deps.extend(referenced_changes(&wc, &base));
92
        deps.extend(b.contributors.iter().copied());
93
        wc.deps = deps.into_iter().collect();
94
        wc.normalize();
95
        let resolves = b.resolves;
96
        let contributors: Vec<ChangeHash> = b.contributors.iter().copied().collect();
97
98
        let mut statuses = b.statuses;
99
        statuses.sort_by(|a, b| a.path.cmp(&b.path));
100
        // Empty snapshot: hash the candidate before storing; only record an op on change.
101
        let new_hash = wc.hash();
102
        let changed = new_hash != old_hash;
103
        if changed {
104
            self.store.put_change(&wc)?;
105
            let mut view = op.view.clone();
106
            view.workspaces.insert(self.workspace, new_hash);
107
            self.record_op(&[op_ref], &format!("{command}{SNAPSHOT_SUFFIX}"), view)?;
108
        }
109
        Ok(SnapshotResult { wc_hash: new_hash, wc, base, base_snapshot, statuses, changed, resolves, contributors })
110
    }
111
112
    /// Turn the working-copy change into a normal change on the bookmark (spec §12.3).
113
    pub fn commit(&self, message: &str, extra_deps: &[ChangeHash]) -> Result<ChangeHash> {
114
        let snap = self.snapshot("oxy commit")?;
115
        if snap.wc.tree_ops.is_empty() && snap.wc.edits.is_empty() {
116
            return fail("nothing to commit: the working copy matches its base");
117
        }
118
        if let Some(s) = snap.statuses.iter().find(|s| s.status == ChangeStatus::ConflictEdited) {
119
            return fail(format!("{} still contains conflict markers", s.path));
120
        }
121
        if message.trim().is_empty() {
122
            return fail("a commit message is required");
123
        }
124
        let (op_ref, op) = self.head_op()?;
125
        let mut deps: BTreeSet<ChangeHash> = referenced_changes(&snap.wc, &snap.base);
126
        // A resolution depends on every change that contributed to the
127
        // conflict (spec §8.1). Tree and opaque conflicts are resolved through
128
        // ordinary operations whose references already cover the contributors.
129
        deps.extend(snap.contributors.iter().copied());
130
        for d in extra_deps {
131
            if !snap.base.contains(d) {
132
                return fail(format!("--depends-on {d}: not in the working copy's base state"));
133
            }
134
            deps.insert(*d);
135
        }
136
        if self.config.sign_changes && self.secret_key()?.is_none() {
137
            return fail("core.sign is \"change\" but no secret key is available for author.key");
138
        }
139
        let mut change = Change {
140
            change_id: snap.wc.change_id,
141
            deps: deps.into_iter().collect(),
142
            author: self.author(),
143
            hlc: Hlc::now(),
144
            message: message.trim_end().to_string(),
145
            tree_ops: snap.wc.tree_ops.clone(),
146
            edits: snap.wc.edits.clone(),
147
            kind: if snap.resolves { ChangeKind::Resolution } else { ChangeKind::Normal },
148
        };
149
        change.normalize();
150
        let hash = self.store.put_change(&change)?;
151
        if self.config.sign_changes {
152
            self.sign_change(&hash)?;
153
        }
154
155
        // New bookmark heads: maximal elements of old heads plus the new change.
156
        // The working copy continues on its own base plus the new change, which
157
        // is exactly what the files on disk contain; the bookmark may hold
158
        // other heads (and conflicts) the working copy has not checked out.
159
        let old_heads = self.heads_of(&op.view, &self.config.bookmark)?;
160
        let old_base = snap.base.maximal(&snap.wc.deps);
161
        let mut all: Vec<ChangeHash> = old_heads.clone();
162
        all.extend(old_base.iter().copied());
163
        all.push(hash);
164
        let mut st = self.load_state(&all)?;
165
        st.add(change)?;
166
        let mut with_new = old_heads.clone();
167
        with_new.push(hash);
168
        let new_heads = st.maximal(&with_new);
169
        let mut wc_base = old_base.clone();
170
        wc_base.push(hash);
171
        let wc_base = st.maximal(&wc_base);
172
173
        let wc = self.new_working_copy(wc_base, "");
174
        let wc_hash = self.store.put_change(&wc)?;
175
        let mut view = op.view.clone();
176
        view.bookmarks.insert(self.config.bookmark.clone(), self.store.put_state(&StateObject::new(new_heads))?);
177
        view.workspaces.insert(self.workspace, wc_hash);
178
        self.record_op(&[op_ref], &format!("oxy commit -m {message:?}"), view)?;
179
        Ok(hash)
180
    }
181
}
182
183
/// Builds the tree ops and edits of a working-copy change against a base.
184
struct ChangeBuilder<'a> {
185
    base: &'a State,
186
    base_snapshot: &'a Snapshot,
187
    tree_ops: Vec<TreeOp>,
188
    edits: Vec<Edit>,
189
    statuses: Vec<PathStatus>,
190
    dir_nodes: HashMap<String, NodeId>,
191
    reuse: HashMap<String, (NodeId, NodeKind)>,
192
    /// Changes that contributed to conflicts this working copy resolves.
193
    contributors: BTreeSet<ChangeHash>,
194
    resolves: bool,
195
}
196
197
impl<'a> ChangeBuilder<'a> {
198
    fn new(base: &'a State, base_snapshot: &'a Snapshot, reuse: HashMap<String, (NodeId, NodeKind)>) -> Self {
199
        let mut dir_nodes: HashMap<String, NodeId> = HashMap::new();
200
        dir_nodes.insert(String::new(), NodeId::ROOT);
201
        for (p, f) in &base_snapshot.files {
202
            if f.kind == NodeKind::Dir {
203
                dir_nodes.insert(p.clone(), f.node);
204
            }
205
        }
206
        ChangeBuilder { base, base_snapshot, tree_ops: vec![], edits: vec![], statuses: vec![], dir_nodes, reuse, contributors: BTreeSet::new(), resolves: false }
207
    }
208
209
    fn reused_node(&self, path: &str, kind: NodeKind) -> Option<NodeId> {
210
        self.reuse.get(path).filter(|(_, k)| *k == kind).map(|(n, _)| *n)
211
    }
212
213
    fn ensure_dir(&mut self, path: &str) -> NodeId {
214
        if let Some(n) = self.dir_nodes.get(path) {
215
            return *n;
216
        }
217
        let mut parent = NodeId::ROOT;
218
        let mut prefix = String::new();
219
        for comp in path.split('/') {
220
            if !prefix.is_empty() {
221
                prefix.push('/');
222
            }
223
            prefix.push_str(comp);
224
            parent = match self.dir_nodes.get(&prefix) {
225
                Some(n) => *n,
226
                None => {
227
                    let node = self.reused_node(&prefix, NodeKind::Dir).unwrap_or_else(NodeId::random);
228
                    self.tree_ops.push(TreeOp::AddNode { node, kind: NodeKind::Dir, mode: Mode::default(), parent, name: comp.to_string() });
229
                    self.dir_nodes.insert(prefix.clone(), node);
230
                    node
231
                }
232
            };
233
        }
234
        parent
235
    }
236
237
    fn add_path(&mut self, repo: &Repo, path: &str, e: &FsEntry) -> Result<()> {
238
        let (dir, name) = split_path(path);
239
        let parent = self.ensure_dir(dir);
240
        let node = self.reused_node(path, e.kind).unwrap_or_else(NodeId::random);
241
        let opaque = e.kind == NodeKind::Symlink || is_binary(&e.content);
242
        self.tree_ops.push(TreeOp::AddNode { node, kind: e.kind, mode: Mode { exec: e.exec, opaque }, parent, name: name.to_string() });
243
        if opaque {
244
            let blob = repo.store_blob(&e.content)?;
245
            self.edits.push(Edit::Replace { node, old: None, new: Some(blob) });
246
        } else if !e.content.is_empty() {
247
            self.edits.push(Edit::Insert {
248
                node,
249
                after: crate::objects::AtomRef::Start,
250
                before: crate::objects::AtomRef::End,
251
                lines: split_lines(&e.content).iter().map(|l| l.to_vec()).collect(),
252
            });
253
        }
254
        self.statuses.push(PathStatus { path: path.to_string(), status: ChangeStatus::Added });
255
        Ok(())
256
    }
257
258
    fn remove_path(&mut self, path: &str, expected: &crate::state::FileState) {
259
        let entry = &self.base_snapshot.tree.entries[path];
260
        self.tree_ops.push(TreeOp::RemoveNode { node: expected.node, placement: op_ref(entry.placement) });
261
        if path.contains(".oxy-conflict-") || expected.is_conflicted() {
262
            self.resolves = true;
263
        }
264
        self.statuses.push(PathStatus { path: path.to_string(), status: ChangeStatus::Removed });
265
    }
266
267
    fn update_path(&mut self, repo: &Repo, path: &str, e: &FsEntry, expected: &crate::state::FileState) -> Result<()> {
268
        if expected.kind != e.kind {
269
            self.remove_path(path, expected);
270
            self.statuses.pop();
271
            self.add_path(repo, path, e)?;
272
            self.statuses.pop();
273
            self.statuses.push(PathStatus { path: path.to_string(), status: ChangeStatus::Modified });
274
            return Ok(());
275
        }
276
        let entry = &self.base_snapshot.tree.entries[path];
277
        let node = expected.node;
278
        let mode_atom = entry.mode_atom.map(op_ref);
279
        let mut status: Option<ChangeStatus> = None;
280
        match &expected.content {
281
            FileContent::Dir => {}
282
            FileContent::Text { bytes, materialized } => {
283
                if materialized.is_conflicted() {
284
                    if bytes == &e.content {
285
                        return Ok(());
286
                    }
287
                    if has_conflict_markers(&e.content) {
288
                        self.statuses.push(PathStatus { path: path.to_string(), status: ChangeStatus::ConflictEdited });
289
                        return Ok(());
290
                    }
291
                    // Resolution (spec §9.6): diff against the unconflicted lines
292
                    // with each region as a gap, then retire every region atom.
293
                    // Whatever the author kept from a region is re-inserted as
294
                    // new atoms, which leaves the graph totally ordered.
295
                    let regions = self.base.conflict_regions(&node);
296
                    let mut edits = text_edits(node, &regions.plain, &e.content);
297
                    if !regions.region_atoms.is_empty() {
298
                        edits.insert(0, Edit::Delete { node, atoms: ranges(&regions.region_atoms) });
299
                    }
300
                    self.edits.extend(edits);
301
                    self.contributors.extend(regions.contributors);
302
                    self.resolves = true;
303
                    if e.exec != expected.mode.exec {
304
                        if let Some(old) = mode_atom {
305
                            self.tree_ops.push(TreeOp::SetMode { node, old, mode: Mode { exec: e.exec, opaque: false } });
306
                        }
307
                    }
308
                    self.statuses.push(PathStatus { path: path.to_string(), status: ChangeStatus::Resolved });
309
                    return Ok(());
310
                }
311
                if bytes != &e.content {
312
                    if is_binary(&e.content) {
313
                        // Text → opaque (spec §7.5).
314
                        if let Some(old) = mode_atom {
315
                            self.tree_ops.push(TreeOp::SetMode { node, old, mode: Mode { exec: e.exec, opaque: true } });
316
                        }
317
                        let live: Vec<_> = repo_live_keys(self.base, &node);
318
                        if !live.is_empty() {
319
                            self.edits.push(Edit::Delete { node, atoms: ranges(&live) });
320
                        }
321
                        let blob = repo.store_blob(&e.content)?;
322
                        self.edits.push(Edit::Replace { node, old: None, new: Some(blob) });
323
                        status = Some(ChangeStatus::Modified);
324
                    } else {
325
                        let old = self.base.live_lines(&node);
326
                        let edits = text_edits(node, &old, &e.content);
327
                        if !edits.is_empty() {
328
                            self.edits.extend(edits);
329
                            status = Some(ChangeStatus::Modified);
330
                        }
331
                    }
332
                }
333
                let switched_to_opaque = status == Some(ChangeStatus::Modified) && is_binary(&e.content);
334
                if !switched_to_opaque && e.exec != expected.mode.exec {
335
                    if let Some(old) = mode_atom {
336
                        self.tree_ops.push(TreeOp::SetMode { node, old, mode: Mode { exec: e.exec, opaque: false } });
337
                        status.get_or_insert(ChangeStatus::ModeChanged);
338
                    }
339
                }
340
            }
341
            FileContent::Opaque { blobs } => {
342
                let new_ref = Repo::blob_ref(&e.content);
343
                if blobs.len() > 1 {
344
                    if !blobs.contains(&new_ref) {
345
                        self.statuses.push(PathStatus { path: path.to_string(), status: ChangeStatus::ConflictEdited });
346
                    }
347
                    return Ok(());
348
                }
349
                let current = blobs.first().copied();
350
                if current != Some(new_ref) {
351
                    if e.kind == NodeKind::File && !is_binary(&e.content) {
352
                        // Opaque → text (spec §7.5).
353
                        if let Some(old) = mode_atom {
354
                            self.tree_ops.push(TreeOp::SetMode { node, old, mode: Mode { exec: e.exec, opaque: false } });
355
                        }
356
                        self.edits.push(Edit::Replace { node, old: current, new: None });
357
                        if !e.content.is_empty() {
358
                            self.edits.push(Edit::Insert {
359
                                node,
360
                                after: crate::objects::AtomRef::Start,
361
                                before: crate::objects::AtomRef::End,
362
                                lines: split_lines(&e.content).iter().map(|l| l.to_vec()).collect(),
363
                            });
364
                        }
365
                    } else {
366
                        let blob = repo.store_blob(&e.content)?;
367
                        self.edits.push(Edit::Replace { node, old: current, new: Some(blob) });
368
                    }
369
                    status = Some(ChangeStatus::Modified);
370
                } else if e.kind == NodeKind::File && e.exec != expected.mode.exec {
371
                    if let Some(old) = mode_atom {
372
                        self.tree_ops.push(TreeOp::SetMode { node, old, mode: Mode { exec: e.exec, opaque: true } });
373
                        status = Some(ChangeStatus::ModeChanged);
374
                    }
375
                }
376
            }
377
        }
378
        if let Some(s) = status {
379
            self.statuses.push(PathStatus { path: path.to_string(), status: s });
380
        }
381
        Ok(())
382
    }
383
}
384
385
fn repo_live_keys(base: &State, node: &NodeId) -> Vec<crate::graph::AtomKey> {
386
    base.live_lines(node).into_iter().map(|(k, _)| k).collect()
387
}
388
389
/// The changes a change's scope references (spec §8.1): introducers of every
390
/// atom, placement, and mode it touches, and of every node it operates on.
391
pub fn referenced_changes(change: &Change, base: &State) -> BTreeSet<ChangeHash> {
392
    let mut out = BTreeSet::new();
393
    let opref = |r: &OpRef, out: &mut BTreeSet<ChangeHash>| {
394
        if !r.change.is_zero() {
395
            out.insert(r.change);
396
        }
397
    };
398
    let mut nodes: Vec<NodeId> = Vec::new();
399
    for op in &change.tree_ops {
400
        match op {
401
            TreeOp::AddNode { parent, .. } => nodes.push(*parent),
402
            TreeOp::RemoveNode { node, placement } => {
403
                nodes.push(*node);
404
                opref(placement, &mut out);
405
            }
406
            TreeOp::Move { node, old, parent, .. } => {
407
                nodes.push(*node);
408
                nodes.push(*parent);
409
                opref(old, &mut out);
410
            }
411
            TreeOp::SetMode { node, old, .. } => {
412
                nodes.push(*node);
413
                opref(old, &mut out);
414
            }
415
        }
416
    }
417
    for e in &change.edits {
418
        nodes.push(e.node());
419
        match e {
420
            Edit::Insert { after, before, .. } => {
421
                for r in [after, before] {
422
                    if let crate::objects::AtomRef::Atom { change, .. } = r {
423
                        if !change.is_zero() {
424
                            out.insert(*change);
425
                        }
426
                    }
427
                }
428
            }
429
            Edit::Delete { atoms, .. } => {
430
                for r in atoms {
431
                    if !r.change.is_zero() {
432
                        out.insert(r.change);
433
                    }
434
                }
435
            }
436
            Edit::Replace { .. } => {}
437
        }
438
    }
439
    for n in nodes {
440
        if let Some(h) = base.tree().introducer(&n) {
441
            out.insert(h);
442
        }
443
    }
444
    out
445
}
446
447
/// Paths of the nodes a change adds on top of `base_snapshot`.
448
pub fn added_node_paths(change: &Change, base_snapshot: &Snapshot) -> HashMap<String, (NodeId, NodeKind)> {
449
    let by_node = base_snapshot.tree.by_node();
450
    let mut new_names: HashMap<NodeId, (NodeId, String, NodeKind)> = HashMap::new();
451
    for op in &change.tree_ops {
452
        if let TreeOp::AddNode { node, parent, name, kind, .. } = op {
453
            new_names.insert(*node, (*parent, name.clone(), *kind));
454
        }
455
    }
456
    let mut out = HashMap::new();
457
    for (node, (_, _, kind)) in &new_names {
458
        if let Some(path) = path_of_node(node, &by_node, &new_names) {
459
            out.insert(path, (*node, *kind));
460
        }
461
    }
462
    out
463
}
464
465
fn path_of_node(
466
    n: &NodeId,
467
    by_node: &HashMap<NodeId, &crate::tree::TreeEntry>,
468
    new_names: &HashMap<NodeId, (NodeId, String, NodeKind)>,
469
) -> Option<String> {
470
    if let Some(e) = by_node.get(n) {
471
        return Some(e.path.clone());
472
    }
473
    let mut parts = Vec::new();
474
    let mut cur = *n;
475
    loop {
476
        if cur.is_root() {
477
            break;
478
        }
479
        if let Some(e) = by_node.get(&cur) {
480
            if !e.path.is_empty() {
481
                parts.push(e.path.clone());
482
            }
483
            break;
484
        }
485
        let (parent, name, _) = new_names.get(&cur)?;
486
        parts.push(name.clone());
487
        cur = *parent;
488
    }
489
    parts.reverse();
490
    Some(parts.join("/"))
491
}
492
493
/// Render a change's operations with line content, using `base` for deleted lines.
494
pub fn render_change(change: &Change, base: &State, base_snapshot: &Snapshot) -> String {
495
    let by_node = base_snapshot.tree.by_node();
496
    let mut new_names: HashMap<NodeId, (NodeId, String, NodeKind)> = HashMap::new();
497
    for op in &change.tree_ops {
498
        if let TreeOp::AddNode { node, parent, name, kind, .. } = op {
499
            new_names.insert(*node, (*parent, name.clone(), *kind));
500
        }
501
    }
502
    let path_of = |n: &NodeId| -> String { path_of_node(n, &by_node, &new_names).unwrap_or_else(|| format!("<node {}>", n.short(8))) };
503
504
    let mut out = String::new();
505
    for op in &change.tree_ops {
506
        match op {
507
            TreeOp::AddNode { node, kind, mode, .. } => {
508
                out.push_str(&format!("A {} ({:?}{}{})\n", path_of(node), kind, if mode.exec { ", exec" } else { "" }, if mode.opaque { ", opaque" } else { "" }));
509
            }
510
            TreeOp::RemoveNode { node, .. } => out.push_str(&format!("D {}\n", path_of(node))),
511
            TreeOp::Move { node, name, .. } => out.push_str(&format!("R {} -> {}\n", path_of(node), name)),
512
            TreeOp::SetMode { node, mode, .. } => {
513
                out.push_str(&format!("M {} mode: exec={} opaque={}\n", path_of(node), mode.exec, mode.opaque));
514
            }
515
        }
516
    }
517
    let mut last_node: Option<NodeId> = None;
518
    for e in &change.edits {
519
        let n = e.node();
520
        if last_node != Some(n) {
521
            out.push_str(&format!("--- {}\n", path_of(&n)));
522
            last_node = Some(n);
523
        }
524
        match e {
525
            Edit::Insert { lines, .. } => {
526
                for l in lines {
527
                    out.push('+');
528
                    out.push_str(&String::from_utf8_lossy(l));
529
                    if !l.ends_with(b"\n") {
530
                        out.push('\n');
531
                    }
532
                }
533
            }
534
            Edit::Delete { atoms, .. } => {
535
                for r in atoms {
536
                    for i in r.from..r.to {
537
                        let content = base.file(&n).and_then(|g| g.content(&(r.change, i))).unwrap_or(b"<unknown>\n");
538
                        out.push('-');
539
                        out.push_str(&String::from_utf8_lossy(content));
540
                        if !content.ends_with(b"\n") {
541
                            out.push('\n');
542
                        }
543
                    }
544
                }
545
            }
546
            Edit::Replace { old, new, .. } => {
547
                out.push_str(&format!(
548
                    "  opaque content {} -> {}\n",
549
                    old.map(|o| o.short(12)).unwrap_or_else(|| "none".into()),
550
                    new.map(|o| o.short(12)).unwrap_or_else(|| "none".into())
551
                ));
552
            }
553
        }
554
    }
555
    out
556
}