4631 classLoadRevision |
4631 classLoadRevision |
4632 "load a specific revision into the system - especially useful to |
4632 "load a specific revision into the system - especially useful to |
4633 upgrade a class to the newest revision" |
4633 upgrade a class to the newest revision" |
4634 |
4634 |
4635 currentClass isLoaded ifFalse:[ |
4635 currentClass isLoaded ifFalse:[ |
4636 self warn:'cannot load specific releases of autoloaded classes.'. |
4636 self warn:'cannot load specific releases of autoloaded classes.'. |
4637 ^ self. |
4637 ^ self. |
4638 ]. |
4638 ]. |
4639 |
4639 |
4640 self doClassMenu:[:currentClass | |
4640 self doClassMenu:[:currentClass | |
4641 |aStream comparedSource currentSource v rev revString what mgr keep className |
4641 |aStream comparedSource currentSource v rev revString what mgr keep className |
4642 newClass prevCategory ok| |
4642 newClass prevCategory ok| |
4643 |
4643 |
4644 rev := Dialog request:'load which revision: (empty for newest)' onCancel:nil. |
4644 rev := SourceCodeManagerUtilities |
4645 rev notNil ifTrue:[ |
4645 askForExistingRevision:'load which revision:' |
4646 className := currentClass name. |
4646 title:'Load from repository' |
4647 (className includesString:'_rev_') ifTrue:[ |
4647 class:currentClass. |
4648 self warn:'select the original class and try again.'. |
4648 "/ rev := Dialog request:'load which revision: (empty for newest)' onCancel:nil. |
4649 ^ self |
4649 rev notNil ifTrue:[ |
4650 ]. |
4650 className := currentClass name. |
4651 |
4651 (className includesString:'_rev_') ifTrue:[ |
4652 mgr := currentClass sourceCodeManager. |
4652 self warn:'select the original class and try again.'. |
4653 ok := false. |
4653 ^ self |
4654 |
4654 ]. |
4655 rev withoutSpaces isEmpty ifTrue:[ |
4655 |
4656 what := className , '(newest)'. |
4656 mgr := currentClass sourceCodeManager. |
4657 self busyLabel:'extracting %1' with:what. |
4657 ok := false. |
4658 aStream := mgr getMostRecentSourceStreamForClassNamed:className. |
4658 |
4659 revString := 'newest'. |
4659 rev withoutSpaces isEmpty ifTrue:[ |
4660 keep := false. |
4660 what := className , '(newest)'. |
4661 ] ifFalse:[ |
4661 self busyLabel:'extracting %1' with:what. |
4662 what := className , '(' , rev , ')'. |
4662 aStream := mgr getMostRecentSourceStreamForClassNamed:className. |
4663 self busyLabel:'extracting %1' with:what. |
4663 revString := 'newest'. |
4664 aStream := mgr getSourceStreamFor:currentClass revision:rev. |
4664 keep := false. |
4665 revString := rev. |
4665 ] ifFalse:[ |
4666 keep := true. |
4666 what := className , '(' , rev , ')'. |
4667 ]. |
4667 self busyLabel:'extracting %1' with:what. |
4668 |
4668 aStream := mgr getSourceStreamFor:currentClass revision:rev. |
4669 aStream isNil ifTrue:[ |
4669 revString := rev. |
4670 self warn:'cannot find classes source.'. |
4670 keep := true. |
4671 ^ self. |
4671 ]. |
4672 ]. |
4672 |
4673 |
4673 aStream isNil ifTrue:[ |
4674 self busyLabel:'loading %1' with:what . |
4674 self warn:'cannot find classes source.'. |
4675 |
4675 ^ self. |
4676 [ |
4676 ]. |
4677 Class withoutUpdatingChangesDo:[ |
4677 |
4678 |saveIt prevSkip| |
4678 self busyLabel:'loading %1' with:what . |
4679 |
4679 |
4680 saveIt := Dialog confirmWithCancel:'Keep a save-copy of the existing class ? |
4680 [ |
|
4681 Class withoutUpdatingChangesDo:[ |
|
4682 |saveIt prevSkip| |
|
4683 |
|
4684 saveIt := Dialog confirmWithCancel:'Keep a save-copy of the existing class ? |
4681 |
4685 |
4682 Enter ''yes'', to have the existing class be |
4686 Enter ''yes'', to have the existing class be |
4683 renamed before the fileIn is performed. |
4687 renamed before the fileIn is performed. |
4684 You have to care for subclasses if doing so, |
4688 You have to care for subclasses if doing so, |
4685 because those are moved out of the way together |
4689 because those are moved out of the way together |
4688 Enter ''no'' to load the repository version |
4692 Enter ''no'' to load the repository version |
4689 without saving the existing class. |
4693 without saving the existing class. |
4690 In this case, methods from the repository version |
4694 In this case, methods from the repository version |
4691 will be merged with methods of the class in your |
4695 will be merged with methods of the class in your |
4692 running image.)' default:false. |
4696 running image.)' default:false. |
4693 saveIt isNil ifTrue:[^ self]. |
4697 saveIt isNil ifTrue:[^ self]. |
4694 saveIt ifTrue:[ |
4698 saveIt ifTrue:[ |
4695 "/ rename the current class - for backup |
4699 "/ rename the current class - for backup |
4696 prevCategory := currentClass category. |
4700 prevCategory := currentClass category. |
4697 currentClass category:'* obsolete *'. |
4701 currentClass category:'* obsolete *'. |
4698 Smalltalk renameClass:currentClass to:className , '_saved'. |
4702 Smalltalk renameClass:currentClass to:className , '_saved'. |
4699 ]. |
4703 ]. |
4700 |
4704 |
4701 prevSkip := ClassCategoryReader skipUnchangedMethods. |
4705 prevSkip := ClassCategoryReader skipUnchangedMethods. |
4702 ClassCategoryReader skipUnchangedMethods:false. |
4706 ClassCategoryReader skipUnchangedMethods:false. |
4703 |
4707 |
4704 Class nameSpaceQuerySignal answer:currentClass nameSpace |
4708 Class nameSpaceQuerySignal answer:currentClass nameSpace |
4705 do:[ |
4709 do:[ |
4706 Class packageQuerySignal answer:currentClass package |
4710 Class packageQuerySignal answer:currentClass package |
4707 do:[ |
4711 do:[ |
4708 lockUpdates := true. |
4712 lockUpdates := true. |
4709 [ |
4713 [ |
4710 aStream fileIn. |
4714 aStream fileIn. |
4711 ] valueNowOrOnUnwindDo:[ |
4715 ] valueNowOrOnUnwindDo:[ |
4712 ClassCategoryReader skipUnchangedMethods:prevSkip. |
4716 ClassCategoryReader skipUnchangedMethods:prevSkip. |
4713 lockUpdates := false. |
4717 lockUpdates := false. |
4714 ]. |
4718 ]. |
4715 ]. |
4719 ]. |
4716 ]. |
4720 ]. |
4717 |
4721 |
4718 "/ did that work ? |
4722 "/ did that work ? |
4719 newClass := Smalltalk at:className ifAbsent:nil. |
4723 newClass := Smalltalk at:className ifAbsent:nil. |
4720 newClass isNil ifTrue:[ |
4724 newClass isNil ifTrue:[ |
4721 saveIt ifTrue:[ |
4725 saveIt ifTrue:[ |
4722 self warn:'fileIn failed - undoing changes ...'. |
4726 self warn:'fileIn failed - undoing changes ...'. |
4723 Smalltalk renameClass:currentClass to:className. |
4727 Smalltalk renameClass:currentClass to:className. |
4724 currentClass category:prevCategory. |
4728 currentClass category:prevCategory. |
4725 ] ifFalse:[ |
4729 ] ifFalse:[ |
4726 self warn:'fileIn failed - cannot recover class'. |
4730 self warn:'fileIn failed - cannot recover class'. |
4727 ] |
4731 ] |
4728 ] ifFalse:[ |
4732 ] ifFalse:[ |
4729 "/ |
4733 "/ |
4730 "/ if we loaded an old version, rename that one and fix the name of the |
4734 "/ if we loaded an old version, rename that one and fix the name of the |
4731 "/ current class |
4735 "/ current class |
4732 "/ |
4736 "/ |
4733 keep ifTrue:[ |
4737 keep ifTrue:[ |
4734 saveIt ifTrue:[ |
4738 saveIt ifTrue:[ |
4735 Smalltalk renameClass:newClass to:(className , '_rev_' , rev). |
4739 Smalltalk renameClass:newClass to:(className , '_rev_' , rev). |
4736 newClass category:'* old versions *'. |
4740 newClass category:'* old versions *'. |
4737 Smalltalk renameClass:currentClass to:className. |
4741 Smalltalk renameClass:currentClass to:className. |
4738 currentClass category:prevCategory. |
4742 currentClass category:prevCategory. |
4739 ] |
4743 ] |
4740 ]. |
4744 ]. |
4741 ok := true. |
4745 ok := true. |
4742 ] |
4746 ] |
4743 ]. |
4747 ]. |
4744 ] valueNowOrOnUnwindDo:[ |
4748 ] valueNowOrOnUnwindDo:[ |
4745 aStream close. |
4749 aStream close. |
4746 self normalLabel. |
4750 self normalLabel. |
4747 Smalltalk changed. |
4751 Smalltalk changed. |
4748 ]. |
4752 ]. |
4749 ok ifTrue:[ |
4753 ok ifTrue:[ |
4750 self switchToClassNamed:newClass name. |
4754 self switchToClassNamed:newClass name. |
4751 ] |
4755 ] |
4752 ] |
4756 ] |
4753 ] |
4757 ] |
4754 |
4758 |
4755 "Created: / 14.11.1995 / 16:43:15 / cg" |
4759 "Created: / 14.11.1995 / 16:43:15 / cg" |
4756 "Modified: / 18.6.1998 / 14:29:40 / cg" |
4760 "Modified: / 18.6.1998 / 14:29:40 / cg" |
4757 ! |
4761 ! |