CVSSourceCodeManager.st
changeset 1451 561003a458bb
parent 1448 50aa98fb89be
child 1457 8383e94050aa
--- a/CVSSourceCodeManager.st	Tue Jan 31 23:53:02 2006 +0100
+++ b/CVSSourceCodeManager.st	Wed Feb 01 23:17:12 2006 +0100
@@ -4003,11 +4003,25 @@
     "Modified: 29.1.1997 / 19:00:35 / cg"
 !
 
-revisionLogOf:clsOrNil fromRevision:rev1 toRevision:rev2 fileName:classFileName directory:packageDir module:moduleDir
+revisionLogOf:clsOrNil fromRevision:firstRev toRevision:lastRef fileName:classFileName directory:packageDir module:moduleDir 
+    ^ self 
+        revisionLogOf:clsOrNil
+        fromRevision:firstRev
+        toRevision:lastRef
+        numberOfRevisions:nil
+        fileName:classFileName
+        directory:packageDir
+        module:moduleDir
+!
+
+revisionLogOf:clsOrNil fromRevision:firstRev toRevision:lastRef numberOfRevisions:numRevisions fileName:classFileName directory:packageDir module:moduleDir
     "return info about the repository container and
      (part of) the revisionlog as a collection of revision entries.
      Return nil on failure.
 
+     If numRevisions is notNil, it limits the number of revision records returned -
+     only numRevions of the newest revision infos will be collected.
+
      The returned information is a structure (IdentityDictionary)
      filled with:
             #container          -> the RCS/CVS container file name 
@@ -4017,10 +4031,10 @@
             #numberOfRevisions  -> the number of revisions in the container (nil for all)
             #revisions          -> collection of per-revision info (see below)
 
-            rev1 / rev2 specify from which revisions a logEntry is wanted:
-             -If rev1 is nil, the first revision is the initial revision
+            firstRev / lastRef specify from which revisions a logEntry is wanted:
+             -If firstRev is nil, the first revision is the initial revision
               otherwise, the log starts with that revision.
-             -If rev2 is nil, the last revision is the newest revision
+             -If lastRef is nil, the last revision is the newest revision
               otherwise, the log ends with that revision.
 
              -If both are nil, all logEntries are extracted.
@@ -4033,13 +4047,14 @@
               #date                  -> when was it checked in
               #state                 -> the RCS state
               #numberOfChangedLines  -> the number of changed line w.r.t the previous
+              #logMessage            -> the checkIn log message
 
             revisions are ordered newest first 
             (i.e. the last entry is for the initial revision; the first for the most recent one)
         "
 
     |tempDir fullName modulePath inStream inHeaderInfo atEnd line revArg idx
-     info record revisionRecords s headerOnly msg |
+     info record revisionRecords s headerOnly msg|
 
     modulePath :=  moduleDir , '/' , packageDir. 
     fullName :=  modulePath , '/' , classFileName.
@@ -4060,18 +4075,18 @@
 
         revArg := ''.
         headerOnly := false.
-        (rev1 notNil or:[rev2 notNil]) ifTrue:[
-            (rev1 == 0 and:[rev2 == 0]) ifTrue:[
+        (firstRev notNil or:[lastRef notNil]) ifTrue:[
+            (firstRev == 0 and:[lastRef == 0]) ifTrue:[
                 revArg := '-h'.
                 headerOnly := true.
             ] ifFalse:[
                 revArg := '-r'.
-                rev1 notNil ifTrue:[
-                    revArg := revArg , rev1
+                firstRev notNil ifTrue:[
+                    revArg := revArg , firstRev
                 ].
                 revArg := revArg , ':'.
-                rev2 notNil ifTrue:[
-                    revArg := revArg , rev2
+                lastRef notNil ifTrue:[
+                    revArg := revArg , lastRef
                 ].
             ]
         ].
@@ -4122,6 +4137,19 @@
                     ]
                 ].
                 gotIt ifFalse:[
+                    (line startsWith:'symbolic names:') ifTrue:[
+                        |tags tokens|
+
+                        tags := Dictionary new.
+                        line:= inStream nextLine.
+                        [line notNil 
+                         and:[(line startsWith:Character space) or:[line startsWith:Character tab]]] whileTrue:[
+                            tokens := line asCollectionOfSubstringsSeparatedBy:$:.
+                            tags at:(tokens first withoutSeparators) put:(tokens second withoutSeparators).
+                            line:= inStream nextLine.
+                        ].
+                        info at:#symbolicNames put:tags.
+                    ].
                     (line startsWith:'description:') ifTrue:[inHeaderInfo := false].
                 ]
             ]
@@ -4151,66 +4179,23 @@
             atEnd := false.
             [atEnd or:[inStream atEnd]] whileFalse:[
                 record := self readRevisionLogEntryFromStream:inStream.
-
-"/                revLine1 := inStream nextLine.
-"/                [revLine1 notNil and:[(revLine1 startsWith:'revision ') not]]
-"/                    whileTrue:[inStream atEnd ifTrue:[
-"/                                revLine1 := nil
-"/                               ] ifFalse:[
-"/                                revLine1 := inStream nextLine.]].
-"/                revLine2 := inStream nextLine.
-"/                (revLine1 notNil and:[revLine2 notNil]) ifTrue:[
-"/                    record := IdentityDictionary new.
-"/                    record at:#revision put:(revLine1 asCollectionOfWords at:2).
-"/                    "/ decompose date/author/state etc.
-"/                    (revLine2 asCollectionOfSubstringsSeparatedBy:$;) do:[:info |
-"/                        |subEntry|
-"/                        subEntry := info withoutSeparators.
-"/                        #('date:'   #date
-"/                          'author:' #author 
-"/                          'state:'  #state 
-"/                          'lines:'  #numberOfChangedLines
-"/                         ) pairWiseDo:[:word :key |
-"/                            s := subEntry restAfter:word withoutSeparators:true.
-"/                            s notNil ifTrue:[record at:key put:s.].                        
-"/                        ].
-"/                    ].
-"/
-"/                    "first revision does not hav a 'lines:' entry"
-"/                    (record includesKey:#numberOfChangedLines) ifFalse:[
-"/                        record at:#numberOfChangedLines put:''
-"/                    ].
-"/
-"/                    s := nil.
-"/                    line := inStream nextLine.
-"/                    [atEnd or:[line isNil or:[line startsWith:'--------']]] whileFalse:[
-"/                        (line startsWith:'==========') ifTrue:[
-"/                            atEnd := true.
-"/                        ] ifFalse:[
-"/                            (line withoutSpaces = '.') ifTrue:[
-"/                                line := '*** empty log message ***'
-"/                            ].
-"/                            s isNil ifTrue:[
-"/                                s := line
-"/                            ] ifFalse:[
-"/                                s := s , Character cr asString , line.
-"/                            ].
-"/                            line := inStream nextLine.
-"/                        ]
-"/                    ].
-"/                    record at:#logMessage put:s.
-"/                    revisionRecords add:record.
-"/                ]
                 record isNil ifTrue:[
                     atEnd := true.
                 ] ifFalse:[
                     revisionRecords add:record.
+                ].
+                (numRevisions notNil and:[revisionRecords size >= numRevisions]) ifTrue:[
+                    atEnd := true
                 ]
             ].
         ].
     ] ensure:[
         inStream notNil ifTrue:[inStream close].
-        tempDir recursiveRemove
+        OperatingSystem accessDeniedErrorSignal handle:[:ex |
+            ('CVSSourceCodeManager [warning]: could not remove tempDir ', tempDir pathName) infoPrintCR.
+        ] do:[
+            tempDir recursiveRemove
+        ].
     ].
     ^ info
 
@@ -4229,158 +4214,14 @@
 !
 
 revisionLogOf:clsOrNil numberOfRevisions:numRevisions fileName:classFileName directory:packageDir module:moduleDir
-    "return info about the repository container and
-     (part of) the revisionlog (numRevisions newest revisions)
-     as a collection of revision entries.
-     Return nil on failure.
-
-     The returned information is a structure (IdentityDictionary)
-     filled with:
-            #container          -> the RCS container file name 
-            #filename           -> the actual source file name
-            #newestRevision     -> the revisionString of the newest revision
-            #numberOfRevisions  -> the number of revisions in the container (nil for all)
-            #revisions          -> collection of per-revision info (see below)
-
-            rev1 / rev2 specify from which revisions a logEntry is wanted:
-             -If rev1 is nil, the first revision is the initial revision
-              otherwise, the log starts with that revision.
-             -If rev2 is nil, the last revision is the newest revision
-              otherwise, the log ends with that revision.
-
-             -If both are nil, all logEntries are extracted.
-             -If both are 0 (not nil), no logEntries are extracted (i.e. only the header).
-
-            per revision info consists of one record per revision:
-
-              #revision              -> the revision string
-              #author                -> who checked that revision into the repository
-              #date                  -> when was it checked in
-              #state                 -> the RCS state
-              #numberOfChangedLines  -> the number of changed line w.r.t the previous
-              #logMessage            -> the checkIn log message
-
-            revisions are ordered newest first 
-            (i.e. the last entry is for the initial revision; the first for the most recent one)
-        "
-
-    |tempDir fullName modulePath inStream inHeaderInfo atEnd line revArg idx
-     info record revisionRecords s msg|
-
-    modulePath :=  moduleDir , '/' , packageDir. 
-    fullName :=  modulePath , '/' , classFileName.
-    tempDir := self createTempDirectory:nil forModule:nil.
-    tempDir isNil ifTrue:[
-        ('CVSSourceCodeManager [error]: no tempDir - cannot extract log') errorPrintCR.
-        ^ nil.
-    ].
-
-    [
-        self createEntryFor:fullName 
-             module:moduleDir
-             in:(tempDir construct:modulePath) 
-             revision:'1.1' 
-             date:'dummy' 
-             special:''
-             overwrite:false.
-
-        revArg := ''.
-
-        msg := 'reading revision log '.
-        clsOrNil isNil ifTrue:[
-            msg := msg , 'in ' , fullName.
-        ] ifFalse:[
-            msg := msg , 'of ', clsOrNil name.
-        ].
-        self activityNotification:msg.
-
-        inStream := self 
-                        executeCVSCommand:('log ' , revArg , ' ' , fullName) 
-                        module:moduleDir 
-                        inDirectory:tempDir 
-                        log:true 
-                        pipe:true.
-
-        inStream isNil ifTrue:[
-            ('CVSSourceCodeManager [error]: cannot open pipe to cvs log ', fullName) errorPrintCR.
-            ^ nil
-        ].
-
-        "/
-        "/ read the commands pipe output and extract the container info
-        "/
-        info := IdentityDictionary new.
-        inHeaderInfo := true.
-        [inHeaderInfo and:[inStream atEnd not]] whileTrue:[
-            line:= inStream nextLine.
-            line notNil ifTrue:[
-                |gotIt|
-
-                gotIt := false.
-                #('RCS file:'        #container
-                  'Working file:'    #filename
-                  'head:'            #newestRevision
-                  'total revisions:' #numberOfRevisions
-                 ) pairWiseDo:[:word :key |
-                    gotIt ifFalse:[
-                        s := line restAfter:word withoutSeparators:true.
-                        s notNil ifTrue:[info at:key put:s. gotIt := true].                        
-                    ]
-                ].
-                gotIt ifFalse:[
-                    (line startsWith:'description:') ifTrue:[inHeaderInfo := false].
-                ]
-            ]
-        ].
-        inStream nextLine. "/ skip separating line after description.
-
-        info isEmpty ifTrue:[
-            ('CVSSourceCodeManager [warning]: no log for ', fullName) errorPrintCR.
-            ^ nil
-        ].
-
-        "/ strip selected revisions from the total-revisions entry
-        s := info at:#numberOfRevisions.
-        (idx := s indexOf:$;) ~~ 0 ifTrue:[
-            info at:#numberOfRevisions put:(Integer readFrom:(s copyTo:idx - 1))
-        ] ifFalse:[
-            info at:#numberOfRevisions put:(Integer readFrom:s onError:[1])
-        ].
-
-        "/
-        "/ continue to read the commands pipe output 
-        "/ and extract revision-info records
-        "/
-        revisionRecords := OrderedCollection new:(info at:#numberOfRevisions).
-        info at:#revisions put:revisionRecords.
-
-        atEnd := false.
-        [atEnd or:[inStream atEnd]] whileFalse:[
-            record := self readRevisionLogEntryFromStream:inStream.
-            record isNil ifTrue:[
-                atEnd := true.
-            ] ifFalse:[
-                revisionRecords add:record.
-            ].
-            (numRevisions notNil and:[revisionRecords size >= numRevisions]) ifTrue:[
-                atEnd := true
-            ]
-        ].
-    ] ensure:[
-        inStream notNil ifTrue:[inStream shutDown. inStream close.].
-        OperatingSystem accessDeniedErrorSignal handle:[:ex |
-            ('CVSSourceCodeManager [warning]: could not remove tempDir ', tempDir pathName) infoPrintCR.
-        ] do:[
-            tempDir recursiveRemove
-        ].
-    ].
-    ^ info
-
-    "
-     SourceCodeManager revisionLogOf:Array 
-     SourceCodeManager revisionLogOf:Array numberOfRevisions:5
-
-    "
+    ^ self 
+        revisionLogOf:clsOrNil
+        fromRevision:nil
+        toRevision:nil
+        numberOfRevisions:numRevisions
+        fileName:classFileName
+        directory:packageDir
+        module:moduleDir
 !
 
 statusOf:clsOrNil fileName:classFileName directory:packageDir module:moduleDir
@@ -4486,7 +4327,7 @@
 !CVSSourceCodeManager class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/CVSSourceCodeManager.st,v 1.295 2006-01-24 16:26:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/CVSSourceCodeManager.st,v 1.296 2006-02-01 22:16:35 stefan Exp $'
 ! !
 
 CVSSourceCodeManager initialize!