Bugfix: keep branch of mater working copy even if there are no changesets yet.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 14 Jan 2013 14:39:05 +0000
changeset 176 78124cee58da
parent 175 89e868803035
child 177 1b0ddad9770e
Bugfix: keep branch of mater working copy even if there are no changesets yet.
mercurial/HGPackageModel.st
mercurial/HGRepository.st
mercurial/HGStXTests.st
mercurial/HGWorkingCopy.st
mercurial/mercurial.rc
--- a/mercurial/HGPackageModel.st	Mon Jan 14 14:11:31 2013 +0000
+++ b/mercurial/HGPackageModel.st	Mon Jan 14 14:39:05 2013 +0000
@@ -137,14 +137,19 @@
         tmpRepo := repository cloneTo:tmpPath update:false.
     ].
     tmpWc := tmpRepo workingCopy.
+
     "If it is fresh repository, it has no changeset yet..."
     (rev ~~ HGChangesetId null) ifTrue:[
         tmpWc update:rev.
     ].
+
+    "Update branch to match branch of master working copy"
+    tmpWc branch: repository workingCopy branch name.
+
     self setWorkingCopy:tmpWc
 
     "Created: / 14-11-2012 / 00:16:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 01-12-2012 / 17:53:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-01-2013 / 14:27:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 ensureTemporaryWorkingCopyAtRevision:rev 
@@ -163,10 +168,13 @@
     self ensureTemporaryWorkingCopy.
     (r revno ~~ -1) ifTrue:[
         wc update:r revno printString.
+        "Update branch to match branch of master working copy"
+        wc branch: repository workingCopy branch name.
+
     ].
 
     "Created: / 28-11-2012 / 09:38:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 01-12-2012 / 15:18:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 14-01-2013 / 14:31:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGPackageModel class methodsFor:'documentation'!
--- a/mercurial/HGRepository.st	Mon Jan 14 14:11:31 2013 +0000
+++ b/mercurial/HGRepository.st	Mon Jan 14 14:39:05 2013 +0000
@@ -133,15 +133,15 @@
             execute.
     names := branches collect:[:b|b name].
     current := current reject:[:b|names includes: b name].
-    current isEmpty ifTrue:[
-        current add: (HGBranch new setName: 'default').
-    ].
     current do:[:b|b setRepository: self].
     branches addAll: current.
+    branches isEmpty ifTrue:[
+        branches add: (HGBranch new setName: 'default'; setRepository: self).
+    ].
     ^branches.
 
     "Created: / 27-11-2012 / 19:57:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 14-01-2013 / 14:09:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-01-2013 / 14:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 config
--- a/mercurial/HGStXTests.st	Mon Jan 14 14:11:31 2013 +0000
+++ b/mercurial/HGStXTests.st	Mon Jan 14 14:39:05 2013 +0000
@@ -582,6 +582,7 @@
     (repo workingCopy / 'abbrev.stc' ) appendingFileDo:[:s|s cr;cr;cr].
     repo workingCopy branch: 'test_commit_06c'.
     repo workingCopy commit: 'test_commit_06c into branch test_commit_06c'.
+    repo workingCopy update: 0.
 
     "=== modify & commit ================================== "    
     (MockHGP1Foo compile:'zork ^ 2' classified:'test') package: MockHGP1Foo package.
@@ -599,6 +600,7 @@
     "
 
     "Created: / 10-12-2012 / 03:28:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-01-2013 / 14:37:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 test_commit_07
@@ -628,6 +630,38 @@
     self assert: (Smalltalk at:#mocks_hg_p4_empty) hgLogicalRevision revno = 0.
 
     "Created: / 14-01-2013 / 13:20:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_commit_08
+    "
+    Test commit into fresh branch created in repo (but with no
+    changeset yet)
+    "
+    | repo pm ct |
+
+    repo := self repositoryNamed: 'mocks/hg/p1'.
+    repo workingCopy branch: 'branch_test_commit_08'.
+    self assert: (Smalltalk loadPackage: 'mocks:hg/p1').
+
+    "=== modifyes & commits =============================== "    
+    (MockHGP1Foo compile:'zork ^ 2' classified:'test') package: MockHGP1Foo package.
+
+    pm := HGPackageModel named: 'mocks:hg/p1'.
+    ct := pm commitTask.
+    ct message:'test_commit_08 1'.
+    ct do.
+
+    self assert: (repo branches size == 2).
+    self assert: (repo @ 2) branches size == 1.
+    self assert: (repo @ 2) branches anElement name = 'branch_test_commit_08'.
+
+
+    "
+    repo workingCopy browse
+    pm temporaryWorkingCopy browse.
+    "
+
+    "Created: / 14-01-2013 / 14:14:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGStXTests methodsFor:'tests - manager API'!
--- a/mercurial/HGWorkingCopy.st	Mon Jan 14 14:11:31 2013 +0000
+++ b/mercurial/HGWorkingCopy.st	Mon Jan 14 14:39:05 2013 +0000
@@ -20,9 +20,10 @@
         "File DOES contain trailing newline"    
         name := (root asFilename / '.hg' / 'branch') contents first.
     ].
-    ^repository branchWithName: name.
+    ^repository branchWithName: name createIfAbsent: true.
 
     "Created: / 27-11-2012 / 13:51:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-01-2013 / 14:23:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 branch: aStringOrHGBranch
--- a/mercurial/mercurial.rc	Mon Jan 14 14:11:31 2013 +0000
+++ b/mercurial/mercurial.rc	Mon Jan 14 14:39:05 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", "Mon, 14 Jan 2013 13:55:19 GMT\0"
+      VALUE "ProductDate", "Mon, 14 Jan 2013 14:37:37 GMT\0"
     END
 
   END