137 std::string currentRepoPath;
146 std::shared_ptr<ISubject> eventBus;
159 void logError(
const std::string& message)
const;
170 void logDebug(
const std::string& message)
const;
181 void logInfo(
const std::string& message)
const;
196 bool createDirectory(
const std::filesystem::path& path)
const;
211 bool createFile(
const std::filesystem::path& path,
const std::string& content =
"")
const;
222 std::string getCurrentBranchFromHead()
const;
245 void updateHead(
const std::string& commit_hash)
const;
353 void updateCommitReferences(
const std::string& removedCommitHash,
const std::string& newParentHash)
const;
381 std::optional<CommitInfo>
getCommitByHash(
const std::string& commit_hash)
const;
479 std::vector<CommitInfo>
getBranchHistory(
const std::string& branch_name)
const;
516 bool branchExists(
const std::string& branch_name)
const;
529 std::string
getBranchHead(
const std::string& branch_name)
const;
557 std::vector<std::string>
getCommitFiles(
const std::string& commit_hash)
const;
570 void setMergeState(
const std::string& branch_name,
const std::string& commit_hash)
const;
Defines the interface for the Subject (Publisher) component of the Observer pattern.
Manages all physical file and directory operations within the SVCS repository.
Definition RepositoryManager.hxx:83
std::vector< std::string > getStagedFiles()
Retrieves a list of all files currently marked as staged (indexed).
Definition RepositoryManager.cxx:366
std::string getHeadCommit() const
Retrieves the hash of the current HEAD commit in the repository.
Definition RepositoryManager.cxx:775
void updateBranchReference(const std::string &branchName, const std::string &commitHash) const
Updates branch reference file with commit hash.
Definition RepositoryManager.cxx:260
std::string getCurrentBranch() const
Gets the current branch name.
Definition RepositoryManager.cxx:892
std::string getParentCommitHash(const std::string &commit_hash) const
Retrieves the hash of the parent commit for a given commit.
Definition RepositoryManager.cxx:542
std::string getBranchHead(const std::string &branch_name) const
Gets the head commit of a branch.
Definition RepositoryManager.cxx:907
std::filesystem::path getRepositoryPath() const
Returns the determined root path of the currently active repository.
Definition RepositoryManager.cxx:1064
void setMergeState(const std::string &branch_name, const std::string &commit_hash) const
Sets merge state (for conflict resolution).
Definition RepositoryManager.cxx:986
bool saveStagedChanges(const std::string &message)
Creates a commit from staged changes. (Convenience method often used by the SaveCommand).
Definition RepositoryManager.cxx:764
void updateCommitReferences(const std::string &removedCommitHash, const std::string &newParentHash) const
Updates commit references when a commit is removed.
Definition RepositoryManager.cxx:581
std::vector< CommitInfo > getCommitHistory() const
Retrieves the complete commit history for the current branch.
Definition RepositoryManager.cxx:816
bool isMergeInProgress() const
Checks if a merge is in progress.
Definition RepositoryManager.cxx:1026
bool isRepositoryInitialized(const std::string &path=".")
Checks if a SVCS repository is initialized in the given path or its parents.
Definition RepositoryManager.cxx:312
bool restoreFilesFromCommit(const CommitInfo &commit) const
Restores the working directory files to the state recorded in a specific commit.
Definition RepositoryManager.cxx:716
std::string createCommit(const std::string &message)
Creates a commit from the currently staged files.
Definition RepositoryManager.cxx:463
std::string getMergeBranch() const
Gets the branch being merged.
Definition RepositoryManager.cxx:1037
void clearMergeState() const
Clears merge state (after merge completion/abort).
Definition RepositoryManager.cxx:1006
RepositoryManager(std::shared_ptr< ISubject > bus)
Constructs a RepositoryManager.
Definition RepositoryManager.cxx:28
bool clearStagingArea()
Clears the contents of the staging area (index).
Definition RepositoryManager.cxx:392
std::vector< std::string > getCommitFiles(const std::string &commit_hash) const
Gets all files changed in a commit.
Definition RepositoryManager.cxx:948
void updateHead(const std::string &commit_hash) const
Updates HEAD reference.
Definition RepositoryManager.cxx:415
static std::string generateCommitHash(const std::string &content)
Generates a commit hash from content.
Definition RepositoryManager.cxx:449
bool addFileToStaging(const std::string &filePath)
Attempts to add a file to the staging area (index).
Definition RepositoryManager.cxx:337
bool initializeRepository(const std::string &path, bool force=false)
Initializes a new SVCS repository in the specified path.
Definition RepositoryManager.cxx:50
bool branchExists(const std::string &branch_name) const
Checks if a branch exists.
Definition RepositoryManager.cxx:896
bool removeRepository(const std::filesystem::path &path) const
Attempts to recursively remove the entire SVCS repository structure (e.g., the .svcs directory) and i...
Definition RepositoryManager.cxx:167
std::optional< CommitInfo > getCommitByHash(const std::string &commit_hash) const
Retrieves the CommitInfo structure for a given commit hash.
Definition RepositoryManager.cxx:704
bool revertCommit(const std::string &commit_hash)
Reverts the repository state to a previous commit.
Definition RepositoryManager.cxx:629
std::string getFileContentAtCommit(const std::string &commit_hash, const std::string &file_path) const
Gets the content of a file at a specific commit.
Definition RepositoryManager.cxx:929
std::vector< CommitInfo > getBranchHistory(const std::string &branch_name) const
Retrieves the commit history for a specific branch.
Definition RepositoryManager.cxx:820
Core VCS data structures and object model.
Service layer components and infrastructure services.
Structure containing essential metadata for a single commit.
Definition RepositoryManager.hxx:38
std::string message
The message provided by the user when creating the commit.
Definition RepositoryManager.hxx:49
std::string branch
The branch this commit belongs to.
Definition RepositoryManager.hxx:73
std::string hash
The unique identifier (hash) of the commit.
Definition RepositoryManager.hxx:43
int files_count
The count of files included in this commit.
Definition RepositoryManager.hxx:55
std::string author
The author or user who created the commit.
Definition RepositoryManager.hxx:61
std::string timestamp
Timestamp of when the commit was created.
Definition RepositoryManager.hxx:67