77 bool singleFile =
false;
80 if( kindStr ==
"pcb" )
85 else if( kindStr ==
"sch" )
90 else if( kindStr ==
"sym" )
95 else if( kindStr ==
"fp" )
105 wxFprintf( stderr,
_(
"Unknown --kind '%s' (expected pcb, sch, sym, or fp)\n" ),
106 wxString::FromUTF8( kindStr ) );
114 const wxString tmpDir = wxFileName::CreateTempFileName( wxStandardPaths::Get().GetTempDir()
115 + wxFileName::GetPathSeparator()
116 + wxS(
"kicad_mergedriver_" ) );
117 wxRemoveFile( tmpDir );
119 if( !wxFileName::Mkdir( tmpDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
121 wxFprintf( stderr,
_(
"Could not create a temporary directory for the merge.\n" ) );
125 auto staged = [&](
const wxString& aName )
127 return tmpDir + wxFileName::GetPathSeparator() + aName + wxS(
"." ) + ext;
130 const wxString stagedAncestor = staged( wxS(
"ancestor" ) );
131 const wxString stagedOurs = staged( wxS(
"ours" ) );
132 const wxString stagedTheirs = staged( wxS(
"theirs" ) );
133 const wxString stagedOut = staged( wxS(
"merged" ) );
135 bool copied = wxCopyFile( ancestor, stagedAncestor ) && wxCopyFile( ours, stagedOurs )
136 && wxCopyFile( theirs, stagedTheirs );
140 wxFileName::Rmdir( tmpDir, wxPATH_RMDIR_RECURSIVE );
141 wxFprintf( stderr,
_(
"Could not stage merge inputs.\n" ) );
149 stagedOut,
false, singleFile,
nullptr );
155 && wxFileExists( stagedOut ) )
157 if( !wxCopyFile( stagedOut,
output ) )
159 wxFileName::Rmdir( tmpDir, wxPATH_RMDIR_RECURSIVE );
160 wxFprintf( stderr,
_(
"Could not write merged output.\n" ) );
165 wxFileName::Rmdir( tmpDir, wxPATH_RMDIR_RECURSIVE );
int DispatchMerge(KIWAY &aKiway, DOC_KIND aKind, const wxString &aAncestor, const wxString &aOurs, const wxString &aTheirs, const wxString &aOutput, bool aInteractive, bool aSingleFile, REPORTER *aReporter)
Run a 3-way document/library merge by calling the owning kiface's KIFACE_MERGE_DOCUMENT function expo...