36 std::vector<BOARD_ITEM*>& aAdded, std::vector<BOARD_ITEM*>& aRemoved,
37 std::vector<BOARD_ITEM*>& aChanged )
39 auto it1 = aAncestorSet.begin();
40 auto it2 = aOtherSet.begin();
42 while( it1 != aAncestorSet.end() && it2 != aOtherSet.end() )
49 aRemoved.push_back( item1 );
54 aAdded.push_back( item2 );
59 if( !( *item1 == *item2 ) )
60 aChanged.push_back( item1 );
73 const auto ancestor_set = aAncestor->
GetItemSet();
91 wxLogTrace(
traceGit,
"PCB merge driver: no common ancestor, declining merge" );
92 return GIT_PASSTHROUGH;
99 wxLogTrace(
traceGit,
"PCB merge driver: could not load merge blobs (rc=%d)", rc );
112 std::unique_ptr<BOARD> ancestor_board;
113 std::unique_ptr<BOARD> ours_board;
114 std::unique_ptr<BOARD> theirs_board;
118 ancestor_board.reset(
static_cast<BOARD*
>( ancestor_parser.
Parse() ) );
119 ours_board.reset(
static_cast<BOARD*
>( ours_parser.
Parse() ) );
120 theirs_board.reset(
static_cast<BOARD*
>( theirs_parser.
Parse() ) );
124 wxLogTrace(
traceGit,
"Could not parse board: %s", e.
What() );
129 wxLogTrace(
traceGit,
"Could not parse board: unknown error" );
141 std::set_intersection( ancestor_ours_differences.
m_changed.begin(),
142 ancestor_ours_differences.
m_changed.end(),
143 ancestor_theirs_differences.
m_removed.begin(),
144 ancestor_theirs_differences.
m_removed.end(),
146 std::set_intersection( ancestor_theirs_differences.
m_changed.begin(),
147 ancestor_theirs_differences.
m_changed.end(),
148 ancestor_ours_differences.
m_removed.begin(),
149 ancestor_ours_differences.
m_removed.end(),
151 std::set_intersection( ancestor_ours_differences.
m_changed.begin(),
152 ancestor_ours_differences.
m_changed.end(),
153 ancestor_theirs_differences.
m_changed.begin(),
154 ancestor_theirs_differences.
m_changed.end(),
169 const bool planResolved = plan.
Resolved();
172 theirs_board.get(), std::move( plan ) );
173 std::unique_ptr<BOARD> merged = applier.
Apply();
177 wxLogTrace(
traceGit,
"PCB merge applier failed to produce a board" );
182 std::string serialized;
189 pcbIO.
Format( merged.get() );
194 wxLogTrace(
traceGit,
"Failed to serialize merged board: %s", ioe.
What() );
200 wxLogTrace(
traceGit,
"Failed to allocate git_buf for merged board" );
209 return GIT_EMERGECONFLICT;
221 unsigned int* aModeOut, git_buf* aMergedOut )
std::set< BOARD_ITEM *, CompareByUuid > BOARD_ITEM_SET
Set of BOARD_ITEMs ordered by UUID.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
const BOARD_ITEM_SET GetItemSet()
Collect every owned item (tracks, zones, generators, footprints, drawings, markers,...
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
Three-way merge plan generator.
MERGE_PLAN Plan(const DOCUMENT_DIFF &aAncestorOurs, const DOCUMENT_DIFF &aAncestorTheirs) const
Plan the merge given the canonical pair of diffs.
Diff two already-parsed BOARDs and produce a DOCUMENT_DIFF.
DOCUMENT_DIFF Diff() override
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
Materialize a MERGE_PLAN into a real merged BOARD.
std::unique_ptr< BOARD > Apply()
Produce the merged board.
std::set< BOARD_ITEM * > both_modified
void findSetDifferences(const BOARD_ITEM_SET &aAncestorSet, const BOARD_ITEM_SET &aOtherSet, std::vector< BOARD_ITEM * > &aAdded, std::vector< BOARD_ITEM * > &aRemoved, std::vector< BOARD_ITEM * > &aChanged)
git_merge_driver_source * m_mergeDriver
KIGIT_PCB_MERGE_DIFFERENCES compareBoards(BOARD *aAncestor, BOARD *aOther)
std::set< BOARD_ITEM * > they_modified_we_deleted
static int Apply(const git_merge_driver_source *aSrc, const char **aPathOut, unsigned int *aModeOut, git_buf *aMergedOut)
libgit2 merge-driver apply callback shim.
std::set< BOARD_ITEM * > we_modified_they_deleted
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
void Format(const BOARD_ITEM *aItem) const
Output aItem to aFormatter in s-expression format.
void SetOutputFormatter(OUTPUTFORMATTER *aFormatter)
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
const wxChar *const traceGit
Flag to enable Git debugging output.
int WriteToGitBuf(git_buf *aBuf, const std::string &aContent)
Allocate a libgit2-owned buffer big enough for aContent and copy the bytes plus a trailing NUL.
int LoadMergeBlobs(const git_merge_driver_source *aSource, MERGE_BLOBS &aBlobs)
Look up the ancestor/ours/theirs blobs of a merge-driver source and decode them into aBlobs.
int ApplyMergeDriver(const git_merge_driver_source *aSrc, const char **aPathOut, unsigned int *aModeOut, git_buf *aMergedOut)
Shared libgit2 merge-driver apply callback shim.
Pcbnew s-expression file format parser definition.
Result of planning a 3-way merge.
Decoded ancestor/ours/theirs blob contents for a 3-way merge driver.
std::string ancestor
Empty when there is no common ancestor.
std::vector< BOARD_ITEM * > m_removed
std::vector< BOARD_ITEM * > m_changed
std::vector< BOARD_ITEM * > m_added
wxLogTrace helper definitions.