Skip to content

Commit 8d9714e

Browse files
committed
style: clang format fixes
ACP-21694
1 parent f4e5de7 commit 8d9714e

File tree

7 files changed

+114
-92
lines changed

7 files changed

+114
-92
lines changed

p4-fusion/commands/change_list.cc

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ void ChangeList::PrepareDownload(const BranchSet& branchSet)
5656

5757
std::unique_lock<std::mutex> lock(*cl.stateMutex);
5858
cl.state = Described;
59-
cl.stateCV->notify_all(); });
59+
cl.stateCV->notify_all();
60+
});
6061
}
6162

6263
void ChangeList::StartDownloadAndLFSUpload(int nPrintBatch)
@@ -107,7 +108,8 @@ void ChangeList::StartDownloadAndLFSUpload(int nPrintBatch)
107108

108109
// Download any remaining files that were smaller in number than the total batch size.
109110
// Additionally, signal the batch processing end.
110-
cl.DownloadBatch(printBatchFiles, printBatchFileData); });
111+
cl.DownloadBatch(printBatchFiles, printBatchFileData);
112+
});
111113
}
112114

113115
void ChangeList::DownloadBatch(std::shared_ptr<std::vector<std::string>> printBatchFiles, std::shared_ptr<std::vector<FileData*>> printBatchFileData)
@@ -118,37 +120,37 @@ void ChangeList::DownloadBatch(std::shared_ptr<std::vector<std::string>> printBa
118120
// Only perform the batch processing when there are files to process.
119121
if (!printBatchFileData->empty())
120122
{
121-
const PrintResult& printData = p4->PrintFiles(*printBatchFiles);
123+
const PrintResult& printData = p4->PrintFiles(*printBatchFiles);
122124
for (int i = 0; i < printBatchFiles->size(); i++)
123125
{
124-
std::string filePath = P4Unescape(printBatchFileData->at(i)->GetRelativeDepotPath());
125-
// If in LFS mode, we determine whether a file is LFS-tracked, and if so, we do produce a pointer file and upload the file contents.
126-
if (! lfsClient || !lfsClient->IsLFSTracked(filePath))
127-
{
128-
printBatchFileData->at(i)->MoveContentsOnceFrom(printData.GetPrintData().at(i).contents);
129-
}
130-
else
131-
{
132-
const auto& fileContents = printData.GetPrintData().at(i).contents;
133-
const std::vector<char> pointerFileContents = lfsClient->CreatePointerFileContents(fileContents);
134-
Communicator::UploadResult uploadResult = lfsClient->UploadFile(fileContents);
135-
switch (uploadResult)
136-
{
137-
case Communicator::UploadResult::Uploaded:
138-
SUCCESS("Uploaded file " << filePath << " to LFS (" << fileContents.size() << " bytes)");
139-
break;
140-
case Communicator::UploadResult::AlreadyExists:
141-
SUCCESS("File " << filePath << " already exists in LFS, skipping upload");
142-
break;
143-
case Communicator::UploadResult::Error:
144-
ERR("Failed to upload file " << filePath << " to LFS");
145-
// Not nice, but we have no other means to signal any intermediate errors from here
146-
std::abort();
147-
}
148-
149-
// git blob content should be a pointer file, so replace the contents
150-
printBatchFileData->at(i)->MoveContentsOnceFrom(pointerFileContents);
151-
}
126+
std::string filePath = P4Unescape(printBatchFileData->at(i)->GetRelativeDepotPath());
127+
// If in LFS mode, we determine whether a file is LFS-tracked, and if so, we do produce a pointer file and upload the file contents.
128+
if (!lfsClient || !lfsClient->IsLFSTracked(filePath))
129+
{
130+
printBatchFileData->at(i)->MoveContentsOnceFrom(printData.GetPrintData().at(i).contents);
131+
}
132+
else
133+
{
134+
const auto& fileContents = printData.GetPrintData().at(i).contents;
135+
const std::vector<char> pointerFileContents = lfsClient->CreatePointerFileContents(fileContents);
136+
Communicator::UploadResult uploadResult = lfsClient->UploadFile(fileContents);
137+
switch (uploadResult)
138+
{
139+
case Communicator::UploadResult::Uploaded:
140+
SUCCESS("Uploaded file " << filePath << " to LFS (" << fileContents.size() << " bytes)");
141+
break;
142+
case Communicator::UploadResult::AlreadyExists:
143+
SUCCESS("File " << filePath << " already exists in LFS, skipping upload");
144+
break;
145+
case Communicator::UploadResult::Error:
146+
ERR("Failed to upload file " << filePath << " to LFS");
147+
// Not nice, but we have no other means to signal any intermediate errors from here
148+
std::abort();
149+
}
150+
151+
// git blob content should be a pointer file, so replace the contents
152+
printBatchFileData->at(i)->MoveContentsOnceFrom(pointerFileContents);
153+
}
152154
}
153155
}
154156

@@ -158,7 +160,8 @@ void ChangeList::DownloadBatch(std::shared_ptr<std::vector<std::string>> printBa
158160
{
159161
state = CommitReady;
160162
stateCV->notify_all();
161-
} });
163+
}
164+
});
162165
}
163166

164167
void ChangeList::WaitForBeingCommitReady()

p4-fusion/lfs/communication/lfscomm.cc

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ const char* GetUserAgent()
2626
static std::once_flag init_flag;
2727
std::call_once(init_flag, []()
2828
{
29-
curl_version_info_data* version_info = curl_version_info(CURLVERSION_NOW);
30-
if (version_info && version_info->version)
31-
{
32-
result = std::string("curl/") + version_info->version;
33-
} });
29+
curl_version_info_data* version_info = curl_version_info(CURLVERSION_NOW);
30+
if (version_info && version_info->version)
31+
{
32+
result = std::string("curl/") + version_info->version;
33+
}
34+
});
3435

3536
return result.c_str();
3637
}
@@ -191,14 +192,16 @@ RequestResult PerformPostRequestWithRetry(CURL* curl,
191192
SetupRequest(curl, url, data, data_size, headers, &result, auth);
192193

193194
return PerformRequestWithRetry([&]() -> RequestResult
194-
{
195-
result.curl_result = curl_easy_perform(curl);
196-
197-
if (result.curl_result == CURLE_OK) {
198-
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &result.response_code);
199-
}
200-
201-
return result; });
195+
{
196+
result.curl_result = curl_easy_perform(curl);
197+
198+
if (result.curl_result == CURLE_OK)
199+
{
200+
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &result.response_code);
201+
}
202+
203+
return result;
204+
});
202205
}
203206

204207
// Helper function to perform a PUT request with binary data
@@ -214,13 +217,15 @@ RequestResult PerformPutRequestWithRetry(CURL* curl, const std::string& url,
214217

215218
return PerformRequestWithRetry([&]() -> RequestResult
216219
{
217-
result.curl_result = curl_easy_perform(curl);
218-
219-
if (result.curl_result == CURLE_OK) {
220-
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &result.response_code);
221-
}
222-
223-
return result; });
220+
result.curl_result = curl_easy_perform(curl);
221+
222+
if (result.curl_result == CURLE_OK)
223+
{
224+
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &result.response_code);
225+
}
226+
227+
return result;
228+
});
224229
}
225230

226231
struct BatchResponse
@@ -397,11 +402,13 @@ Communicator::UploadResult PerformUpload(const std::string& uploadUrl, const std
397402

398403
uploadResult = PerformRequestWithRetry([&]() -> RequestResult
399404
{
400-
uploadResult.curl_result = curl_easy_perform(curl.get());
401-
if (uploadResult.curl_result == CURLE_OK) {
402-
curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE, &uploadResult.response_code);
403-
}
404-
return uploadResult; });
405+
uploadResult.curl_result = curl_easy_perform(curl.get());
406+
if (uploadResult.curl_result == CURLE_OK)
407+
{
408+
curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE, &uploadResult.response_code);
409+
}
410+
return uploadResult;
411+
});
405412

406413
curl_slist_free_all(uploadHeaders);
407414

@@ -454,11 +461,13 @@ bool PerformVerify(const std::string& verifyUrl, const std::string& oid, size_t
454461

455462
verifyResult = PerformRequestWithRetry([&]() -> RequestResult
456463
{
457-
verifyResult.curl_result = curl_easy_perform(curl.get());
458-
if (verifyResult.curl_result == CURLE_OK) {
459-
curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE, &verifyResult.response_code);
460-
}
461-
return verifyResult; });
464+
verifyResult.curl_result = curl_easy_perform(curl.get());
465+
if (verifyResult.curl_result == CURLE_OK)
466+
{
467+
curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE, &verifyResult.response_code);
468+
}
469+
return verifyResult;
470+
});
462471

463472
curl_slist_free_all(verifyHeaders);
464473

p4-fusion/lfs/communication/s3comm.cc

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
#include <aws/core/utils/stream/PreallocatedStreamBuf.h>
1111

1212
S3Comm::S3Comm(const std::string& serverURL, const std::string& bucket, const std::string& repository, const std::string& username, const std::string& password)
13-
: m_ServerURL(serverURL)
14-
, m_Bucket(bucket)
15-
, m_Repository(repository)
16-
, m_Username(username)
17-
, m_Password(password)
13+
: m_ServerURL(serverURL)
14+
, m_Bucket(bucket)
15+
, m_Repository(repository)
16+
, m_Username(username)
17+
, m_Password(password)
1818
{
1919
}
2020

@@ -26,14 +26,14 @@ Communicator::UploadResult S3Comm::UploadFile(const std::vector<char>& fileConte
2626

2727
bool isHttps = m_ServerURL.find("https://") == 0;
2828

29-
Aws::S3::S3ClientConfiguration config;
30-
config.endpointOverride = m_ServerURL;
31-
config.scheme = isHttps ? Aws::Http::Scheme::HTTPS : Aws::Http::Scheme::HTTP;
32-
config.verifySSL = isHttps;
29+
Aws::S3::S3ClientConfiguration config;
30+
config.endpointOverride = m_ServerURL;
31+
config.scheme = isHttps ? Aws::Http::Scheme::HTTPS : Aws::Http::Scheme::HTTP;
32+
config.verifySSL = isHttps;
3333
config.useVirtualAddressing = false;
3434

3535
Aws::S3::S3Client s3Client(credentials, config,
36-
Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, false);
36+
Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, false);
3737

3838
std::string objectKey = m_Repository + "/" + oid;
3939

@@ -53,15 +53,13 @@ Communicator::UploadResult S3Comm::UploadFile(const std::vector<char>& fileConte
5353
objectRequest.SetKey(objectKey);
5454

5555
auto streamBuf = Aws::MakeShared<Aws::Utils::Stream::PreallocatedStreamBuf>("",
56-
reinterpret_cast<unsigned char*>(const_cast<char*>(fileContents.data())),
57-
fileContents.size());
56+
reinterpret_cast<unsigned char*>(const_cast<char*>(fileContents.data())),
57+
fileContents.size());
5858
auto stream = Aws::MakeShared<Aws::IOStream>("", streamBuf.get());
59-
stream->seekg(0, std::ios::beg);
59+
stream->seekg(0, std::ios::beg);
6060

61-
objectRequest.SetBody(stream);
61+
objectRequest.SetBody(stream);
6262

6363
auto uploadResult = s3Client.PutObject(objectRequest);
64-
return uploadResult.IsSuccess() ?
65-
UploadResult::Uploaded :
66-
UploadResult::Error;
64+
return uploadResult.IsSuccess() ? UploadResult::Uploaded : UploadResult::Error;
6765
}

p4-fusion/main.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ int Main(int argc, char** argv)
424424

425425
// Check if all changelists appear only once
426426
std::set<std::string> uniqueChangeListNumbers;
427-
for (const ChangeList& cl : changes) {
427+
for (const ChangeList& cl : changes)
428+
{
428429
uniqueChangeListNumbers.insert(cl.number);
429430
}
430431
if (uniqueChangeListNumbers.size() != changes.size())

p4-fusion/thread_pool.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ void ThreadPool::Initialize(int size, LFSClient* lfsClient)
134134
m_ThreadExceptions[i] = std::current_exception();
135135
}
136136
m_JobsProcessing--;
137-
} }));
137+
}
138+
}));
138139
}
139140
}
140141

p4-fusion/utils/arguments.cc

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,23 @@ static std::unique_ptr<std::vector<std::string>> ArgsFromFile(const std::string&
4242
std::string errorMessage;
4343
switch (resultCode)
4444
{
45-
case WRDE_BADCHAR: errorMessage = "Illegal newline or |&;<>(){}"; break;
46-
case WRDE_BADVAL: errorMessage = "An undefined shell variable was referenced"; break;
47-
case WRDE_CMDSUB: errorMessage = "Command substitution not allowed"; break;
48-
case WRDE_NOSPACE: errorMessage = "Out of memory"; break;
49-
case WRDE_SYNTAX: errorMessage = "Syntax error"; break;
50-
default: break;
45+
case WRDE_BADCHAR:
46+
errorMessage = "Illegal newline or |&;<>(){}";
47+
break;
48+
case WRDE_BADVAL:
49+
errorMessage = "An undefined shell variable was referenced";
50+
break;
51+
case WRDE_CMDSUB:
52+
errorMessage = "Command substitution not allowed";
53+
break;
54+
case WRDE_NOSPACE:
55+
errorMessage = "Out of memory";
56+
break;
57+
case WRDE_SYNTAX:
58+
errorMessage = "Syntax error";
59+
break;
60+
default:
61+
break;
5162
}
5263
ERR("Error parsing config file: " << errorMessage);
5364
return nullptr;
@@ -190,13 +201,12 @@ bool Arguments::IsValid() const
190201
}
191202
}
192203

193-
const bool hasAnyLFSParam = !GetLFSSpecs().empty() || !GetLFSServerUrl().empty() ||
194-
!GetLFSUsername().empty() || !GetLFSPassword().empty() || !GetLFSToken().empty() || !GetLFSAPI().empty() ||
195-
!GetLFSS3Bucket().empty() || !GetLFSS3Repository().empty();
204+
const bool hasAnyLFSParam = !GetLFSSpecs().empty() || !GetLFSServerUrl().empty() || !GetLFSUsername().empty() || !GetLFSPassword().empty() || !GetLFSToken().empty() || !GetLFSAPI().empty() || !GetLFSS3Bucket().empty() || !GetLFSS3Repository().empty();
196205
const bool hasAllLFSParams = !GetLFSSpecs().empty() && !GetLFSServerUrl().empty() && !GetLFSAPI().empty();
197206
if (hasAnyLFSParam && !hasAllLFSParams)
198207
return false;
199-
if (hasAnyLFSParam) {
208+
if (hasAnyLFSParam)
209+
{
200210
const std::string& lfsAPI = GetLFSAPI();
201211
if (lfsAPI != "lfs" && lfsAPI != "s3")
202212
{

p4-fusion/utils/arguments.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Arguments
2626

2727
std::string GetParameter(const std::string& argName) const;
2828
std::vector<std::string> GetParameterList(const std::string& argName) const;
29-
void AddArgumentsFromFile (const std::string& filename);
29+
void AddArgumentsFromFile(const std::string& filename);
3030
bool ValidateS3Bucket() const;
3131

3232
public:

0 commit comments

Comments
 (0)