initial checkin cvs_MAIN
authorClaus Gittinger <cg@exept.de>
Mon, 21 Jul 2014 12:28:00 +0100
branchcvs_MAIN
changeset 502 844bac3030a1
parent 501 4be1efdcbf41
child 503 14d868f983a9
initial checkin class: HGSourceCodeManager comment/format in: #revisionLogOf:fromRevision:toRevision:numberOfRevisions:fileName:directory:module:
mercurial/HGSourceCodeManager.st
--- a/mercurial/HGSourceCodeManager.st	Fri May 23 10:29:38 2014 +0100
+++ b/mercurial/HGSourceCodeManager.st	Mon Jul 21 12:28:00 2014 +0100
@@ -57,6 +57,13 @@
     ^ HGRepository discoverPackage: packageId
 
     "Modified: / 04-07-2013 / 02:16:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+utilities
+
+    ^HGSourceCodeManagerUtilities forManager: self.
+
+    "Created: / 24-03-2014 / 12:48:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGSourceCodeManager class methodsFor:'accessing-classes'!
@@ -73,9 +80,10 @@
     "Answer the package manager class used to get
      package models"
     
-    ^ HGPackageModelRegistry
+    ^ HGPackageWorkingCopyRegistry
 
     "Created: / 13-11-2012 / 23:59:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 05-03-2014 / 21:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGSourceCodeManager class methodsFor:'accessing-tools'!
@@ -116,7 +124,7 @@
 
     | pkg repo root file rev |
 
-    pkg := HGPackageModel named: (moduleDir , ':' , packageDir).  
+    pkg := HGPackageWorkingCopy named: (moduleDir , ':' , packageDir).  
     pkg isNil ifTrue:[ ^ nil ].
     repo := pkg repository.
 
@@ -164,7 +172,7 @@
         ^file readStream.
     ]
 
-    "Modified: / 09-07-2013 / 15:44:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 05-03-2014 / 21:45:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 streamForExtensionFile:fileName package:pkgId directory:packageDir module:moduleDir cache:doCache
@@ -172,7 +180,7 @@
 
     defClass := ProjectDefinition definitionClassForPackage:pkgId.
     rev := defClass hgLogicalRevision.
-    pkg := HGPackageModel named: (moduleDir , ':' , packageDir).  
+    pkg := HGPackageWorkingCopy named: (moduleDir , ':' , packageDir).  
     pkg isNil ifTrue:[ ^ nil ].
     repo := pkg repository.
     root := (repo @ rev) / pkg repositoryRoot.
@@ -204,7 +212,7 @@
     ]
 
     "Created: / 27-03-2013 / 11:49:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 08-07-2013 / 02:26:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 05-03-2014 / 21:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGSourceCodeManager class methodsFor:'basic administration'!
@@ -251,7 +259,10 @@
     ^ self shouldImplement
 !
 
-revisionLogOf:clsOrNil fromRevision:rev1OrNil toRevision:rev2OrNil numberOfRevisions:limitOrNil fileName:classFileName directory:packageDir module:moduleDir
+revisionLogOf:clsOrNil 
+        fromRevision:rev1OrNil toRevision:rev2OrNil numberOfRevisions:limitOrNil 
+        fileName:classFileName directory:packageDir module:moduleDir
+
     "Actually do return a revisionLog. The main worker method. This must be implemented by a 
      concrete source-code manager. The interface of this method is just crazy!!
 
@@ -293,7 +304,7 @@
     | pkg repo path wcentry info newest oldest startRev stopRev limit log revs startRevIndex stopRevIndex revIndex |
 
     info := IdentityDictionary new.
-    pkg := HGPackageModel named: (moduleDir , ':' , packageDir).
+    pkg := HGPackageWorkingCopy named: (moduleDir , ':' , packageDir).
     repo := pkg repository.
     path := pkg repositoryRoot.
     wcentry := repo workingCopy / path / classFileName.
@@ -348,7 +359,7 @@
 
     ^info
 
-    "Modified (format): / 11-02-2014 / 14:50:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 05-03-2014 / 21:45:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGSourceCodeManager class methodsFor:'queries'!
@@ -492,15 +503,27 @@
 !
 
 revisionInfoFromString:aString
-    "{ Pragma: +optSpace }"
+    | revInfo |
+
+    revInfo := HGRevisionInfo fromString: aString.
+    revInfo isNotExpanded ifTrue:[ 
+        "/ Sigh, this method is called from ProjectDefinition>>extensionsRevisionInfoForManager:
+        "/ however here we don't know for what package it's called (no class nor package info
+        "/ provided. Hence the thisContext sender receiver hack.
 
-    ^ HGRevisionInfo fromString: aString
+        | senderReceiver |
+        (senderReceiver := thisContext sender receiver) isProjectDefinition ifTrue:[ 
+            revInfo := HGRevisionInfo new.
+            revInfo changesetId: senderReceiver hgLogicalRevision.
+        ].
+    ].
+    ^ revInfo
 
-    "Modified: / 20-11-2012 / 23:26:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 02-05-2014 / 18:05:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 revisionInfoFromString: vsnString inClass: class
-    | revMethod revInfo revAnnotation def clsBinRev |
+    | revInfo def clsBinRev |
 
     "NOTE: class argument may be nil if called for extensions, sigh"
 
@@ -514,48 +537,54 @@
         ].
     ].
 
-    revInfo := self revisionInfoFromString: (clsBinRev ? vsnString).
-    class notNil ifTrue:[
-        revInfo className: class name.
-    ].
-    revInfo changesetId isNull ifTrue:[
-        "/ Patch changesetId - it it might be not in the vsnString if class is
-        "/ loaded from sources...
-        | package selector |
+    revInfo := self revisionInfoFromString: vsnString.
+
+    revInfo isNotExpanded ifTrue:[ 
+        | pkg |
 
         "When called for extensions, class may be nil. But in this case we don't know
          the extension's package, so we have to guess it.
          What a stupid, CVS-centric interface. Playing with strings is simply too bad."
 
+        revInfo := HGRevisionInfo new.
+        revInfo changesetId: HGChangesetId null.
         class notNil ifTrue:[
-            package := class package.
-            selector := self nameOfVersionMethodInClasses.
+            pkg := class package.
         ] ifFalse:[
             "Add more cases here..."
             (thisContext sender selector == #loadExtensionsForPackage:language:) ifTrue:[
-                package := thisContext sender argAt: 1.
-                selector := self nameOfVersionMethodForExtensions
+                pkg := thisContext sender argAt: 1.
             ]
         ].
 
-        def := ProjectDefinition definitionClassForPackage: package.
-        revMethod := (class ? def) theMetaclass compiledMethodAt: selector.
-        revMethod notNil ifTrue:[
-            revAnnotation := revMethod annotationAt: #HGRevision:.
-            revAnnotation notNil ifTrue:[
-                revInfo changesetId: revAnnotation revision.
+        pkg notNil ifTrue:[    
+            | rev |
+            def := ProjectDefinition definitionClassForPackage: pkg.
+            [ def isNil ] whileTrue:[
+                pkg := pkg asPackageId parentPackage.
+                pkg isNil ifTrue:[ 
+                    ^ nil.
+                ].
+                pkg := pkg asString.
+                (self isResponsibleForPackage: pkg) ifFalse:[ 
+                    ^ nil
+                ].
+                def := ProjectDefinition definitionClassForPackage: pkg.      
             ].
-        ].
-        revInfo changesetId isNull ifTrue:[
-            def ~~ class ifTrue:[
-                revInfo changesetId: (def revisionInfoOfManager:self) changesetId.
+            rev := def hgLogicalRevision.
+            rev notNil ifTrue:[ 
+                revInfo changesetId: rev.
             ].
         ].
     ].
+
+    class notNil ifTrue:[
+        revInfo className: class name.
+    ]. 
     ^revInfo
 
     "Created: / 30-11-2012 / 21:48:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 09-07-2013 / 01:16:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 23-05-2014 / 12:28:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 withSourceRewriteHandlerDo:aBlock
@@ -575,12 +604,20 @@
 
 !HGSourceCodeManager class methodsFor:'documentation'!
 
+version
+    ^ '$Header$'
+!
+
+version_CVS
+    ^ '$Path: stx/libscm/mercurial/HGSourceCodeManager.st, Version: 1.0, User: cg, Time: 2014-07-21T13:28:10.331$'
+!
+
 version_HG
 
     ^ '$Changeset: <not expanded> $'
 !
 
 version_SVN
-    ^ '§Id::                                                                                                                        §'
+    ^ '$Id$'
 ! !