From 601fd4d616d964c5574ae8cfdb87e5edc6f0be7f Mon Sep 17 00:00:00 2001 From: Vadim Macagon Date: Sun, 27 Apr 2014 15:58:11 +0700 Subject: [PATCH] Display a notification when a commit is successful. --- .../Private/MercurialSourceControlClient.cpp | 12 +++++++++++ .../Private/MercurialSourceControlClient.h | 5 +++++ .../Private/MercurialSourceControlWorkers.cpp | 20 +++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/Source/MercurialSourceControl/Private/MercurialSourceControlClient.cpp b/Source/MercurialSourceControl/Private/MercurialSourceControlClient.cpp index 5c4ac2f..c8c873b 100644 --- a/Source/MercurialSourceControl/Private/MercurialSourceControlClient.cpp +++ b/Source/MercurialSourceControl/Private/MercurialSourceControlClient.cpp @@ -452,6 +452,18 @@ bool FClient::CommitFiles( return RunCommand(Command, Output, OutErrors); } +bool FClient::GetWorkingDirectoryParentRevisionID( + const FString& InWorkingDirectory, FString& OutRevisionID, TArray& OutErrors +) const +{ + TArray Options; + // just grab the local revision number + Options.Add(FString(TEXT("--template \"{rev}\""))); + FString Command(TEXT("parents")); + AppendCommandOptions(Command, Options, InWorkingDirectory); + return RunCommand(Command, OutRevisionID, OutErrors); +} + void FClient::AppendCommandOptions( FString& InOutCommand, const TArray& InOptions, const FString& InWorkingDirectory ) diff --git a/Source/MercurialSourceControl/Private/MercurialSourceControlClient.h b/Source/MercurialSourceControl/Private/MercurialSourceControlClient.h index 6b84a0d..fad2748 100644 --- a/Source/MercurialSourceControl/Private/MercurialSourceControlClient.h +++ b/Source/MercurialSourceControl/Private/MercurialSourceControlClient.h @@ -123,6 +123,11 @@ class FClient : public TSharedFromThis const FString& InCommitMessage, TArray& OutErrors ) const; + /** Get the local ID of the working directory's parent revision. */ + bool GetWorkingDirectoryParentRevisionID( + const FString& InWorkingDirectory, FString& OutRevisionID, TArray& OutErrors + ) const; + private: static void AppendCommandOptions( FString& InOutCommand, const TArray& InOptions, diff --git a/Source/MercurialSourceControl/Private/MercurialSourceControlWorkers.cpp b/Source/MercurialSourceControl/Private/MercurialSourceControlWorkers.cpp index 76e96be..32280a7 100644 --- a/Source/MercurialSourceControl/Private/MercurialSourceControlWorkers.cpp +++ b/Source/MercurialSourceControl/Private/MercurialSourceControlWorkers.cpp @@ -283,6 +283,26 @@ bool FCheckInWorker::Execute(FCommand& InCommand) Operation->GetDescription().ToString(), InCommand.ErrorMessages ); + if (bResult) + { + FString RevisionID; + bool bRetrievedID = Client->GetWorkingDirectoryParentRevisionID( + InCommand.GetWorkingDirectory(), RevisionID, InCommand.ErrorMessages + ); + + if (!bRetrievedID) + { + RevisionID = "???"; + } + + Operation->SetSuccessMessage( + FText::Format( + LOCTEXT("CommitSuccessful", "Committed revision {0}."), + FText::FromString(RevisionID) + ) + ); + } + bResult &= Client->GetFileStates( InCommand.GetWorkingDirectory(), InCommand.GetAbsoluteFiles(), FileStates, InCommand.ErrorMessages