--- a/mercurial/HGCommand.st Mon Feb 04 12:59:18 2013 +0100
+++ b/mercurial/HGCommand.st Mon Feb 04 15:55:37 2013 +0100
@@ -12,7 +12,7 @@
"{ Package: 'stx:libscm/mercurial' }"
Object subclass:#HGCommand
- instanceVariableNames:'workingDirectory result error workers blocker'
+ instanceVariableNames:'workingDirectory result error workers blocker notifications'
classVariableNames:'HGExecutable HGVersion Debugging Tracing'
poolDictionaries:''
category:'SCM-Mercurial-Internal'
@@ -474,12 +474,44 @@
"Modified: / 01-10-2012 / 14:38:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!HGCommand methodsFor:'error reporting'!
+
+error: aString
+ error := HGCommandError newException errorString: aString.
+
+ "Created: / 04-02-2013 / 13:58:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+notify
+ | notification |
+
+ [ (notification := notifications nextOrNil) notNil ] whileTrue:[
+ Tracing ifTrue:[
+ Logger log: 'notifying:' , notification description severity: #trace facility: 'HG'.
+ ].
+ notification raiseRequest.
+ ]
+
+ "Created: / 04-02-2013 / 14:39:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+notify: aString
+
+ Tracing ifTrue:[
+ Logger log: 'received notification: ' , aString severity: #trace facility: 'HG'.
+ ].
+ notifications nextPut: (HGNotification newException errorString: aString).
+
+ "Created: / 04-02-2013 / 14:03:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!HGCommand methodsFor:'executing'!
execute
- | stdoutPipe stdout stderrPipe stderr pid environment status args |
+ | stdoutPipe stdout stderrPipe stderr pid environment status args spin |
workers := OrderedCollection new.
+ notifications := SharedQueue new.
stdoutPipe := NonPositionableExternalStream makePipe.
stdout := stdoutPipe first.
@@ -506,7 +538,7 @@
blocker := (Semaphore new:-2) name: 'Waiting for hg command to finish'.
Processor monitor:[
Tracing ifTrue:[
- Logger log: 'executing: ' , (args asStringWith:' ') severity: #trace facility: 'HG'.
+ Logger log: 'cmd: executing: ' , (args asStringWith:' ') severity: #trace facility: 'HG'.
].
pid := OperatingSystem exec:(self executable) withArguments:args
environment:environment
@@ -515,6 +547,9 @@
newPgrp:false
inDirectory:self workingDirectory
] action:[:stat |
+ Tracing ifTrue:[
+ Logger log: 'cmd: command finished' severity: #trace facility: 'HG'.
+ ].
status := stat.
blocker signal.
].
@@ -533,13 +568,19 @@
].
self spawn: [ result := self parseOutput: stdout ].
self spawn: [ error := self parseError: stderr ].
+
+ spin := SemaphoreSet with: blocker with: notifications readSemaphore.
+
[
- blocker wait.
+ [ spin wait ~~ blocker ] whileTrue:[ self notify ]
] ensure:[
stderr close.
stdout close.
].
+ Tracing ifTrue:[
+ Logger log: 'returning' severity: #trace facility: 'HG'.
+ ].
^self status: status result: result error: error
"
@@ -550,7 +591,7 @@
"Modified: / 17-12-2011 / 19:22:00 / dundee"
"Modified (format): / 27-12-2011 / 15:53:54 / dundee"
"Modified: / 14-11-2012 / 13:41:57 / jv"
- "Modified: / 04-02-2013 / 12:27:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 04-02-2013 / 14:40:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGCommand methodsFor:'private'!
@@ -633,9 +674,10 @@
parserOn: aStream
"Returns an HGCommandParser initialized on given stream."
- ^HGCommandParser on: aStream
+ ^HGCommandParser for: self on: aStream
"Created: / 04-02-2013 / 12:17:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 04-02-2013 / 14:14:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
spawn:aBlock
@@ -645,10 +687,17 @@
worker := aBlock newProcess.
workers add: worker.
- worker addExitAction:[ blocker signal. workers remove: worker ].
+ worker addExitAction:[
+ Tracing ifTrue:[
+ Logger log: 'command parser finished' severity: #trace facility: 'HG'.
+ ].
+ blocker signal.
+ workers remove: worker
+ ].
worker resume.
"Created: / 04-02-2013 / 11:55:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 04-02-2013 / 14:28:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
status: status result: res
@@ -1242,6 +1291,16 @@
"Modified: / 15-11-2012 / 00:38:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!HGCommand::pull methodsFor:'accessing'!
+
+url
+ ^ url
+!
+
+url:aString
+ url := aString.
+! !
+
!HGCommand::pull methodsFor:'private'!
argumentsCommandOn:stream
@@ -1258,9 +1317,9 @@
parseOutput:stream
"superclass HGCommand says that I am responsible to implement this method"
- ^ nil
+ ^ (self parserOn:stream) parseCommandPull
- "Modified: / 15-11-2012 / 09:53:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 04-02-2013 / 15:35:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGCommand::push methodsFor:'accessing'!