Fix for issue #26: Java extension files are removed.
--- a/common/SCMAbstractFileoutLikeTask.st Fri Nov 29 15:49:36 2013 +0000
+++ b/common/SCMAbstractFileoutLikeTask.st Fri Nov 29 21:00:10 2013 +0000
@@ -294,8 +294,22 @@
ActivityNotification notify:'Removing old containers'.
wcroot := package temporaryWorkingCopyRoot.
containers := self package containers.
+
containersToKeep := self package containersToKeep.
containersToDelete := containers \ containersToKeep.
+ "/ Fix for issue #26: Java extension files are removed.
+ "/ Filter out all Java extension containers which are for classes which
+ "/ are currently not loaded.
+ containersToDelete := containersToDelete reject:[:each |
+ (each startsWith: 'java/extensions/')
+ and:[
+ | nm |
+
+ nm := each copyFrom:17 to: (each lastIndexOf: $.) - 1.
+ (JavaVM registry classes contains: [:cls | cls binaryName = nm]) not.
+ ].
+ ].
+
containersToDelete do:[:nm|
| entry |
@@ -305,7 +319,7 @@
"Created: / 11-04-2008 / 11:00:27 / Jan Vrany <vranyj1@fel.cvut.cz>"
"Modified: / 19-08-2009 / 15:03:51 / Jan Vrany <vranyj1@fel.cvut.cz>"
- "Modified: / 15-11-2012 / 00:54:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 29-11-2013 / 17:56:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doRenameContainerForClassNamed: new using: renames language: lang
--- a/mercurial/HGStXTests.st Fri Nov 29 15:49:36 2013 +0000
+++ b/mercurial/HGStXTests.st Fri Nov 29 21:00:10 2013 +0000
@@ -1204,6 +1204,80 @@
"
"Created: / 11-06-2013 / 00:16:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_commit_16a
+ "
+ Test correct fileout if Java extensions
+ "
+
+ | repo pmN111 ctN111 java_lang_String changeset |
+
+ repo := self repositoryNamed: 'mocks/hg/p5'.
+ self assert: (Smalltalk loadPackage:'mocks:hg/p5').
+
+ "/ Do skipIf after package is loaded!!!!!! otherwise the
+ "/ Java extension is not loaded!!
+ self skipIf: self stxlibjavaAvailable not description: 'STX:LIBJAVA not available'.
+
+ java_lang_String := Java classForName: 'java.lang.String'.
+ (Compiler compile:'test_commit_16a ^ #foo' forClass: java_lang_String)
+ package:#'mocks:hg/p5'.
+ self assert: (java_lang_String methodDictionary includesKey:#test_commit_16a).
+
+ pmN111 := HGPackageModel named: #'mocks:hg/p5'.
+ ctN111 := pmN111 commitTask.
+ ctN111 message:'test_commit_16a '.
+ ctN111 do.
+ "
+ repo workingCopy browse
+ "
+ changeset := repo @ 2.
+
+ self assert: (changeset changes contains:[:change | change isAdded ]).
+ self deny: (changeset changes contains:[:change | change isRemoved ]).
+
+ self assert: (changeset / 'java' / 'extensions' / 'java' / 'lang' / 'String.st' ) notNil.
+
+ "Created: / 29-11-2013 / 16:25:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_commit_16b
+ "
+ Test covering issue #26: Java extension files are removed.
+
+ Check, that if the particular class is not loaded in the system,
+ extension file is kept intact.
+ "
+
+ | repo pmN111 ctN111 changeset |
+
+ repo := self repositoryNamed: 'mocks/hg/p5'.
+ self assert: (Smalltalk loadPackage:'mocks:hg/p5').
+
+ "/ Do skipIf after package is loaded!!!!!! otherwise the
+ "/ Java extension is not loaded!!
+ self skipIf: self stxlibjavaAvailable not description: 'STX:LIBJAVA not available'.
+
+ "/ Flush Java to make sure java.lang.Object is not loaded.
+ (Smalltalk at:#Java) flushAllJavaResources.
+
+
+ pmN111 := HGPackageModel named: #'mocks:hg/p5'.
+ ctN111 := pmN111 commitTask.
+ ctN111 message:'test_commit_16a '.
+ ctN111 do.
+ "
+ repo workingCopy browse
+ "
+ changeset := repo @ 2.
+
+ self deny: (changeset changes contains:[:change | change isAdded ]).
+ self deny: (changeset changes contains:[:change | change isRemoved ]).
+
+ self assert: (changeset / 'java' / 'extensions' / 'java' / 'lang' / 'Object.st' ) notNil.
+
+ "Created: / 29-11-2013 / 17:34:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGStXTests methodsFor:'tests - manager API'!
@@ -1711,6 +1785,37 @@
self tearDown
"Created: / 20-11-2012 / 19:32:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+stxlibjavaAvailable
+ "raise an error: this method should be implemented (TODO)"
+
+ (Smalltalk at:#JavaVM) isNil ifTrue:[
+ Smalltalk loadPackage:'stx:libjava'.
+ ].
+ (Smalltalk at:#JavaVM) isNil ifTrue:[
+ ^ false
+ ].
+ (Smalltalk at:#Java) isNil ifTrue:[
+ ^ false
+ ].
+ ^ [
+ (Smalltalk at:#JavaVM) booted ifTrue:[
+ "/ Sorry, flush it...
+ (Smalltalk at:#Java) flushAllJavaResources.
+ ].
+
+ "/ Opps, workaround - have to nil out Java:ExtensionsPathPackages
+ Smalltalk at: #'Java:ExtensionsPathPackages' put: nil.
+
+ "/ Now, initialize ot..."
+ (Smalltalk at:#Java) initialize.
+ (Smalltalk at:#JavaVM) initializeVM.
+ true.
+ ] on:Error do:[:ex | false ]
+
+ "Created: / 29-11-2013 / 16:21:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 29-11-2013 / 17:30:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGStXTests class methodsFor:'documentation'!
--- a/mercurial/mercurial.rc Fri Nov 29 15:49:36 2013 +0000
+++ b/mercurial/mercurial.rc Fri Nov 29 21:00:10 2013 +0000
@@ -25,7 +25,7 @@
VALUE "LegalCopyright", "Copyright Jan Vrany 2012\0"
VALUE "ProductName", "Smalltalk/X Mercurial Integration\0"
VALUE "ProductVersion", "6.2.3.0\0"
- VALUE "ProductDate", "Wed, 09 Oct 2013 11:09:32 GMT\0"
+ VALUE "ProductDate", "Fri, 29 Nov 2013 20:40:37 GMT\0"
END
END
Binary file mercurial/tests/repositories/mocks_hg_p5.hg.zip has changed