moved svnRevision to stx:libsvn stx_6_2_2
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 23 Jul 2012 19:28:33 +0200
changeset 1113 b0258d0a5d81
parent 1112 98ffcd3ba7fe
child 1114 e92bfe84c61f
moved svnRevision to stx:libsvn
extensions.st
--- a/extensions.st	Mon Jul 23 19:21:39 2012 +0200
+++ b/extensions.st	Mon Jul 23 19:28:33 2012 +0200
@@ -991,6 +991,65 @@
     "Created: / 08-04-2011 / 16:01:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!ProjectDefinition class methodsFor:'accessing - svn'!
+
+svnRevision
+
+    "
+        Answers SVN revision of given package. The revision is computed
+        as follows:
+        1) Look at package directory if there is .svn administration
+           directory. If so, uses SVN to obtain SVN revision & return
+        2) If svnRevisionNr return non-nil, use that as SVN revision & return
+        3) If everything fails, compute maximum from all revision of all
+           classes & extensions
+    "
+    | pkgDir revNr |
+
+    "1)"
+    pkgDir := self packageDirectory.
+    (pkgDir notNil and: [pkgDir exists and: [(pkgDir / '.svn') exists]]) ifTrue:
+        [[revNr := (SVN::InfoCommand new
+                    workingCopy: (SVN::WorkingCopy branch: (SVN::Branch new) path: pkgDir);
+                    execute) anyOne revision]
+                        value
+                        "/on: Error do: [revNr := nil]
+                        ].
+    revNr ifNotNil:[^SVN::Revision number:revNr].
+    "2)"
+    "We have to explicitly check for existence of svnRevisionNr,
+     because we don't want to invoke inherited method"
+    (self class methodDictionary includesKey: #svnRevisionNr)
+        ifTrue:[revNr := self perform:#svnRevisionNr].
+    revNr ifNotNil:[
+        (revNr startsWith: 'nil') ifTrue:[ ^ SVN::Revision head].      
+        ^SVN::Revision number:(revNr asString select:[:e|e isDigit])
+    ].
+
+    "3)"
+    revNr := (self searchForClassesWithProject: self package)
+                inject: 0
+                into:
+                    [:rev :cls|
+                    ((cls revision ? '.') includes: $.)"/ CVS revision number?
+                        ifTrue:[rev]
+                        ifFalse:[rev max: (cls revision ? '0') asNumber]].
+    ^revNr ~= 0
+        ifTrue: [SVN::Revision number:revNr]
+        ifFalse:[SVN::Revision head]
+
+    "
+        stx_libbasic svnRevision
+        stx_goodies_libsvn svnRevision
+        stx_goodies_libsvn revision
+
+    "
+
+    "Created: / 15-06-2009 / 11:54:33 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 22-08-2009 / 09:06:29 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 23-07-2012 / 18:08:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !String methodsFor:'converting'!
 
 asSVNRevisionSpec