Merge branch 'main' of github.com:steveyegge/beads

This commit is contained in:
Steve Yegge
2025-11-06 19:42:06 -08:00
3 changed files with 124 additions and 119 deletions

File diff suppressed because one or more lines are too long

View File

@@ -459,6 +459,9 @@ func createSyncFunc(ctx context.Context, store storage.Storage, autoCommit, auto
return
}
// Cache multi-repo paths to avoid redundant calls (bd-we4p)
multiRepoPaths := getMultiRepoJSONLPaths()
// Check for exclusive lock before processing database
beadsDir := filepath.Dir(jsonlPath)
skip, holder, err := types.ShouldSkipDatabase(beadsDir)
@@ -502,7 +505,6 @@ func createSyncFunc(ctx context.Context, store storage.Storage, autoCommit, auto
// Capture left snapshot (pre-pull state) for 3-way merge
// This is mandatory for deletion tracking integrity
// In multi-repo mode, capture snapshots for all JSONL files
multiRepoPaths := getMultiRepoJSONLPaths()
if multiRepoPaths != nil {
// Multi-repo mode: snapshot each JSONL file
for _, path := range multiRepoPaths {
@@ -572,16 +574,15 @@ func createSyncFunc(ctx context.Context, store storage.Storage, autoCommit, auto
// Perform 3-way merge and prune deletions
// In multi-repo mode, apply deletions for each JSONL file
multiRepoPathsForMerge := getMultiRepoJSONLPaths()
if multiRepoPathsForMerge != nil {
// Multi-repo mode: merge/prune for each JSONL
for _, path := range multiRepoPathsForMerge {
if multiRepoPaths != nil {
// Multi-repo mode: merge/prune for each JSONL
for _, path := range multiRepoPaths {
if err := applyDeletionsFromMerge(syncCtx, store, path); err != nil {
log.log("Error during 3-way merge for %s: %v", path, err)
return
}
}
log.log("Applied deletions from %d repos", len(multiRepoPathsForMerge))
log.log("Applied deletions from %d repos", len(multiRepoPaths))
} else {
// Single-repo mode
if err := applyDeletionsFromMerge(syncCtx, store, jsonlPath); err != nil {
@@ -610,9 +611,8 @@ func createSyncFunc(ctx context.Context, store storage.Storage, autoCommit, auto
// Update base snapshot after successful import
// In multi-repo mode, update snapshots for all JSONL files
multiRepoPathsForSnapshot := getMultiRepoJSONLPaths()
if multiRepoPathsForSnapshot != nil {
for _, path := range multiRepoPathsForSnapshot {
if multiRepoPaths != nil {
for _, path := range multiRepoPaths {
if err := updateBaseSnapshot(path); err != nil {
log.log("Warning: failed to update base snapshot for %s: %v", path, err)
}

View File

@@ -323,8 +323,8 @@ func computeAcceptedDeletions(basePath, leftPath, mergedPath string) ([]string,
for id, baseLine := range baseIndex {
// Issue in base but not in merged
if !mergedIDs[id] {
// Check if unchanged locally using semantic JSON comparison
if leftLine, existsInLeft := leftIndex[id]; existsInLeft && jsonEquals(leftLine, baseLine) {
// Check if unchanged locally - try raw equality first, then semantic JSON comparison
if leftLine, existsInLeft := leftIndex[id]; existsInLeft && (leftLine == baseLine || jsonEquals(leftLine, baseLine)) {
deletions = append(deletions, id)
}
}