38 std::vector<BOARD_ITEM*>& aAdded, std::vector<BOARD_ITEM*>& aRemoved,
39 std::vector<BOARD_ITEM*>& aChanged )
41 auto it1 = aAncestorSet.begin();
42 auto it2 = aOtherSet.begin();
44 while( it1 != aAncestorSet.end() && it2 != aOtherSet.end() )
51 aRemoved.push_back( item1 );
56 aAdded.push_back( item2 );
61 if( !( *item1 == *item2 ) )
62 aChanged.push_back( item1 );
75 const auto ancestor_set = aAncestor->
GetItemSet();
94 ? KICAD_FORMAT::FORMAT_MODE::COMPACT_TEXT_PROPERTIES
95 : KICAD_FORMAT::FORMAT_MODE::NORMAL );
109 wxLogTrace(
traceGit,
"PCB merge driver: no common ancestor, declining merge" );
110 return GIT_PASSTHROUGH;
117 wxLogTrace(
traceGit,
"PCB merge driver: could not load merge blobs (rc=%d)", rc );
130 std::unique_ptr<BOARD> ancestor_board;
131 std::unique_ptr<BOARD> ours_board;
132 std::unique_ptr<BOARD> theirs_board;
136 ancestor_board.reset(
static_cast<BOARD*
>( ancestor_parser.
Parse() ) );
137 ours_board.reset(
static_cast<BOARD*
>( ours_parser.
Parse() ) );
138 theirs_board.reset(
static_cast<BOARD*
>( theirs_parser.
Parse() ) );
142 wxLogTrace(
traceGit,
"Could not parse board: %s", e.
What() );
147 wxLogTrace(
traceGit,
"Could not parse board: unknown error" );
159 std::set_intersection( ancestor_ours_differences.
m_changed.begin(),
160 ancestor_ours_differences.
m_changed.end(),
161 ancestor_theirs_differences.
m_removed.begin(),
162 ancestor_theirs_differences.
m_removed.end(),
164 std::set_intersection( ancestor_theirs_differences.
m_changed.begin(),
165 ancestor_theirs_differences.
m_changed.end(),
166 ancestor_ours_differences.
m_removed.begin(),
167 ancestor_ours_differences.
m_removed.end(),
169 std::set_intersection( ancestor_ours_differences.
m_changed.begin(),
170 ancestor_ours_differences.
m_changed.end(),
171 ancestor_theirs_differences.
m_changed.begin(),
172 ancestor_theirs_differences.
m_changed.end(),
187 const bool planResolved =
plan.Resolved();
190 theirs_board.get(), std::move(
plan ) );
191 std::unique_ptr<BOARD> merged = applier.
Apply();
195 wxLogTrace(
traceGit,
"PCB merge applier failed to produce a board" );
200 std::string serialized;
208 wxLogTrace(
traceGit,
"Failed to serialize merged board: %s", ioe.
What() );
214 wxLogTrace(
traceGit,
"Failed to allocate git_buf for merged board" );
223 return GIT_EMERGECONFLICT;
235 unsigned int* aModeOut, git_buf* aMergedOut )
std::set< BOARD_ITEM *, CompareByUuid > BOARD_ITEM_SET
Set of BOARD_ITEMs ordered by UUID.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
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.
static std::string FormatBoard(BOARD *aBoard)
Serialize a board to a complete, prettified .kicad_pcb file image.
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 PCB_IO derivation for saving and loading Pcbnew s-expression formatted files.
void FormatBoardToFormatter(OUTPUTFORMATTER *aOut, BOARD *aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr)
Serialize a BOARD to an OUTPUTFORMATTER without file I/O or Prettify.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
const wxChar *const traceGit
Flag to enable Git debugging output.
static std::vector< PENDING_PROPERTY > plan(const EDA_ITEM &aSource, const EDA_ITEM &aTarget, const std::set< wxString > &aEnabledKeys)
Target properties to write, paired with values read off the source.
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.