@@ -833,64 +833,6 @@ DepotOperations::SyncCommand(
833833 return nullptr ;
834834 }
835835
836- typedef HashSet<DepotString, StringInfo::EqualInsensitive> DepotFileHashSet;
837- typedef Map<DepotString, FDepotResultSizesNode, StringInfo::LessInsensitive> DepotFileClientSizeMapType;
838-
839- DepotFileHashSet writeableHeadDepotFiles;
840- DepotFileHashSet writeableHaveDepotFiles;
841- DepotFileHashSet symlinkDepotFiles;
842- DepotFileHashSet diffDepotFiles;
843- DepotFileClientSizeMapType depotFileClientSizeMap;
844-
845- if ((syncFlags & (DepotSyncFlags::Preview | DepotSyncFlags::Flush)) != 0 && (syncFlags & DepotSyncFlags::IgnoreOutput) == 0 )
846- {
847- DepotRevision haveRevision = (syncFlags & DepotSyncFlags::Force) ? FDepotRevision::New<FDepotRevisionNone>() : FDepotRevision::New<FDepotRevisionHave>();
848- for (const DepotString& fileSpec : fileSpecs)
849- {
850- const DepotString haveFileSpec = CreateFileSpec (fileSpec, haveRevision, CreateFileSpecFlags::OverrideRevison);
851- if (haveFileSpec.empty ())
852- {
853- reportError (StringInfo::Format (" Invalid haveFileSpec for fileSpec='%s' rev='%s'" , fileSpec.c_str (), FDepotRevision::ToString (haveRevision).c_str ()));
854- return nullptr ;
855- }
856-
857- const DepotString& headFileSpec = fileSpec;
858- if (headFileSpec.empty ())
859- {
860- reportError (StringInfo::Format (" Invalid headFileSpec for fileSpec='%s' rev='%s'" , fileSpec.c_str (), FDepotRevision::ToString (revision).c_str ()));
861- return nullptr ;
862- }
863-
864- DepotResultDiff2 diff2 = Diff2 (depotClient, haveFileSpec, headFileSpec);
865- for (size_t diff2NodeIndex = 0 ; diff2NodeIndex < diff2->NodeCount (); ++diff2NodeIndex)
866- {
867- FDepotResultDiff2Node node = diff2->Node (diff2NodeIndex);
868- diffDepotFiles.insert (node.DepotFile ());
869- diffDepotFiles.insert (node.DepotFile2 ());
870-
871- if (DepotInfo::IsWritableFileType (node.Type ()))
872- writeableHaveDepotFiles.insert (node.DepotFile ());
873- if (DepotInfo::IsWritableFileType (node.Type2 ()))
874- writeableHeadDepotFiles.insert (node.DepotFile2 ());
875-
876- if (DepotInfo::IsSymlinkFileType (node.Type ()))
877- symlinkDepotFiles.insert (node.DepotFile ());
878- if (DepotInfo::IsSymlinkFileType (node.Type2 ()))
879- symlinkDepotFiles.insert (node.DepotFile2 ());
880- }
881-
882- if ((syncFlags & DepotSyncFlags::ClientSize) != 0 && depotClient->GetServerApiLevel () >= DepotProtocol::SERVER_SIZES_C)
883- {
884- DepotResultSizes sizes = Sizes (depotClient, headFileSpec, SizesFlags::ClientSize);
885- for (size_t sizesNodeIndex = 0 ; sizesNodeIndex < sizes->NodeCount (); ++sizesNodeIndex)
886- {
887- FDepotResultSizesNode node = sizes->Node (sizesNodeIndex);
888- depotFileClientSizeMap[node.DepotFile ()] = node;
889- }
890- }
891- }
892- }
893-
894836 DepotClientLogCallback onClientLogCallback = std::make_shared<FDepotClientLogCallback>([log](LogChannel::Enum channel, const char * severity, const char * text) -> void
895837 {
896838 if (log != nullptr )
@@ -972,6 +914,55 @@ DepotOperations::SyncCommand(
972914 }
973915 }
974916
917+ typedef HashSet<DepotString, StringInfo::EqualInsensitive> DepotFileHashSet;
918+ typedef Map<DepotString, FDepotResultSizesNode, StringInfo::LessInsensitive> DepotFileClientSizeMapType;
919+
920+ DepotFileHashSet writeableHeadDepotFiles;
921+ DepotFileHashSet writeableHaveDepotFiles;
922+ DepotFileHashSet symlinkDepotFiles;
923+ DepotFileHashSet diffDepotFiles;
924+ DepotFileClientSizeMapType depotFileClientSizeMap;
925+
926+ if (syncFlags & (DepotSyncFlags::Preview | DepotSyncFlags::Flush))
927+ {
928+ DepotResultDiff2 diff2 = Diff2Stat (depotClient, syncFlags, fileSpecs, modifications);
929+ if (diff2.get () == nullptr || diff2->HasError ())
930+ {
931+ reportError (StringInfo::Format (" Failed get filetype differences. %s" , diff2.get () ? diff2->GetError ().c_str () : " Invalid result" ));
932+ return nullptr ;
933+ }
934+
935+ for (size_t diff2NodeIndex = 0 ; diff2NodeIndex < diff2->NodeCount (); ++diff2NodeIndex)
936+ {
937+ FDepotResultDiff2Node node = diff2->Node (diff2NodeIndex);
938+ diffDepotFiles.insert (node.DepotFile ());
939+ diffDepotFiles.insert (node.DepotFile2 ());
940+
941+ if (DepotInfo::IsWritableFileType (node.Type ()))
942+ writeableHaveDepotFiles.insert (node.DepotFile ());
943+ if (DepotInfo::IsWritableFileType (node.Type2 ()))
944+ writeableHeadDepotFiles.insert (node.DepotFile2 ());
945+
946+ if (DepotInfo::IsSymlinkFileType (node.Type ()))
947+ symlinkDepotFiles.insert (node.DepotFile ());
948+ if (DepotInfo::IsSymlinkFileType (node.Type2 ()))
949+ symlinkDepotFiles.insert (node.DepotFile2 ());
950+ }
951+
952+ for (const DepotString& fileSpec : fileSpecs)
953+ {
954+ if ((syncFlags & DepotSyncFlags::ClientSize) != 0 && depotClient->GetServerApiLevel () >= DepotProtocol::SERVER_SIZES_C)
955+ {
956+ DepotResultSizes sizes = Sizes (depotClient, fileSpec, SizesFlags::ClientSize);
957+ for (size_t sizesNodeIndex = 0 ; sizesNodeIndex < sizes->NodeCount (); ++sizesNodeIndex)
958+ {
959+ FDepotResultSizesNode node = sizes->Node (sizesNodeIndex);
960+ depotFileClientSizeMap[node.DepotFile ()] = node;
961+ }
962+ }
963+ }
964+ }
965+
975966 typedef Map<DepotString, FDepotResultFStatNode, StringInfo::LessInsensitive> OpenedHeadDepotFilesType;
976967 OpenedHeadDepotFilesType openedHeadDepotFiles;
977968
@@ -1159,6 +1150,41 @@ DepotOperations::CreateFileSpecs(
11591150 return fileSpecs;
11601151}
11611152
1153+ DepotResultDiff2
1154+ DepotOperations::Diff2Stat (
1155+ DepotClient& depotClient,
1156+ DepotSyncFlags::Enum syncFlags,
1157+ const DepotStringArray& fileSpecs,
1158+ const DepotSyncActionInfoArray& fileModifications
1159+ )
1160+ {
1161+ DepotResultDiff2 diff2stat = MakeResult<DepotResultDiff2>();
1162+
1163+ DepotRevision haveRevision = (syncFlags & DepotSyncFlags::Force) ? FDepotRevision::New<FDepotRevisionNone>() : FDepotRevision::New<FDepotRevisionHave>();
1164+ for (const DepotString& fileSpec : fileSpecs)
1165+ {
1166+ const DepotString haveFileSpec = CreateFileSpec (fileSpec, haveRevision, CreateFileSpecFlags::OverrideRevison);
1167+ if (haveFileSpec.empty ())
1168+ {
1169+ return MakeErrorResult<DepotResultDiff2>(StringInfo::Format (" Invalid haveFileSpec for fileSpec='%s' rev='%s'" , fileSpec.c_str (), FDepotRevision::ToString (haveRevision).c_str ()));
1170+ }
1171+
1172+ const DepotString& headFileSpec = fileSpec;
1173+ if (headFileSpec.empty ())
1174+ {
1175+ return MakeErrorResult<DepotResultDiff2>(StringInfo::Format (" Invalid headFileSpec for fileSpec='%s'" , fileSpec.c_str ()));
1176+ }
1177+
1178+ DepotResultDiff2 diff2 = Diff2 (depotClient, haveFileSpec, headFileSpec);
1179+ if (diff2.get ())
1180+ {
1181+ diff2stat->Append (diff2->TagList ());
1182+ }
1183+ }
1184+
1185+ return diff2stat;
1186+ }
1187+
11621188DepotResultDiff2
11631189DepotOperations::Diff2 (
11641190 DepotClient& depotClient,
0 commit comments