|
SVCS - English Documentation
|
Manages all physical file and directory operations within the SVCS repository. More...
#include <RepositoryManager.hxx>
Public Member Functions | |
| RepositoryManager (std::shared_ptr< ISubject > bus) | |
| Constructs a RepositoryManager. | |
| void | updateHead (const std::string &commit_hash) const |
| Updates HEAD reference. | |
| bool | initializeRepository (const std::string &path, bool force=false) |
| Initializes a new SVCS repository in the specified path. | |
| bool | isRepositoryInitialized (const std::string &path=".") |
| Checks if a SVCS repository is initialized in the given path or its parents. | |
| void | updateBranchReference (const std::string &branchName, const std::string &commitHash) const |
| Updates branch reference file with commit hash. | |
| std::filesystem::path | getRepositoryPath () const |
| Returns the determined root path of the currently active repository. | |
| bool | addFileToStaging (const std::string &filePath) |
| Attempts to add a file to the staging area (index). | |
| std::string | getHeadCommit () const |
| Retrieves the hash of the current HEAD commit in the repository. | |
| std::string | createCommit (const std::string &message) |
| Creates a commit from the currently staged files. | |
| void | updateCommitReferences (const std::string &removedCommitHash, const std::string &newParentHash) const |
| Updates commit references when a commit is removed. | |
| bool | revertCommit (const std::string &commit_hash) |
| Reverts the repository state to a previous commit. | |
| std::optional< CommitInfo > | getCommitByHash (const std::string &commit_hash) const |
| Retrieves the CommitInfo structure for a given commit hash. | |
| std::string | getParentCommitHash (const std::string &commit_hash) const |
| Retrieves the hash of the parent commit for a given commit. | |
| bool | restoreFilesFromCommit (const CommitInfo &commit) const |
| Restores the working directory files to the state recorded in a specific commit. | |
| bool | clearStagingArea () |
| Clears the contents of the staging area (index). | |
| bool | saveStagedChanges (const std::string &message) |
| Creates a commit from staged changes. (Convenience method often used by the SaveCommand). | |
| std::vector< std::string > | getStagedFiles () |
| Retrieves a list of all files currently marked as staged (indexed). | |
| std::vector< CommitInfo > | getCommitHistory () const |
| Retrieves the complete commit history for the current branch. | |
| std::vector< CommitInfo > | getBranchHistory (const std::string &branch_name) const |
| Retrieves the commit history for a specific branch. | |
| std::string | getCurrentBranch () const |
| Gets the current branch name. | |
| bool | removeRepository (const std::filesystem::path &path) const |
| Attempts to recursively remove the entire SVCS repository structure (e.g., the .svcs directory) and its contents. | |
| bool | branchExists (const std::string &branch_name) const |
| Checks if a branch exists. | |
| std::string | getBranchHead (const std::string &branch_name) const |
| Gets the head commit of a branch. | |
| std::string | getFileContentAtCommit (const std::string &commit_hash, const std::string &file_path) const |
| Gets the content of a file at a specific commit. | |
| std::vector< std::string > | getCommitFiles (const std::string &commit_hash) const |
| Gets all files changed in a commit. | |
| void | setMergeState (const std::string &branch_name, const std::string &commit_hash) const |
| Sets merge state (for conflict resolution). | |
| void | clearMergeState () const |
| Clears merge state (after merge completion/abort). | |
| bool | isMergeInProgress () const |
| Checks if a merge is in progress. | |
| std::string | getMergeBranch () const |
| Gets the branch being merged. | |
Static Public Member Functions | |
| static std::string | generateCommitHash (const std::string &content) |
| Generates a commit hash from content. | |
Manages all physical file and directory operations within the SVCS repository.
The RepositoryManager is the core layer responsible for interacting directly with the file system for tasks like initialization, path management, staging, committing, and logging.
|
explicit |
Constructs a RepositoryManager.
| bus | A shared pointer to the event bus (ISubject) for communication. |
| bool svcs::core::RepositoryManager::addFileToStaging | ( | const std::string & | filePath | ) |
Attempts to add a file to the staging area (index).
This typically involves reading the file and updating the index state.
| filePath | The path to the file to be staged. |
true if the file was successfully added, false otherwise. | bool svcs::core::RepositoryManager::branchExists | ( | const std::string & | branch_name | ) | const |
Checks if a branch exists.
| branch_name | The branch name to check. |
| bool svcs::core::RepositoryManager::clearStagingArea | ( | ) |
Clears the contents of the staging area (index).
true if the staging area was successfully cleared, false otherwise. | std::string svcs::core::RepositoryManager::createCommit | ( | const std::string & | message | ) |
Creates a commit from the currently staged files.
| message | Commit message provided by the user. |
|
static |
Generates a commit hash from content.
| content | The content to hash. |
| std::string svcs::core::RepositoryManager::getBranchHead | ( | const std::string & | branch_name | ) | const |
Gets the head commit of a branch.
| branch_name | The branch name. |
| std::vector< CommitInfo > svcs::core::RepositoryManager::getBranchHistory | ( | const std::string & | branch_name | ) | const |
Retrieves the commit history for a specific branch.
| branch_name | The name of the branch. |
| std::optional< CommitInfo > svcs::core::RepositoryManager::getCommitByHash | ( | const std::string & | commit_hash | ) | const |
Retrieves the CommitInfo structure for a given commit hash.
| commit_hash | The hash of the commit to retrieve. |
| std::vector< std::string > svcs::core::RepositoryManager::getCommitFiles | ( | const std::string & | commit_hash | ) | const |
Gets all files changed in a commit.
| commit_hash | The commit hash. |
| std::vector< CommitInfo > svcs::core::RepositoryManager::getCommitHistory | ( | ) | const |
Retrieves the complete commit history for the current branch.
| std::string svcs::core::RepositoryManager::getCurrentBranch | ( | ) | const |
Gets the current branch name.
| std::string svcs::core::RepositoryManager::getFileContentAtCommit | ( | const std::string & | commit_hash, |
| const std::string & | file_path ) const |
Gets the content of a file at a specific commit.
| commit_hash | The commit hash. |
| file_path | The file path. |
| std::string svcs::core::RepositoryManager::getHeadCommit | ( | ) | const |
Retrieves the hash of the current HEAD commit in the repository.
| std::string svcs::core::RepositoryManager::getMergeBranch | ( | ) | const |
Gets the branch being merged.
| std::string svcs::core::RepositoryManager::getParentCommitHash | ( | const std::string & | commit_hash | ) | const |
Retrieves the hash of the parent commit for a given commit.
| commit_hash | The hash of the child commit. |
|
nodiscard |
Returns the determined root path of the currently active repository.
| std::vector< std::string > svcs::core::RepositoryManager::getStagedFiles | ( | ) |
Retrieves a list of all files currently marked as staged (indexed).
| bool svcs::core::RepositoryManager::initializeRepository | ( | const std::string & | path, |
| bool | force = false ) |
Initializes a new SVCS repository in the specified path.
Creates the necessary internal directories and files (e.g., .svcs/).
| path | The directory path where the repository should be created. |
| force | If true, forces initialization even if the directory exists (implementation dependent). |
true if initialization was successful, false otherwise. | bool svcs::core::RepositoryManager::isMergeInProgress | ( | ) | const |
Checks if a merge is in progress.
| bool svcs::core::RepositoryManager::isRepositoryInitialized | ( | const std::string & | path = "." | ) |
Checks if a SVCS repository is initialized in the given path or its parents.
| path | The path to start searching from (defaults to the current directory "."). |
true if a repository structure is found, false otherwise. | bool svcs::core::RepositoryManager::removeRepository | ( | const std::filesystem::path & | path | ) | const |
Attempts to recursively remove the entire SVCS repository structure (e.g., the .svcs directory) and its contents.
| path | The root path of the repository to remove. |
true if removal was successful, false otherwise. | bool svcs::core::RepositoryManager::restoreFilesFromCommit | ( | const CommitInfo & | commit | ) | const |
Restores the working directory files to the state recorded in a specific commit.
| commit | The CommitInfo structure representing the target state. |
true if files were restored successfully, false otherwise. | bool svcs::core::RepositoryManager::revertCommit | ( | const std::string & | commit_hash | ) |
Reverts the repository state to a previous commit.
This is typically used to undo the effects of a previous 'save' (commit).
| commit_hash | The hash of the commit to revert to (or the one before the commit to undo). |
true if the revert was successful, false otherwise. | bool svcs::core::RepositoryManager::saveStagedChanges | ( | const std::string & | message | ) |
Creates a commit from staged changes. (Convenience method often used by the SaveCommand).
| message | Commit message. |
true if the save (commit) was successful, false otherwise. | void svcs::core::RepositoryManager::setMergeState | ( | const std::string & | branch_name, |
| const std::string & | commit_hash ) const |
Sets merge state (for conflict resolution).
| branch_name | Branch being merged. |
| commit_hash | Commit being merged. |
| void svcs::core::RepositoryManager::updateBranchReference | ( | const std::string & | branchName, |
| const std::string & | commitHash ) const |
Updates branch reference file with commit hash.
| branchName | The name of the branch to update. |
| commitHash | The commit hash to set as branch head. |
| void svcs::core::RepositoryManager::updateCommitReferences | ( | const std::string & | removedCommitHash, |
| const std::string & | newParentHash ) const |
Updates commit references when a commit is removed.
| removedCommitHash | The hash of the commit being removed. |
| newParentHash | The new parent hash for dependent commits. |
| void svcs::core::RepositoryManager::updateHead | ( | const std::string & | commit_hash | ) | const |
Updates HEAD reference.
| commit_hash | The commit hash to set as HEAD. |