Skip to content

Commit

Permalink
#5662: Notify the user to reload the map after a fast-forward has bee…
Browse files Browse the repository at this point in the history
…n affecting the map file on disk.
  • Loading branch information
codereader committed Aug 8, 2021
1 parent a71c7c7 commit 62711c4
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion plugins/vcs/Algorithm.h
Expand Up @@ -203,6 +203,35 @@ inline void tryToFinishMerge(const std::shared_ptr<Repository>& repository)
}
}

inline void performFastForward(const std::shared_ptr<Repository>& repository)
{
auto head = repository->getHead();
auto upstream = head->getUpstream();

// Find the merge base for this ref and its upstream
auto mergeBase = repository->findMergeBase(*head, *upstream);

auto remoteDiffAgainstBase = repository->getDiff(*upstream, *mergeBase);

auto mapPath = repository->getRepositoryRelativePath(GlobalMapModule().getMapName());
bool remoteDiffContainsMap = remoteDiffAgainstBase->containsFile(mapPath);

repository->fastForwardToTrackedRemote();

if (!remoteDiffContainsMap)
{
return;
}

// The map has been modified on disk, so it might be a good choice to reload the map
if (wxutil::Messagebox::Show(_("Map has been updated"),
_("The map file has been updated on disk, reload the map file now?"),
::ui::IDialog::MessageType::MESSAGE_ASK) == ::ui::IDialog::RESULT_YES)
{
GlobalCommandSystem().executeCommand("OpenMap", GlobalMapModule().getMapName());
}
}

inline void syncWithRemote(const std::shared_ptr<Repository>& repository)
{
if (repository->mergeIsInProgress())
Expand Down Expand Up @@ -230,7 +259,7 @@ inline void syncWithRemote(const std::shared_ptr<Repository>& repository)
return;

case RequiredMergeStrategy::FastForward:
repository->fastForwardToTrackedRemote();
performFastForward(repository);
return;
}

Expand Down

0 comments on commit 62711c4

Please sign in to comment.