MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / syncWithRemote

Function syncWithRemote

plugins/vcs/Algorithm.h:240–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240inline void syncWithRemote(const std::shared_ptr<Repository>& repository)
241{
242 if (repository->mergeIsInProgress())
243 {
244 throw GitException(_("Merge in progress"));
245 }
246
247 if (GlobalMapModule().isModified())
248 {
249 throw GitException(_("The map file has unsaved changes, please save before merging."));
250 }
251
252 auto mapPath = repository->getRepositoryRelativePath(GlobalMapModule().getMapName());
253
254 RemoteStatus status = analyseRemoteStatus(repository);
255
256 switch (status.strategy)
257 {
258 case RequiredMergeStrategy::NoMergeRequired:
259 rMessage() << "No merge required." << std::endl;
260 return;
261
262 case RequiredMergeStrategy::JustPush:
263 repository->pushToTrackedRemote();
264 return;
265
266 case RequiredMergeStrategy::FastForward:
267 performFastForward(repository);
268 return;
269 }
270
271 // All the other merge strategies include a recursive merge, prepare it
272 if (status.strategy == RequiredMergeStrategy::MergeMapWithUncommittedChanges)
273 {
274 // Commit the current map changes
275 wxutil::Messagebox::Show(_("Pending Commit"),
276 _("The map file has uncommitted changes, please commit first before integrating."),
277 ::ui::IDialog::MessageType::MESSAGE_CONFIRM);
278 return;
279 }
280
281 if (!repository->isReadyForMerge())
282 {
283 throw git::GitException(_("Repository is not ready for a merge at this point"));
284 }
285
286 if (!repository->getHead() || !repository->getHead()->getUpstream())
287 {
288 throw git::GitException(_("Cannot resolve HEAD and the corresponding upstream branch"));
289 }
290
291 git_merge_analysis_t analysis;
292 git_merge_preference_t preference = GIT_MERGE_PREFERENCE_NONE;
293
294 auto upstream = repository->getHead()->getUpstream();
295 git_oid upstreamOid;
296 auto error = git_reference_name_to_id(&upstreamOid, repository->_get(), upstream->getName().c_str());
297

Callers 1

performSyncMethod · 0.85

Calls 15

GitExceptionClass · 0.85
analyseRemoteStatusFunction · 0.85
rMessageFunction · 0.85
performFastForwardFunction · 0.85
tryToFinishMergeFunction · 0.85
constructVcsFileUriFunction · 0.85
mergeIsInProgressMethod · 0.80
pushToTrackedRemoteMethod · 0.80
isReadyForMergeMethod · 0.80
getHeadMethod · 0.80
getUpstreamMethod · 0.80

Tested by

no test coverage detected