@@ -1716,6 +1716,8 @@ bool FPlasticShelveWorker::Execute(FPlasticSourceControlCommand& InCommand)
1716
1716
1717
1717
int32 PreviousShelveId = ISourceControlState::INVALID_REVISION;
1718
1718
1719
+ InCommand.bCommandSuccessful = true ;
1720
+
1719
1721
if (InCommand.Changelist .IsInitialized ())
1720
1722
{
1721
1723
TSharedRef<FPlasticSourceControlChangelistState, ESPMode::ThreadSafe> ChangelistState = GetProvider ().GetStateInternal (InCommand.Changelist );
@@ -1727,37 +1729,48 @@ bool FPlasticShelveWorker::Execute(FPlasticSourceControlCommand& InCommand)
1727
1729
{
1728
1730
FilesToShelve = FileNamesFromFileStates (ChangelistState->Files );
1729
1731
}
1730
- // If the command has specified some files but not all , and if there was already a shelve with ,
1732
+ // If the command has specified some files, and if there was already a shelve,
1731
1733
// ensure that the previous shelved files are also put back into the new one.
1732
1734
// This is to mimic Perforce behavior, where we can add files to a shelve after we made more changes.
1733
1735
// NOTE: this is a workaround for the fact that we cannot edit an existing shelve.
1734
- else if ((FilesToShelve. Num () < ChangelistState->Files . Num ()) && (ChangelistState-> ShelvedFiles .Num () > 0 ) )
1736
+ else if (ChangelistState->ShelvedFiles .Num () > 0 )
1735
1737
{
1736
1738
for (const FSourceControlStateRef& ShelveFile : ChangelistState->ShelvedFiles )
1737
1739
{
1738
1740
FilesToShelve.AddUnique (ShelveFile->GetFilename ());
1739
1741
}
1740
1742
}
1741
- }
1742
1743
1743
- // If the command is issued on the default changelist, then we need to create a new changelist,
1744
- // move the files to the new changelist, then shelve the files
1745
- if (InCommand.Changelist .IsDefault ())
1746
- {
1747
- // Create a new numbered persistent changelist ala Perforce
1748
- Changelist = CreatePendingChangelist (GetProvider (), Operation->GetDescription ().ToString (), InCommand.InfoMessages , InCommand.ErrorMessages );
1749
- if (Changelist.IsInitialized ())
1744
+ // Ensure that all the files to shelve are indeed in the changelist, so that we can actually shelve them
1745
+ // NOTE: this is because of the workaround that requires to create a new shelve and delete the old one
1746
+ for (FString& FileToShelve : FilesToShelve)
1750
1747
{
1751
- InCommand.bCommandSuccessful = MoveFilesToChangelist (GetProvider (), Changelist, FilesToShelve, InCommand.InfoMessages , InCommand.ErrorMessages );
1752
- if (InCommand.bCommandSuccessful )
1748
+ if (!ChangelistState->Files .ContainsByPredicate ([&FileToShelve](const FSourceControlStateRef& FileState) { return FileToShelve == FileState->GetFilename (); }))
1753
1749
{
1754
- MovedFiles = FilesToShelve;
1750
+ FPaths::MakePathRelativeTo (FileToShelve, *FPaths::ProjectDir ());
1751
+ UE_LOG (LogSourceControl, Error, TEXT (" The file /%s is not in the changelist anymore, so the shelve cannot be updated. Unshelve the corresponding change and retry." ), *FileToShelve);
1752
+ InCommand.bCommandSuccessful = false ;
1755
1753
}
1756
1754
}
1757
1755
}
1758
- else
1756
+
1757
+ if (InCommand.bCommandSuccessful )
1759
1758
{
1760
- InCommand.bCommandSuccessful = true ;
1759
+ // If the command is issued on the default changelist, then we need to create a new changelist,
1760
+ // move the files to the new changelist, then shelve the files
1761
+ if (InCommand.Changelist .IsDefault ())
1762
+ {
1763
+ // Create a new numbered persistent changelist ala Perforce
1764
+ Changelist = CreatePendingChangelist (GetProvider (), Operation->GetDescription ().ToString (), InCommand.InfoMessages , InCommand.ErrorMessages );
1765
+ if (Changelist.IsInitialized ())
1766
+ {
1767
+ InCommand.bCommandSuccessful = MoveFilesToChangelist (GetProvider (), Changelist, FilesToShelve, InCommand.InfoMessages , InCommand.ErrorMessages );
1768
+ if (InCommand.bCommandSuccessful )
1769
+ {
1770
+ MovedFiles = FilesToShelve;
1771
+ }
1772
+ }
1773
+ }
1761
1774
}
1762
1775
1763
1776
if (InCommand.bCommandSuccessful )
0 commit comments