Bugfix for creating new subpackage inside existing package (part 1)
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 11 Jun 2013 00:55:03 +0100
changeset 296 f7824c40a07e
parent 295 6f1beea2cad4
child 297 0f36d2c091e9
Bugfix for creating new subpackage inside existing package (part 1)
mercurial/HGPackageModel.st
mercurial/HGPackageModelRegistry.st
mercurial/HGStXTests.st
mercurial/Make.proto
mercurial/Makefile.init
mercurial/bc.mak
mercurial/mercurial.rc
--- a/mercurial/HGPackageModel.st	Mon Jun 10 02:06:48 2013 +0100
+++ b/mercurial/HGPackageModel.st	Tue Jun 11 00:55:03 2013 +0100
@@ -63,9 +63,21 @@
     "Return a logical revision of the package, i.e., a revision
      on which the next commit will be based on"
 
-    ^self definition hgLogicalRevision
+    | model |
+
+    model := self.
+    [ model notNil ] whileTrue:[
+        | rev |
+
+        rev := model definition hgLogicalRevision.
+        rev notNil ifTrue:[ ^rev ].
+        model := model parent.
+    ].
+
+    ^repository workingCopy changesetId
 
     "Created: / 28-11-2012 / 09:41:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 11-06-2013 / 00:23:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 temporaryRepository
@@ -163,7 +175,7 @@
     
     | rev  tmpPath  tmpRepo  tmpWc |
 
-    rev := self definition hgLogicalRevision.
+    rev := self revision.
     (wc notNil and:[ wc path exists ]) ifTrue:[
         ^ self
     ].
@@ -183,11 +195,13 @@
 
     "Update branch to match branch of master working copy"
     tmpWc branch: repository workingCopy branch name.
-
-    self setWorkingCopy:tmpWc
+    self setWorkingCopy:tmpWc.
+    wcroot exists ifFalse:[
+        wcroot recursiveMakeDirectory.
+    ].
 
     "Created: / 14-11-2012 / 00:16:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 05-02-2013 / 09:30:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 11-06-2013 / 00:48:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 ensureTemporaryWorkingCopyAtRevision:rev 
--- a/mercurial/HGPackageModelRegistry.st	Mon Jun 10 02:06:48 2013 +0100
+++ b/mercurial/HGPackageModelRegistry.st	Tue Jun 11 00:55:03 2013 +0100
@@ -40,13 +40,10 @@
     "Returns a HGPackageModel for given package or nil
      if given package is not backed by Mercurial repository."
 
-    | dir components names directories root rootI rootD pkg|
+    | dir components names namei directories root rootI rootD pkg|
 
     packages at: package ifPresent: [ :p | ^ p ].
 
-    dir := Smalltalk getPackageDirectoryForPackage: package.
-    dir isNil ifTrue:[ ^ nil ].
-
     components := OrderedCollection new.
     names := OrderedCollection new.
 
@@ -73,6 +70,21 @@
         names add: package
 
     ].
+
+    "Package might be sub-package which may not exists. Search for some
+     existing packagedir along package hierarchy"
+    namei := names size.
+    [ dir isNil and: [ namei > 0  ] ] whileTrue:[
+        dir := Smalltalk getPackageDirectoryForPackage: (names at: namei).
+        dir notNil ifTrue:[
+            namei + 1 to: names size do:[:i|
+                dir := dir / (components at: i).
+            ].
+        ].
+        namei := namei - 1.
+    ].
+    dir isNil ifTrue:[ ^ nil ].
+
     directories := Array new: components size.
     directories at: components size put: dir.
     directories size - 1 downTo: 1 do:[:i|
@@ -105,6 +117,7 @@
     ^pkg
 
     "Created: / 18-03-2013 / 22:26:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 11-06-2013 / 00:43:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 packageNamed:package
--- a/mercurial/HGStXTests.st	Mon Jun 10 02:06:48 2013 +0100
+++ b/mercurial/HGStXTests.st	Tue Jun 11 00:55:03 2013 +0100
@@ -1105,6 +1105,72 @@
     self shouldnt: [ repo @ 2 / 'MockHGP1Bar.st' ] raise: HGError.
 
     "Created: / 21-05-2013 / 16:47:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_commit_15a
+    "
+    Test creation of deeply nested packages
+        1) load mocks:hg/p2/n2
+        2) create class in mocks:hg/p2/n2_2
+        3) commit
+
+
+    "
+    | repo pmN22 ctN22 |
+
+    repo := self repositoryNamed: 'mocks/hg/p2'.
+    self assert: (Smalltalk loadPackage:'mocks:hg/p2/n2').
+
+    Object subclass:#MocksHgP2N22Foo
+        instanceVariableNames:''
+        classVariableNames:''
+        poolDictionaries:''
+        category:'* Mocks *'.
+
+    (Smalltalk at:#MocksHgP2N22Foo) package: #'mocks:hg/p2/n2/n2_2'.
+
+    pmN22 := HGPackageModel named: #'mocks:hg/p2/n2/n2_2'.
+    ctN22 := pmN22 commitTask.
+    ctN22 message:'test_commit_15a 1'.
+    ctN22 do.
+    "
+    repo workingCopy browse
+    "
+
+    "Created: / 10-06-2013 / 23:28:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_commit_15b
+    "
+    Test creation of deeply nested packages
+        1) load mocks:hg/p2/n1/n1_1/n_1_1_1
+        2) create class in mocks:hg/p2/n1/n1_1/n_1_1_1
+        3) commit
+
+
+    "
+    | repo pmN111 ctN111 |
+
+    repo := self repositoryNamed: 'mocks/hg/p2'.
+    self assert: (Smalltalk loadPackage:'mocks:hg/p2/n1').
+
+    Object subclass:#MocksHgP2N111Foo
+        instanceVariableNames:''
+        classVariableNames:''
+        poolDictionaries:''
+        category:'* Mocks *'.
+
+    (Smalltalk at:#MocksHgP2N111Foo) package: #'mocks:hg/p2/n1/n1_1/n_1_1_1'.
+
+    pmN111 := HGPackageModel named: #'mocks:hg/p2/n1/n1_1/n_1_1_1'.
+    ctN111 := pmN111 commitTask.
+    ctN111 message:'test_commit_15b 1'.
+    ctN111 do.
+    "
+    repo workingCopy browse
+    "
+
+    "Created: / 11-06-2013 / 00:16:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGStXTests methodsFor:'tests - manager API'!
--- a/mercurial/Make.proto	Mon Jun 10 02:06:48 2013 +0100
+++ b/mercurial/Make.proto	Tue Jun 11 00:55:03 2013 +0100
@@ -194,7 +194,7 @@
 $(OUTDIR)HGChangeset.$(O) HGChangeset.$(H): HGChangeset.st $(INCLUDE_TOP)/stx/libscm/mercurial/HGRepositoryObject.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)HGCommand.$(O) HGCommand.$(H): HGCommand.st $(INCLUDE_TOP)/stx/libscm/mercurial/HGDebugFlags.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)HGCommandError.$(O) HGCommandError.$(H): HGCommandError.st $(INCLUDE_TOP)/stx/libscm/mercurial/HGError.$(H) $(INCLUDE_TOP)/stx/libbasic/Error.$(H) $(INCLUDE_TOP)/stx/libbasic/Exception.$(H) $(INCLUDE_TOP)/stx/libbasic/GenericException.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
-$(OUTDIR)HGCommandServer.$(O) HGCommandServer.$(H): HGCommandServer.st $(INCLUDE_TOP)/stx/libscm/mercurial/HGDebugFlags.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/ReadStream.$(H) $(INCLUDE_TOP)/stx/libbasic/PositionableStream.$(H) $(INCLUDE_TOP)/stx/libbasic/PeekableStream.$(H) $(INCLUDE_TOP)/stx/libbasic/Stream.$(H) $(INCLUDE_TOP)/stx/libbasic/WriteStream.$(H) $(STCHDR)
+$(OUTDIR)HGCommandServer.$(O) HGCommandServer.$(H): HGCommandServer.st $(INCLUDE_TOP)/stx/libscm/mercurial/HGDebugFlags.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/WriteStream.$(H) $(INCLUDE_TOP)/stx/libbasic/PositionableStream.$(H) $(INCLUDE_TOP)/stx/libbasic/PeekableStream.$(H) $(INCLUDE_TOP)/stx/libbasic/Stream.$(H) $(INCLUDE_TOP)/stx/libbasic/ReadStream.$(H) $(STCHDR)
 $(OUTDIR)HGCommitError.$(O) HGCommitError.$(H): HGCommitError.st $(INCLUDE_TOP)/stx/libscm/mercurial/HGError.$(H) $(INCLUDE_TOP)/stx/libbasic/Error.$(H) $(INCLUDE_TOP)/stx/libbasic/Exception.$(H) $(INCLUDE_TOP)/stx/libbasic/GenericException.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)HGConfig.$(O) HGConfig.$(H): HGConfig.st $(INCLUDE_TOP)/stx/libscm/mercurial/HGRepositoryObject.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/Dictionary.$(H) $(INCLUDE_TOP)/stx/libbasic/Set.$(H) $(INCLUDE_TOP)/stx/libbasic/Collection.$(H) $(STCHDR)
 $(OUTDIR)HGNoSuchBranchError.$(O) HGNoSuchBranchError.$(H): HGNoSuchBranchError.st $(INCLUDE_TOP)/stx/libscm/mercurial/HGError.$(H) $(INCLUDE_TOP)/stx/libbasic/Error.$(H) $(INCLUDE_TOP)/stx/libbasic/Exception.$(H) $(INCLUDE_TOP)/stx/libbasic/GenericException.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/Makefile.init	Tue Jun 11 00:55:03 2013 +0100
@@ -0,0 +1,27 @@
+#
+# DO NOT EDIT
+#
+# make uses this file (Makefile) only, if there is no
+# file named "makefile" (lower-case m) in the same directory.
+# My only task is to generate the real makefile and call make again.
+# Thereafter, I am no longer used and needed.
+#
+# MACOSX caveat:
+#   as filenames are not case sensitive (in a default setup),
+#   we cannot use the above trick. Therefore, this file is now named
+#   "Makefile.init", and you have to execute "make -f Makefile.init" to
+#   get the initial makefile.  This is now also done by the toplevel CONFIG
+#   script.
+
+.PHONY: run
+
+run: makefile
+	$(MAKE) -f makefile
+
+#only needed for the definition of $(TOP)
+include Make.proto
+
+makefile: mf
+
+mf:
+	$(TOP)/rules/stmkmf
--- a/mercurial/bc.mak	Mon Jun 10 02:06:48 2013 +0100
+++ b/mercurial/bc.mak	Tue Jun 11 00:55:03 2013 +0100
@@ -120,7 +120,7 @@
 $(OUTDIR)HGChangeset.$(O) HGChangeset.$(H): HGChangeset.st $(INCLUDE_TOP)\stx\libscm\mercurial\HGRepositoryObject.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)HGCommand.$(O) HGCommand.$(H): HGCommand.st $(INCLUDE_TOP)\stx\libscm\mercurial\HGDebugFlags.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)HGCommandError.$(O) HGCommandError.$(H): HGCommandError.st $(INCLUDE_TOP)\stx\libscm\mercurial\HGError.$(H) $(INCLUDE_TOP)\stx\libbasic\Error.$(H) $(INCLUDE_TOP)\stx\libbasic\Exception.$(H) $(INCLUDE_TOP)\stx\libbasic\GenericException.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
-$(OUTDIR)HGCommandServer.$(O) HGCommandServer.$(H): HGCommandServer.st $(INCLUDE_TOP)\stx\libscm\mercurial\HGDebugFlags.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\ReadStream.$(H) $(INCLUDE_TOP)\stx\libbasic\PositionableStream.$(H) $(INCLUDE_TOP)\stx\libbasic\PeekableStream.$(H) $(INCLUDE_TOP)\stx\libbasic\Stream.$(H) $(INCLUDE_TOP)\stx\libbasic\WriteStream.$(H) $(STCHDR)
+$(OUTDIR)HGCommandServer.$(O) HGCommandServer.$(H): HGCommandServer.st $(INCLUDE_TOP)\stx\libscm\mercurial\HGDebugFlags.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\WriteStream.$(H) $(INCLUDE_TOP)\stx\libbasic\PositionableStream.$(H) $(INCLUDE_TOP)\stx\libbasic\PeekableStream.$(H) $(INCLUDE_TOP)\stx\libbasic\Stream.$(H) $(INCLUDE_TOP)\stx\libbasic\ReadStream.$(H) $(STCHDR)
 $(OUTDIR)HGCommitError.$(O) HGCommitError.$(H): HGCommitError.st $(INCLUDE_TOP)\stx\libscm\mercurial\HGError.$(H) $(INCLUDE_TOP)\stx\libbasic\Error.$(H) $(INCLUDE_TOP)\stx\libbasic\Exception.$(H) $(INCLUDE_TOP)\stx\libbasic\GenericException.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)HGConfig.$(O) HGConfig.$(H): HGConfig.st $(INCLUDE_TOP)\stx\libscm\mercurial\HGRepositoryObject.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\Dictionary.$(H) $(INCLUDE_TOP)\stx\libbasic\Set.$(H) $(INCLUDE_TOP)\stx\libbasic\Collection.$(H) $(STCHDR)
 $(OUTDIR)HGNoSuchBranchError.$(O) HGNoSuchBranchError.$(H): HGNoSuchBranchError.st $(INCLUDE_TOP)\stx\libscm\mercurial\HGError.$(H) $(INCLUDE_TOP)\stx\libbasic\Error.$(H) $(INCLUDE_TOP)\stx\libbasic\Exception.$(H) $(INCLUDE_TOP)\stx\libbasic\GenericException.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
--- a/mercurial/mercurial.rc	Mon Jun 10 02:06:48 2013 +0100
+++ b/mercurial/mercurial.rc	Tue Jun 11 00:55:03 2013 +0100
@@ -3,7 +3,7 @@
 // automagically generated from the projectDefinition: stx_libscm_mercurial.
 //
 VS_VERSION_INFO VERSIONINFO
-  FILEVERSION     6,2,32767,32767
+  FILEVERSION     6,2,6124,6124
   PRODUCTVERSION  6,2,3,0
 #if (__BORLANDC__)
   FILEFLAGSMASK   VS_FF_DEBUG | VS_FF_PRERELEASE
@@ -20,12 +20,12 @@
     BEGIN
       VALUE "CompanyName", "Jan Vrany\0"
       VALUE "FileDescription", "Mercurial integration for Smalltalk/X (LIB)\0"
-      VALUE "FileVersion", "6.2.32767.32767\0"
+      VALUE "FileVersion", "6.2.6124.6124\0"
       VALUE "InternalName", "stx:libscm/mercurial\0"
       VALUE "LegalCopyright", "Copyright Jan Vrany 2012\0"
       VALUE "ProductName", "Smalltalk/X Mercurial Integration\0"
       VALUE "ProductVersion", "6.2.3.0\0"
-      VALUE "ProductDate", "Tue, 21 May 2013 15:49:46 GMT\0"
+      VALUE "ProductDate", "Mon, 10 Jun 2013 23:53:23 GMT\0"
     END
 
   END