--- a/AbstractSourceCodeManager.st Tue Sep 27 18:05:13 2011 +0200
+++ b/AbstractSourceCodeManager.st Tue Sep 27 18:10:26 2011 +0200
@@ -1455,6 +1455,22 @@
"Modified: / 09-07-2011 / 12:25:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+versionMethodKeyword
+
+ "Answers the keyword used by the version management system to
+ expand a current version in a file (_without_ dollars). For
+ CVS it is 'Header', for SVN 'Id', others may use different
+ keywords. If nil is returned, then the version management does
+ not use any keyword."
+
+ "/TODO: Now, 'Header' is returned for backward compatibility. In future
+ "/it should be changed to self subclassResponsibility
+
+ ^'Header'
+
+ "Created: / 27-09-2011 / 14:52:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
versionMethodTemplateForJavaScript
^ self versionMethodTemplateForJavaScriptFor:(self nameOfVersionMethodInClasses)
@@ -1491,10 +1507,11 @@
^
'def self.',aSelector,'()
- return "$' , 'Header' , '$"
+ return "$' , self versionMethodKeyword , '$"
end'
"Modified (comment): / 19-08-2011 / 01:19:40 / cg"
+ "Modified: / 27-09-2011 / 16:46:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
versionMethodTemplateForSmalltalk
@@ -1511,10 +1528,11 @@
^
aSelector,'
- ^ ''$', 'Header' , '$''
+ ^ ''$', self versionMethodKeyword , '$''
'
"Modified (comment): / 19-08-2011 / 01:19:08 / cg"
+ "Modified: / 27-09-2011 / 16:46:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!AbstractSourceCodeManager class methodsFor:'source code access'!
@@ -1931,6 +1949,49 @@
"
!
+ensureKeyword: keyword inVersionMethod: source
+
+ | startQuote endQuote doubleColon |
+
+ "/nil keyword means that given source code management system
+ "/does not expand keywords (StORE or Monticello, for example)
+ keyword isNil ifTrue:[
+ ^source.
+ ].
+
+ startQuote := source indexOf: $'.
+ startQuote == 0 ifTrue:[
+ self error:'Does not seem to be a valid version method source. Invalid source?'
+ ].
+ (source at: startQuote + 1) == $$ ifFalse:[
+ self error:'Does not seem to be a valid version method source. Invalid source?'
+ ].
+
+ endQuote := source lastIndexOf: $'.
+ startQuote == endQuote ifTrue:[
+ self error:'Does not seem to be a valid version method source. Invalid source?'
+ ].
+ (source at: endQuote - 1) == $$ ifFalse:[
+ self error:'Does not seem to be a valid version method source. Invalid source?'
+ ].
+
+ doubleColon := source indexOf: $: startingAt: startQuote + 2.
+ "/There may be no double colon at all, if the version method
+ "/is fresh, like '$Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.256 2011-09-27 16:10:26 vrany Exp $'
+ (doubleColon == 0 or:[doubleColon > endQuote]) ifTrue:[
+ doubleColon := endQuote - 1.
+ ].
+
+ (source copyFrom: startQuote + 2 to: doubleColon - 1) = keyword ifTrue:[
+ "/ Good, desired keyword is already there
+ ^source
+ ].
+
+ ^(source copyTo: startQuote + 1) , keyword , (source copyFrom: doubleColon)
+
+ "Created: / 27-09-2011 / 15:00:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
ensureKeywordExpansionWith: aCharacter inVersionMethod:aString
"given the source code of my version method, ensure that it contains aCharacter for
proper keyword expansion"
@@ -1977,6 +2038,13 @@
"
!
+ensureKeywordInVersionMethod: source
+
+ ^self ensureKeyword: self versionMethodKeyword inVersionMethod: source
+
+ "Created: / 27-09-2011 / 14:50:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
ensureNoDollarsInVersionMethod:aString
"given the source code of another manager's version method, ensure that it does NOT
contain dollars and add $§ instead, to avoid that CVS expands keywords in it"
@@ -2635,12 +2703,19 @@
or:[m selector = Class nameOfOldVersionMethod]]) ifTrue:[
"/ it's my version method - make sure that it has $'s around...
newSource := self ensureDollarsInVersionMethod:rewriteQuery source.
+ (m selector = Class nameOfOldVersionMethod) ifTrue:[
+ "/ #version method: make sure that it contains proper
+ "/ keyword (Header for CVS/P4, Id for SVN...
+ newSource := self ensureKeywordInVersionMethod: newSource.
+ ]
] ifFalse:[
"/ it's another manager's version method - make sure that it has NONONO $'s around...
newSource := self ensureNoDollarsInVersionMethod:rewriteQuery source.
].
rewriteQuery proceedWith:newSource
] do:aBlock.
+
+ "Modified: / 27-09-2011 / 16:48:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
writeHistoryLogSince:timeGoal filterSTSources:filterSTSourcesBoolean filterUser:userFilter filterRepository:repositoryFilter filterModules:moduleFilter filterProjects:projectFilterArg to:aStream
@@ -3091,7 +3166,7 @@
!AbstractSourceCodeManager class methodsFor:'documentation'!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.255 2011-09-07 02:42:35 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.256 2011-09-27 16:10:26 vrany Exp $'
! !
AbstractSourceCodeManager initialize!