mercurial/HGCommitTask.st
changeset 152 9068fe7a5795
parent 151 527a1e85aef8
child 153 442c60f78aec
--- a/mercurial/HGCommitTask.st	Mon Dec 10 02:49:43 2012 +0000
+++ b/mercurial/HGCommitTask.st	Mon Dec 10 03:43:12 2012 +0000
@@ -1,7 +1,7 @@
 "{ Package: 'stx:libscm/mercurial' }"
 
 SCMAbstractCommitTask subclass:#HGCommitTask
-	instanceVariableNames:'author remote'
+	instanceVariableNames:'author remote branch'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'SCM-Mercurial-StX-Tasks'
@@ -29,6 +29,14 @@
     author := aString.
 !
 
+branch
+    ^ branch
+!
+
+branch:aString
+    branch := aString.
+!
+
 remote
     ^ remote
 !
@@ -46,16 +54,28 @@
         | wc |
 
         wc := self package temporaryWorkingCopy.
+        branch notNil ifTrue:[
+            (self package repository branches contains:[:b|b name = branch]) ifTrue:[
+                HGCommitError raiseErrorString: 'Commiting to an existing branch is not allowed'.
+                ^self.
+            ].
+            wc branch: branch.
+        ].
         wc commit: msg files: containers author: self author.
         wc repository push: nil force: true.
         remote notNil ifTrue:[
             self package repository push: remote force: false.
-        ]
+        ].
+        "/Also, mark original (package) working copy as given branch
+        "/so subsequent 'hg update' will update from that branch
+        branch notNil ifTrue:[
+            wc repository workingCopy branch: branch.
+        ].
     ].
 
     "Created: / 15-11-2012 / 16:52:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 07-12-2012 / 16:13:16 / jv"
-    "Modified: / 10-12-2012 / 01:44:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 10-12-2012 / 03:32:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 doPrepareWorkingCopy2