| 224 | } |
| 225 | |
| 226 | func (p *Pool) vacateCommits(ctx context.Context, ts nano.Ts, dryrun bool) ([]ksuid.KSUID, error) { |
| 227 | main, err := p.Main(ctx) |
| 228 | if err != nil { |
| 229 | return nil, err |
| 230 | } |
| 231 | commit, err := p.commits.FindNearestToTs(ctx, main.Branch.Commit, ts) |
| 232 | if err != nil { |
| 233 | return nil, err |
| 234 | } |
| 235 | branches, err := p.branches.All(ctx) |
| 236 | if err != nil { |
| 237 | return nil, err |
| 238 | } |
| 239 | var conflicts []string |
| 240 | for _, b := range branches { |
| 241 | // Find any branches whose history does not include commit and if any |
| 242 | // are found fail. |
| 243 | path, err := p.commits.Path(ctx, b.Commit) |
| 244 | if err != nil { |
| 245 | return nil, err |
| 246 | } |
| 247 | if !slices.Contains(path, commit) { |
| 248 | conflicts = append(conflicts, b.Name) |
| 249 | } |
| 250 | } |
| 251 | if len(conflicts) > 0 { |
| 252 | slices.Sort(conflicts) |
| 253 | v := "branch does not include commit nearest timestamp" |
| 254 | if len(conflicts) > 1 { |
| 255 | v = "branches do not include commit nearest timestamp" |
| 256 | } |
| 257 | return nil, fmt.Errorf("cannot vacate at selected time: %s in the deletion path: %s", v, strings.Join(conflicts, ", ")) |
| 258 | } |
| 259 | if dryrun { |
| 260 | path, err := p.commits.Path(ctx, commit) |
| 261 | if err != nil { |
| 262 | return nil, err |
| 263 | } |
| 264 | return path[1:], nil |
| 265 | } |
| 266 | return p.commits.SetBase(ctx, commit) |
| 267 | } |
| 268 | |
| 269 | func (p *Pool) vacateBranchStore(ctx context.Context, ts nano.Ts, dryrun bool) error { |
| 270 | var werr error |