PerforceSourceCodeManager.st
changeset 2355 6c21470136d2
parent 2354 ff5d19f308b4
child 2359 62c8ea518b59
--- a/PerforceSourceCodeManager.st	Tue Apr 19 14:16:22 2011 +0200
+++ b/PerforceSourceCodeManager.st	Tue Apr 19 14:17:50 2011 +0200
@@ -19,6 +19,13 @@
         privateIn:PerforceSourceCodeManager
 !
 
+VersionInfo subclass:#PerforceVersionInfo
+        instanceVariableNames:'repositoryPathName'
+        classVariableNames:''
+        poolDictionaries:''
+        privateIn:PerforceSourceCodeManager
+!
+
 Object subclass:#WorkSpaceDefinition
         instanceVariableNames:'client host localDir owner repositoryDir root workSpaceName
                 workSpaceDefinitionFilename moduleName'
@@ -2284,6 +2291,106 @@
     ^ workSpaceDefinition at:#workSpaceDefinitionFilename ifAbsent:nil.
 ! !
 
+!PerforceSourceCodeManager::PerforceVersionInfo class methodsFor:'documentation'!
+
+documentation
+"
+    Class used to return a Dictionary when asked for versionInfo.
+    This has been replaced by instances of VersionInfo and subclasses.
+
+    Notice, that CVSVersionInfo adds some CVS specific data.
+
+    [author:]
+        cg (cg@AQUA-DUO)
+"
+! !
+
+!PerforceSourceCodeManager::PerforceVersionInfo class methodsFor:'instance creation'!
+
+fromRCSString:aString
+    "{ Pragma: +optSpace }"
+
+    "I know how to parse RCS/CVS version id strings.
+     Return an instance filled with revision info which is
+     extracted from aString. This must be in RCS/CVS format."
+
+    |words firstWord info nm indexOfLastHash|
+
+    words := aString asCollectionOfWords.
+    words size < 2 ifTrue:[
+        ^ nil
+    ].
+    firstWord := words first.
+
+    info := self new.
+
+    "/
+    "/ supported formats:
+    "/
+    "/ $-Header:   pathName#rev $
+
+    (firstWord = '$Header:') ifTrue:[
+        nm := words second.
+        indexOfLastHash := nm lastIndexOf:$#.
+        indexOfLastHash ~= 0 ifTrue:[
+            info fileName:((nm copyTo:(indexOfLastHash - 1)) asFilename baseName).
+            info repositoryPathName:(nm copyTo:(indexOfLastHash - 1)).
+            info revision:((nm copyFrom:indexOfLastHash + 1) asCollectionOfWords first).
+        ].
+        ^ info
+    ].
+
+
+    ^ nil
+
+    "
+     PerforceVersionInfo fromRCSString:'$Header: /cvs/stx/stx/libbasic3/PerforceSourceCodeManager.st,v 1.9 2011-04-19 12:17:50 cg Exp $'
+    "
+
+    "Modified: / 22-10-2008 / 20:17:00 / cg"
+! !
+
+!PerforceSourceCodeManager::PerforceVersionInfo methodsFor:'accessing'!
+
+repositoryPathName
+    ^ repositoryPathName
+!
+
+repositoryPathName:something
+    repositoryPathName := something.
+!
+
+state
+    ^ ''
+!
+
+timeZone
+    ^ ''
+!
+
+timezone
+    ^ ''
+
+    "Created: / 22-10-2008 / 20:50:39 / cg"
+! !
+
+!PerforceSourceCodeManager::PerforceVersionInfo methodsFor:'queries'!
+
+getVersionString
+
+    |stream|
+
+    stream := WriteStream on:''.
+    stream nextPutAll:'$Header:'.
+    stream space.
+    stream nextPutAll:repositoryPathName.
+    stream nextPut:$#.
+    stream nextPutAll:revision printString.
+    stream space.
+    stream nextPut:$$.
+    ^ stream contents
+! !
+
 !PerforceSourceCodeManager::WorkSpaceDefinition methodsFor:'accessing'!
 
 client
@@ -2390,7 +2497,7 @@
 !PerforceSourceCodeManager class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic3/PerforceSourceCodeManager.st,v 1.8 2011-04-19 12:16:22 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/PerforceSourceCodeManager.st,v 1.9 2011-04-19 12:17:50 cg Exp $'
 ! !
 
 PerforceSourceCodeManager initialize!