2471 | tmpFilename perforceCommand outputStream errorStream result s |
2473 | tmpFilename perforceCommand outputStream errorStream result s |
2472 changesAsLogged inStream line changesDict chunksPart words mergedSource mySource |
2474 changesAsLogged inStream line changesDict chunksPart words mergedSource mySource |
2473 localRevision resultSource definitionClass descriptionInfo resolveFiles depotPath localPath checkInDefinition fileStatDict| |
2475 localRevision resultSource definitionClass descriptionInfo resolveFiles depotPath localPath checkInDefinition fileStatDict| |
2474 |
2476 |
2475 self temporaryWorkSpace isNil ifTrue:[ |
2477 self temporaryWorkSpace isNil ifTrue:[ |
2476 self perforceError raiseErrorString:('Error getting temporary workspace when try to merge or resolve conflicts for ', aNumber printString, '.'). |
2478 self perforceError raiseErrorString:('Error getting temporary workspace when try to merge or resolve conflicts for ', aNumber printString, '.'). |
2477 ^false. |
2479 ^false. |
2478 ]. |
2480 ]. |
2479 descriptionInfo := (self getChangeDespriptionInfoFor:aNumber printString). |
2481 descriptionInfo := (self getChangeDespriptionInfoFor:aNumber printString). |
2480 descriptionInfo isNil ifTrue:[ |
2482 descriptionInfo isNil ifTrue:[ |
2481 ^false. |
2483 ^false. |
2482 ]. |
2484 ]. |
2483 resolveFiles := descriptionInfo at:#Files ifAbsent:nil. |
2485 resolveFiles := descriptionInfo at:#Files ifAbsent:nil. |
2484 resolveFiles isNil ifTrue:[ |
2486 resolveFiles isNil ifTrue:[ |
2485 ^false. |
2487 ^false. |
2486 ]. |
2488 ]. |
2487 resolveFiles do:[:aFileLine| |
2489 resolveFiles do:[:aFileLine| |
2488 depotPath := (aFileLine copyTo:((aFileLine lastIndexOf:$#) - 1 )) withoutTrailingSeparators. |
2490 depotPath := (aFileLine copyTo:((aFileLine lastIndexOf:$#) - 1 )) withoutTrailingSeparators. |
2489 localPath := self temporaryWorkSpace getLocalPathForDepotPath:depotPath. |
2491 localPath := self temporaryWorkSpace getLocalPathForDepotPath:depotPath. |
2490 fileStatDict := self temporaryWorkSpace getFileStatForPathname:localPath. |
2492 fileStatDict := self temporaryWorkSpace getFileStatForPathname:localPath. |
2491 (fileStatDict includesKey:'unresolved') ifTrue:[ |
2493 (fileStatDict includesKey:'unresolved') ifTrue:[ |
2492 definitionClass := Smalltalk at:(localPath asFilename withoutSuffix baseName asSymbol) ifAbsent:nil. |
2494 definitionClass := Smalltalk at:(localPath asFilename withoutSuffix baseName asSymbol) ifAbsent:nil. |
2493 checkInDefinition := PerforceSourceCodeManager getCheckInDefinitionForClass:definitionClass. |
2495 checkInDefinition := PerforceSourceCodeManager getCheckInDefinitionForClass:definitionClass. |
2494 localRevision := checkInDefinition getLocalRevisionNumber. |
2496 localRevision := checkInDefinition getLocalRevisionNumber. |
2495 tmpFilename := localPath asFilename. |
2497 tmpFilename := localPath asFilename. |
2496 perforceCommand := ('resolve -af "' , tmpFilename pathName, '"'). |
2498 perforceCommand := ('resolve -af "' , tmpFilename pathName, '"'). |
2497 outputStream := ReadWriteStream on:''. |
2499 outputStream := ReadWriteStream on:''. |
2498 errorStream := ReadWriteStream on:''. |
2500 errorStream := ReadWriteStream on:''. |
2499 result := self temporaryWorkSpace executePerforceCommand:perforceCommand inDirectory:self temporaryWorkSpace root |
2501 result := self temporaryWorkSpace executePerforceCommand:perforceCommand inDirectory:self temporaryWorkSpace root |
2500 inputFrom:nil outputTo:outputStream |
2502 inputFrom:nil outputTo:outputStream |
2501 errorTo:errorStream |
2503 errorTo:errorStream |
2502 logHeader:('resolving ', tmpFilename pathName, '.'). |
2504 logHeader:('resolving ', tmpFilename pathName, '.'). |
2503 result ifFalse:[ |
2505 result ifFalse:[ |
2504 ^ false |
2506 ^ false |
2505 ]. |
2507 ]. |
2506 "check for conflicts" |
2508 "check for conflicts" |
2507 changesAsLogged := StringCollection new. |
2509 changesAsLogged := StringCollection new. |
2508 inStream := ReadStream on:(outputStream contents). |
2510 inStream := ReadStream on:(outputStream contents). |
2509 |
2511 |
2510 [inStream atEnd not] whileTrue:[ |
2512 [inStream atEnd not] whileTrue:[ |
2511 line:= inStream nextLine. |
2513 line:= inStream nextLine. |
2512 line notNil ifTrue:[ |
2514 line notNil ifTrue:[ |
2513 (line startsWith:'Diff chunks:') ifTrue:[ |
2515 (line startsWith:'Diff chunks:') ifTrue:[ |
2514 changesAsLogged add:line. |
2516 changesAsLogged add:line. |
2515 changesDict := Dictionary new. |
2517 changesDict := Dictionary new. |
2516 chunksPart := line copyFrom:('Diff chunks:' size + 1). |
2518 chunksPart := line copyFrom:('Diff chunks:' size + 1). |
2517 (chunksPart asCollectionOfSubstringsSeparatedBy:$+) do:[:eachElement| |
2519 (chunksPart asCollectionOfSubstringsSeparatedBy:$+) do:[:eachElement| |
2518 words := eachElement asCollectionOfWords. |
2520 words := eachElement asCollectionOfWords. |
2519 changesDict at:words second asSymbol put:words first asNumber. |
2521 changesDict at:words second asSymbol put:words first asNumber. |
2520 ]. |
2522 ]. |
2521 ]. |
2523 ]. |
2522 ]. |
2524 ]. |
2523 ]. |
2525 ]. |
2524 s := WriteStream on:String new. |
2526 s := WriteStream on:''. |
2525 PerforceSourceCodeManager fileOutSourceCodeOf:definitionClass on:s. |
2527 PerforceSourceCodeManager fileOutSourceCodeOf:definitionClass on:s. |
2526 mergedSource := tmpFilename readStream contents asString. |
2528 mergedSource := tmpFilename readStream contents asString. |
2527 mySource := s contents asString. |
2529 mySource := s contents asString. |
2528 resultSource := self askForMergedSource:mergedSource |
2530 resultSource := self askForMergedSource:mergedSource |
2529 localSource:mySource |
2531 localSource:mySource |
2530 changesDict:changesDict |
2532 changesDict:changesDict |
2531 haveRevision:(fileStatDict at:'haveRev' ifAbsent:nil) |
2533 haveRevision:(fileStatDict at:'haveRev' ifAbsent:nil) |
2532 changesAsLogged:changesAsLogged |
2534 changesAsLogged:changesAsLogged |
2533 pathName:tmpFilename pathName |
2535 pathName:tmpFilename pathName |
2534 definitionClass:definitionClass. |
2536 definitionClass:definitionClass. |
2535 resultSource isNil ifTrue:[ |
2537 resultSource isNil ifTrue:[ |
2536 ^false. |
2538 ^false. |
2537 ]. |
2539 ]. |
2538 "now we have a merge - lets get latest revision and write on it " |
2540 "now we have a merge - lets get latest revision and write on it " |
2539 perforceCommand := ('revert "' , tmpFilename pathName, '"'). |
2541 perforceCommand := ('revert "' , tmpFilename pathName, '"'). |
2540 outputStream := ReadWriteStream on:''. |
2542 outputStream := ReadWriteStream on:''. |
2541 errorStream := ReadWriteStream on:''. |
2543 errorStream := ReadWriteStream on:''. |
2542 result := self temporaryWorkSpace executePerforceCommand:perforceCommand inDirectory:self temporaryWorkSpace root |
2544 result := self temporaryWorkSpace executePerforceCommand:perforceCommand inDirectory:self temporaryWorkSpace root |
2543 inputFrom:nil outputTo:outputStream |
2545 inputFrom:nil outputTo:outputStream |
2544 errorTo:errorStream |
2546 errorTo:errorStream |
2545 logHeader:('revert after resolving ', tmpFilename pathName, '.'). |
2547 logHeader:('revert after resolving ', tmpFilename pathName, '.'). |
2546 result ifFalse:[ |
2548 result ifFalse:[ |
2547 ^ false |
2549 ^ false |
2548 ]. |
2550 ]. |
2549 |
2551 |
2550 tmpFilename remove. |
2552 tmpFilename remove. |
2551 |
2553 |
2552 perforceCommand := ('sync -f "' , tmpFilename pathName, '"'). |
2554 perforceCommand := ('sync -f "' , tmpFilename pathName, '"'). |
2553 outputStream := ReadWriteStream on:''. |
2555 outputStream := ReadWriteStream on:''. |
2554 errorStream := ReadWriteStream on:''. |
2556 errorStream := ReadWriteStream on:''. |
2555 result := self temporaryWorkSpace executePerforceCommand:perforceCommand inDirectory:self temporaryWorkSpace root |
2557 result := self temporaryWorkSpace executePerforceCommand:perforceCommand inDirectory:self temporaryWorkSpace root |
2556 inputFrom:nil outputTo:outputStream |
2558 inputFrom:nil outputTo:outputStream |
2557 errorTo:errorStream |
2559 errorTo:errorStream |
2558 logHeader:('sync after resolving ', tmpFilename pathName, '.'). |
2560 logHeader:('sync after resolving ', tmpFilename pathName, '.'). |
2559 result ifFalse:[ |
2561 result ifFalse:[ |
2560 ^ false |
2562 ^ false |
2561 ]. |
2563 ]. |
2562 |
2564 |
2563 perforceCommand := ('edit -c ', aNumber printString, ' "' , tmpFilename pathName, '"'). |
2565 perforceCommand := ('edit -c ', aNumber printString, ' "' , tmpFilename pathName, '"'). |
2564 outputStream := ReadWriteStream on:''. |
2566 outputStream := ReadWriteStream on:''. |
2565 errorStream := ReadWriteStream on:''. |
2567 errorStream := ReadWriteStream on:''. |
2566 result := self temporaryWorkSpace executePerforceCommand:perforceCommand inDirectory:self temporaryWorkSpace root |
2568 result := self temporaryWorkSpace executePerforceCommand:perforceCommand inDirectory:self temporaryWorkSpace root |
2567 inputFrom:nil outputTo:outputStream |
2569 inputFrom:nil outputTo:outputStream |
2568 errorTo:errorStream |
2570 errorTo:errorStream |
2569 logHeader:('edit after resolving ', tmpFilename pathName, '.'). |
2571 logHeader:('edit after resolving ', tmpFilename pathName, '.'). |
2570 result ifFalse:[ |
2572 result ifFalse:[ |
2571 ^ false |
2573 ^ false |
2572 ]. |
2574 ]. |
2573 |
2575 |
2574 "write my result" |
2576 "write my result" |
2575 resultSource notNil ifTrue:[ |
2577 resultSource notNil ifTrue:[ |
2576 s := tmpFilename writeStream. |
2578 s := tmpFilename writeStream. |
2577 s nextPutAll:resultSource. |
2579 s nextPutAll:resultSource. |
2578 s close. |
2580 s close. |
2579 ]. |
2581 ]. |
2580 ]. |
2582 ]. |
2581 ]. |
2583 ]. |
2582 ^true |
2584 ^true |
2583 ! |
2585 ! |
2584 |
2586 |
2585 releaseWorkSpace |
2587 releaseWorkSpace |