AbstractSourceCodeManager.st
branchjv
changeset 4022 b596e506bbe9
parent 4009 2289742cbd69
parent 4010 2d5dd6fc7885
child 4023 cc7c7a78a57f
equal deleted inserted replaced
4009:2289742cbd69 4022:b596e506bbe9
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "
     1 "
     4  COPYRIGHT (c) 1995 by Claus Gittinger
     2  COPYRIGHT (c) 1995 by Claus Gittinger
     5               All Rights Reserved
     3               All Rights Reserved
     6 
     4 
     7  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
    75         ~/.smalltalk/source-cache (UNIX, as <tempDir> is pruned upon each reboot)
    73         ~/.smalltalk/source-cache (UNIX, as <tempDir> is pruned upon each reboot)
    76     "
    74     "
    77     "JV@2012-03-14: Changed to use .smalltalk/source-cache on UNIX machines"
    75     "JV@2012-03-14: Changed to use .smalltalk/source-cache on UNIX machines"
    78     "CG: why only on unix machines???"
    76     "CG: why only on unix machines???"
    79     
    77     
       
    78     |dir|
       
    79     
    80     CachingSources isNil ifTrue:[
    80     CachingSources isNil ifTrue:[
    81         CachingSources := true.
    81         CachingSources := true.
    82     ].
    82     ].
    83     OperatingSystem isUNIXlike ifTrue:[
    83 
    84         CacheDirectoryName := '~/.smalltalk/sourceCache'.
    84     dir := Filename homeDirectory / '.smalltalk/sourceCache'. 
    85     ] ifFalse:[
    85     dir isWritableDirectory ifFalse:[
    86         CacheDirectoryName := (Filename defaultTempDirectory constructString:'stx_sourceCache').
    86         dir := Filename defaultTempDirectory / 'stx_sourceCache'.
    87     ].
    87     ].  
       
    88     CacheDirectoryName := dir pathName.
       
    89 
       
    90 "/    OperatingSystem isUNIXlike ifTrue:[
       
    91 "/        CacheDirectoryName := '~/.smalltalk/sourceCache'.
       
    92 "/    ] ifFalse:[
       
    93 "/        CacheDirectoryName := (Filename defaultTempDirectory constructString:'stx_sourceCache').
       
    94 "/    ].
    88     
    95     
    89     "
    96     "
    90      self initCacheDirPath     
    97      self initCacheDirPath     
    91     "
    98     "
    92 
    99 
  2595     "given the source code of my version method, ensure that it contains dollars for
  2602     "given the source code of my version method, ensure that it contains dollars for
  2596      proper keyword expansion"
  2603      proper keyword expansion"
  2597 
  2604 
  2598     |versionString|
  2605     |versionString|
  2599 
  2606 
  2600     versionString := aString copyWithout: $§.
  2607     versionString := aString copyWithout: $.
  2601     ^ self ensureKeywordExpansionWith: $$ inVersionMethod:versionString.
  2608     ^ self ensureKeywordExpansionWith: $$ inVersionMethod:versionString.
  2602 
  2609 
  2603     "
  2610     "
  2604      self ensureDollarsInVersionMethod:'foo ^ ''hello'' ' 
  2611      self ensureDollarsInVersionMethod:'foo ^ ''hello'' ' 
  2605      self ensureDollarsInVersionMethod:'foo ^ ''§hello§'' ' 
  2612      self ensureDollarsInVersionMethod:'foo ^ ''hello'' ' 
  2606      self ensureDollarsInVersionMethod:'foo ^ ''   hello   '' '    
  2613      self ensureDollarsInVersionMethod:'foo ^ ''   hello   '' '    
  2607      self ensureDollarsInVersionMethod:'foo ^ ''$','Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.228 2009/10/20 09:55:58 fm Exp $'' '      
  2614      self ensureDollarsInVersionMethod:'foo ^ ''$','Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.228 2009/10/20 09:55:58 fm Exp $'' '      
  2608     -- errors:
  2615     -- errors:
  2609      self ensureDollarsInVersionMethod:'foo ^ ''$Head'' '    
  2616      self ensureDollarsInVersionMethod:'foo ^ ''$Head'' '    
  2610      self ensureDollarsInVersionMethod:'foo ^ ''Header$'' '    
  2617      self ensureDollarsInVersionMethod:'foo ^ ''Header$'' '    
  2687         , aCharacter asString
  2694         , aCharacter asString
  2688         ,(aString copyFrom:indexOfFirstQuote+1 to:indexOfLastQuote-1)
  2695         ,(aString copyFrom:indexOfFirstQuote+1 to:indexOfLastQuote-1)
  2689         ,aCharacter asString ,(aString copyFrom:indexOfLastQuote)
  2696         ,aCharacter asString ,(aString copyFrom:indexOfLastQuote)
  2690 
  2697 
  2691     "
  2698     "
  2692      self ensureKeywordExpansionWith: $§ inVersionMethod: 'foo ^ ''hello'' '  
  2699      self ensureKeywordExpansionWith: $ inVersionMethod: 'foo ^ ''hello'' '  
  2693      self ensureKeywordExpansionWith: $§ inVersionMethod: 'foo ^ ''   hello   '' '
  2700      self ensureKeywordExpansionWith: $ inVersionMethod: 'foo ^ ''   hello   '' '
  2694      self ensureKeywordExpansionWith: $§ inVersionMethod: 'foo ^ ''§Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.218 2009/10/07 12:12:30 fm Exp §'' '    
  2701      self ensureKeywordExpansionWith: $ inVersionMethod: 'foo ^ ''Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.218 2009/10/07 12:12:30 fm Exp '' '    
  2695 
  2702 
  2696      self ensureKeywordExpansionWith: $$ inVersionMethod: 'foo ^ ''hello'' '  
  2703      self ensureKeywordExpansionWith: $$ inVersionMethod: 'foo ^ ''hello'' '  
  2697      self ensureKeywordExpansionWith: $$ inVersionMethod: 'foo ^ ''   hello   '' '
  2704      self ensureKeywordExpansionWith: $$ inVersionMethod: 'foo ^ ''   hello   '' '
  2698      self ensureKeywordExpansionWith: $$ inVersionMethod: 'foo ^ ''$','Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.228 2009/10/20 09:55:58 fm Exp $'' '    
  2705      self ensureKeywordExpansionWith: $$ inVersionMethod: 'foo ^ ''$','Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.228 2009/10/20 09:55:58 fm Exp $'' '    
  2699 
  2706 
  2700     -- errors:
  2707     -- errors:
  2701      self ensureKeywordExpansionWith: $§ inVersionMethod: 'foo ^ ''§Head'' '  
  2708      self ensureKeywordExpansionWith: $ inVersionMethod: 'foo ^ ''Head'' '  
  2702      self ensureKeywordExpansionWith: $§ inVersionMethod: 'foo ^ ''Header§'' '   
  2709      self ensureKeywordExpansionWith: $ inVersionMethod: 'foo ^ ''Header'' '   
  2703     "
  2710     "
  2704 !
  2711 !
  2705 
  2712 
  2706 ensureKeywordInVersionMethod: source
  2713 ensureKeywordInVersionMethod: source
  2707 
  2714 
  2710     "Created: / 27-09-2011 / 14:50:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2717     "Created: / 27-09-2011 / 14:50:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2711 !
  2718 !
  2712 
  2719 
  2713 ensureNoDollarsInVersionMethod:aString
  2720 ensureNoDollarsInVersionMethod:aString
  2714     "given the source code of another manager's version method, ensure that it does NOT
  2721     "given the source code of another manager's version method, ensure that it does NOT
  2715      contain dollars and add $§ instead, to avoid that CVS expands keywords in it"
  2722      contain dollars and add $ instead, to avoid that CVS expands keywords in it"
  2716 
  2723 
  2717     |versionString|
  2724     |versionString|
  2718 
  2725 
  2719     versionString := aString copyWithout: $$.
  2726     versionString := aString copyWithout: $$.
  2720     ^ self ensureKeywordExpansionWith: $§ inVersionMethod:versionString.
  2727     ^ self ensureKeywordExpansionWith: $ inVersionMethod:versionString.
  2721 
  2728 
  2722     "
  2729     "
  2723         self ensureNoDollarsInVersionMethod:'foo ^ ''$','Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.228 2009/10/20 09:55:58 fm Exp $'' '           
  2730         self ensureNoDollarsInVersionMethod:'foo ^ ''$','Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.228 2009/10/20 09:55:58 fm Exp $'' '           
  2724         self ensureNoDollarsInVersionMethod:'foo ^ ''$','Head'' '                
  2731         self ensureNoDollarsInVersionMethod:'foo ^ ''$','Head'' '                
  2725         self ensureNoDollarsInVersionMethod:'foo ^ ''Header$'' '             
  2732         self ensureNoDollarsInVersionMethod:'foo ^ ''Header$'' '             
  2726         self ensureNoDollarsInVersionMethod:'foo ^ ''§Header§'' '    
  2733         self ensureNoDollarsInVersionMethod:'foo ^ ''Header'' '    
  2727 
  2734 
  2728       -- errors:
  2735       -- errors:
  2729 
  2736 
  2730         self ensureNoDollarsInVersionMethod:'foo ^ ''§Header'' '   
  2737         self ensureNoDollarsInVersionMethod:'foo ^ ''Header'' '   
  2731         self ensureNoDollarsInVersionMethod:'foo ^ ''Header§'' '             
  2738         self ensureNoDollarsInVersionMethod:'foo ^ ''Header'' '             
  2732 
  2739 
  2733     "
  2740     "
  2734 !
  2741 !
  2735 
  2742 
  2736 extractKeyValueFor:key fromRevisionString:aString 
  2743 extractKeyValueFor:key fromRevisionString:aString