CVSSourceCodeManager.st
changeset 4144 f06214e8e084
parent 4113 c8014ba8731a
child 4157 3eb587af122a
--- a/CVSSourceCodeManager.st	Fri Nov 18 16:04:55 2016 +0100
+++ b/CVSSourceCodeManager.st	Fri Nov 18 16:14:11 2016 +0100
@@ -23,6 +23,13 @@
 	category:'System-SourceCodeManagement'
 !
 
+VersionInfo subclass:#CVSVersionInfo
+	instanceVariableNames:'repositoryPathName timeZone'
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:CVSSourceCodeManager
+!
+
 !CVSSourceCodeManager class methodsFor:'documentation'!
 
 copyright
@@ -5720,6 +5727,171 @@
     "Created: / 16-08-2006 / 10:58:19 / cg"
 ! !
 
+!CVSSourceCodeManager::CVSVersionInfo class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 2009 by eXept Software AG
+              All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
+
+documentation
+"
+    In ancient times, Class used to return a Dictionary when asked for versionInfo.
+    This has been replaced by instances of VersionInfo and subclasses.
+
+    CVSVersionInfo adds some CVS specific data.
+
+    [author:]
+        cg (cg@AQUA-DUO)
+"
+!
+
+version
+    ^ '$Header$'
+!
+
+version_CVS
+    ^ '$Header$'
+! !
+
+!CVSSourceCodeManager::CVSVersionInfo 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 nextWord info nm s fn revString d |
+
+    s := aString readStream.
+    s skipSeparators.
+    firstWord := s upToSeparator.
+
+    info := self new.
+
+    "/
+    "/ supported formats:
+    "/
+    "/ $-Header:   pathName rev date time user state $
+    "/ $-Revision: rev $
+    "/ $-Id:       fileName rev date time user state $
+    "/
+    (firstWord = '$Header:' or:[firstWord = '§Header:']) ifTrue:[
+        d := firstWord first.
+        s skipSeparators.
+        nm := s throughAll:',v '.
+        nm := nm withoutSeparators.
+        info repositoryPathName:nm.
+        info fileName:(nm asFilename baseName copyButLast:2).
+        words := s upToEnd asCollectionOfWords readStream.
+
+        words atEnd ifFalse:[
+            nextWord := words next.
+            nextWord first ~= d ifTrue:[
+                info revision:nextWord.
+                nextWord := words next.
+                (nextWord notNil and:[nextWord first ~= d]) ifTrue:[
+                    info date:nextWord.
+                    info time:words next.
+                    nextWord := words next.
+                    (nextWord notNil and:[nextWord startsWithAnyOf:'+-']) ifTrue:[
+                        info timezone:nextWord.
+                        nextWord := words next.
+                    ].
+                    info user:nextWord.
+                    info state:words next.
+                ]
+            ].
+        ].
+        ^ info
+    ].
+
+    (firstWord = '$Revision:' or:[firstWord = '§Revision:']) ifTrue:[
+        info revision:(s upToEnd asCollectionOfWords first).
+        ^ info
+    ].
+
+    (firstWord = '$Id:' or:[firstWord = '§Id:']) ifTrue:[
+        "/commented out by Jan Vrany, 2009/10/20
+        "/according to http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html
+        "/svn has no support for $ Header $ expansion. Therefore
+        "/libsvn uses $Id$ instead.
+        "/self halt:'no longer supported'.        
+        words := s upToEnd asCollectionOfWords readStream.
+        info fileName:(fn := words next).
+        (fn endsWith:',v') ifFalse:[
+            "/ not a CVS version
+            ^ nil
+        ].
+        info revision:(revString := words next).
+
+        "/ do not use matchesRegex:'[0-9]+\.[0-9]+.*') here: regex is an optional package
+        ((revString conform:[:c | c isDigit or:[c == $.]])
+        and:[revString includes:$.]) ifFalse:[
+            "/ not a CVS version
+            ^ nil
+        ].
+        info date:(words next).
+        info time:(words next).
+        info user:(words next).
+        info state:(words next).
+        ^ info
+    ].
+
+    ^ nil
+
+    "
+     CVSVersionInfo fromRCSString:('$' , 'Revision: 1.122 $')
+     CVSVersionInfo fromRCSString:(CVSSourceCodeManager version)
+     CVSVersionInfo fromRCSString:(SVNSourceCodeManager version_CVS)
+    "
+
+    "Modified (comment): / 11-10-2011 / 23:41:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 22-11-2011 / 16:15:49 / cg"
+    "Modified (format): / 24-11-2011 / 10:56:51 / cg"
+! !
+
+!CVSSourceCodeManager::CVSVersionInfo methodsFor:'accessing'!
+
+repositoryPathName
+    ^ repositoryPathName
+!
+
+repositoryPathName:something
+    repositoryPathName := something.
+!
+
+timeZone
+    ^ timeZone
+!
+
+timeZone:something
+    timeZone := something.
+!
+
+timezone
+    ^ timeZone
+
+    "Created: / 22-10-2008 / 20:50:39 / cg"
+!
+
+timezone:something
+    timeZone := something.
+
+    "Created: / 22-10-2008 / 20:50:32 / cg"
+! !
+
 !CVSSourceCodeManager class methodsFor:'documentation'!
 
 version