Skip to content

Add staging, tags, remotes, three-way merges, fsck and expand CLI#12

Open
WorkofAditya wants to merge 1 commit into
mainfrom
codex/find-current-merging-features-in-leaf
Open

Add staging, tags, remotes, three-way merges, fsck and expand CLI#12
WorkofAditya wants to merge 1 commit into
mainfrom
codex/find-current-merging-features-in-leaf

Conversation

@WorkofAditya
Copy link
Copy Markdown
Owner

Motivation

  • Provide a richer VCS feature set including staging/index, lightweight tags, local remotes, and proper three-way merges with conflict handling.
  • Make commits more robust (explicit parents list, snapshot handling) and add repository integrity checks and remote sync primitives.
  • Improve user workflow with add, reset, revert, tag, fetch/push/pull, clone, and merge lifecycle commands (--continue/--abort).

Description

  • Implement a persistent staging index and merge state stored in .leaf/index.json and .leaf/MERGE_STATE.json and add helper APIs in Modules/storage.py (load_index, save_index, load_merge_state, save_merge_state, clear_merge_state, etc.).
  • Enhance commit creation to support explicit parents arrays, create full snapshot for the first commit, support staged commits (apply index to base state), and write commit objects and states via _create_commit, _write_commit_files, and related helpers in Modules/commands.py.
  • Add three-way merge logic with conflict markers, merge base calculation, and merge lifecycle commands leaf_merge, leaf_merge_continue, and leaf_merge_abort, plus helper merge functions and find_merge_base in Modules/graph.py.
  • Add index commands leaf_add and leaf_reset, tagging with leaf_tag, local remotes with leaf_remote/leaf_fetch/leaf_push/leaf_pull, leaf_clone, leaf_revert, and leaf_fsck for repository integrity checks, and wire them into the CLI entrypoint (leaf).
  • Refactor storage to atomic JSON saves (_atomic_json_save) and robust loaders (_load_json, safe_load_log) and improve rebuild logic (first_parent_chain) and working-tree write error handling.
  • Update status, log, diff, checkout, restore flows to account for staging and merge state, clear index/merge state where appropriate, and surface tags and merge parents in logs and status outputs.

Testing

  • Added a comprehensive integration-style test suite tests/test_leaf_cli.py exercising init/save/branch/checkout/fast-forward and three-way merges, conflict handling (--continue/--abort), staging, reset, tag, revert, fsck, and remote fetch/push/pull/clone workflows.
  • Ran the test suite with pytest (including the new tests/test_leaf_cli.py) and all tests completed successfully.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant