SVCS - English Documentation
Loading...
Searching...
No Matches
MergeCommand.hxx
Go to the documentation of this file.
1
13#pragma once
14
15#include "ICommand.hxx"
18
19#include <string>
20#include <vector>
21#include <memory>
22
36namespace svcs::cli {
38using namespace svcs::core;
39using namespace svcs::services;
40
50class MergeCommand : public ICommand {
51public:
63 MergeCommand(std::shared_ptr<ISubject> event_bus,
64 std::shared_ptr<RepositoryManager> repo_manager);
65
73 ~MergeCommand() override = default;
74
75 // ICommand interface implementation
85 [[nodiscard]] std::string getName() const override;
86
96 [[nodiscard]] std::string getDescription() const override;
97
107 [[nodiscard]] std::string getUsage() const override;
108
120 bool execute(const std::vector<std::string>& args) override;
121
129 void showHelp() const override;
130
131private:
143 void debugBranchHistory(const std::string& branch_name, const std::string& head_commit) const;
144
156 bool mergeBranch(const std::string& branch_name) const;
157
167 bool abortMerge() const;
168
169
178 [[nodiscard]] bool isMergeInProgress() const;
179
193 std::string findCommonAncestor(const std::string& commit1, const std::string& commit2) const;
194
210 bool performThreeWayMerge(const std::string& ancestor,
211 const std::string& current,
212 const std::string& other) const;
213
231 static bool mergeFileContent(const std::string& ancestor_content,
232 const std::string& current_content,
233 const std::string& other_content,
234 std::string& merged_content);
235
236private:
244 std::shared_ptr<ISubject> event_bus_;
245
253 std::shared_ptr<RepositoryManager> repo_manager_;
254};
255
256}
Declaration of the ICommand interface for all executable CLI commands.
Defines the interface for the Subject (Publisher) component of the Observer pattern.
Declaration of the RepositoryManager class, managing all repository-level file operations.
Interface (abstract base class) for all commands executed via the CLI.
Definition ICommand.hxx:34
bool execute(const std::vector< std::string > &args) override
Executes the merge command with given arguments.
Definition MergeCommand.cxx:38
std::string getName() const override
Gets the command name.
Definition MergeCommand.cxx:26
std::string getDescription() const override
Gets the command description.
Definition MergeCommand.cxx:30
MergeCommand(std::shared_ptr< ISubject > event_bus, std::shared_ptr< RepositoryManager > repo_manager)
Constructs a MergeCommand with event bus and repository manager.
Definition MergeCommand.cxx:21
void showHelp() const override
Displays help information for the command.
Definition MergeCommand.cxx:74
~MergeCommand() override=default
Destructor.
std::string getUsage() const override
Gets the command usage syntax.
Definition MergeCommand.cxx:34
Command-line interface components and command implementations.
Core VCS data structures and object model.
Service layer components and infrastructure services.