void ParmLinkMgr::SetParmB( Parm* p ) { m_WorkingParmLink.SetParmB( p ); m_WorkingParmLink.InitOffsetScale(); RebuildAll(); }
int main(int argc, char * argv[]) { printf("Please wait while initial details are downloaded from Perforce server...\n"); gpszClient = NULL; gpszUser = NULL; gpszRoot = NULL; gpszCheckinUser = NULL; gpszCheckinDate = NULL; gpszCheckinComment = NULL; gnCheckinChangeList = 0; pszDepotFw = NULL; // Get client name and user name (and root path): GetClientAndUser(); printf("client = '%s'; user = '******'...\n", gpszClient, gpszUser); // Get available changelist numbers: GetAvailableChangeLists(); // Get root path: const int kcchBuf = 100; char szBuf[kcchBuf] = ""; GetEnvironmentVariable("fwroot", szBuf, kcchBuf); gpszRoot = strdup(szBuf); // Get default value for date: SYSTEMTIME SystemTime; GetSystemTime(&SystemTime); sprintf(szBuf, "%d-%02d-%02d", SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay); gpszCheckinDate = strdup(szBuf); printf("...Done.\n"); // There are two ways to run the program: // 1) from the command line, with free text (as the checkin comment) forming the rest of the // command line; // 2) with no command line arguments, in which case all details are collected in a dialog // box. // In the case of (1), all other variables take default values: Default changelist, Perforce // user name, date format etc. // Check if user entered text: if (argc < 2) { if (DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG_USER_INFO), NULL, DlgProcUserInfo) == 0) { exit(0); } } else { // Get user's checkin comment from the command line: const char * pszCommandLine = GetCommandLine(); // The position of the what the system thinks is the first of the command line arguments // is the start of the comment: gpszCheckinComment = strdup(strstr(pszCommandLine, argv[1])); // Use Perforce user name as default checkin name: gpszCheckinUser = strdup(gpszUser); } printf("Attempting to acquire check-in token file...\n"); // Loop until we get exclusive access to token file: while (true) { // See if anyone has the token file: if (TokenFileIsFree()) { // Get up to date token file: SyncTokenFile(); // Open token file for edit: OpenTokenFileForEdit(); // Lock token file: // LockTokenFile(); // See if anyone else has the token file as well as us: if (TokenFileExclusivelyMine()) { // We have the token file exclusively, so we can proceed: break; } else { // Someone else got it at the same time as us! We'll revert: RevertTokenFile(); } } // Sleep for 10 seconds before trying again: Sleep(10000); } printf("...Done.\n"); // Now that we have the token file, create a new thread to monitor if we take too long // to complete the task: DWORD nThreadId; // MSDN says you can pass NULL instead of this, but you can't on Win98. HANDLE hThread = CreateThread(NULL, 0, TimeOutCheck, NULL, 0, &nThreadId); printf("Synchronizing files with Perforce server...\n"); // Sync all files: SyncAllFiles(); if (fTimedOut) Sleep(INFINITE); printf("...Done.\n"); printf("Checking if any files need resolving...\n"); // See if any files need resolving: if (FilesNeedResolving()) FatalError("One or more files need resolving. No point in attempting build, as check-in will fail anyway."); if (fTimedOut) Sleep(INFINITE); printf("...Done.\n"); printf("\n"); printf("******************************************************************************\n"); printf("Initialization complete. About to start build. You can leave your machine now!\n"); printf("******************************************************************************\n"); printf("\n"); Sleep(4000); // Rebuild all - does not return if build fails: RebuildAll(); if (fTimedOut) Sleep(INFINITE); // Prepare Chagelist spec file: MakeChangelistSpec(); if (fTimedOut) Sleep(INFINITE); // Edit CheckIn_History.txt file to add user's description of changes. EditTokenFile(); if (fTimedOut) Sleep(INFINITE); // Submit changes: P4Submit(); printf("Auto-checkin completed!\r\n"); TerminateThread(hThread, 0); delete[] pszDepotFw; delete[] gpszClient; delete[] gpszUser; delete[] gpszRoot; delete[] gpszCheckinUser; delete[] gpszCheckinDate; delete[] gpszCheckinComment; for (int i = 0; i < gcclChangeLists; i++) delete[] gppszChangeListsComments[i]; delete[] gppszChangeListsComments; delete[] gpnChangeLists; remove(pszWorkSpaceFileName); remove(pszChagelistSpecFileName); return 0; }