SVN__UpdateTask.st
changeset 77 b27f361cc834
child 207 1f90147b8b31
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SVN__UpdateTask.st	Wed Sep 23 18:50:18 2009 +0200
@@ -0,0 +1,165 @@
+"{ Package: 'cvut:stx/goodies/libsvn' }"
+
+"{ NameSpace: SVN }"
+
+FileoutLikeTask subclass:#UpdateTask
+	instanceVariableNames:'revision notifications updates conflicts resolution'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'SVN-Tasks'
+!
+
+!UpdateTask class methodsFor:'documentation'!
+
+version_SVN
+    ^'$Id$'
+! !
+
+!UpdateTask methodsFor:'accessing'!
+
+revision
+    ^ revision
+
+    "Modified: / 09-04-2009 / 09:39:42 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+revision:aRevision
+    revision := aRevision.
+    loadChangeSet := mergeDiffSet := updateChangeSet := nil.
+
+    "Modified: / 23-03-2009 / 18:40:00 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
+!UpdateTask methodsFor:'executing'!
+
+do
+    "
+     Perform whole task"
+    
+    self assert: revision notNil message: 'No revision specified'.
+    self doUpdateWorkingCopy doApplyMergedChangeSet
+
+    "Modified: / 09-04-2009 / 09:40:28 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+doApplyResolutions
+    self do: 
+        [resolution isNilOrEmptyCollection ifFalse:
+            [(Class updateChangeFileQuerySignal , Class updateChangeListQuerySignal)
+                answer: false
+                do: 
+                    [resolution withIndexDo: 
+                        [:change :index | 
+                        change apply.
+                        SVN::ProgressNotification 
+                            notify: 'Applying changes'
+                            progress: (100 / resolution size) * index ] ] ].
+        self doCompileSvnRevisionNrMethod: true]
+
+    "Created: / 23-03-2009 / 18:36:32 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 17-08-2009 / 19:39:17 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+doUpdateWorkingCopy
+    self do: 
+            [ self workingCopy ensureIsValid.
+            self
+                doRevert;
+                doFileOutAll;
+                doUpdate;
+                doLoadChanges ]
+
+    "Created: / 23-03-2009 / 18:35:06 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 17-08-2009 / 19:01:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
+!UpdateTask methodsFor:'executing - private'!
+
+doLoadChanges
+    updates := ChangeSet new.
+    conflicts := ChangeSet::DiffSet new.
+    notifications do: [:each | self doLoadChangesFor: each ].
+
+    "Modified: / 18-08-2009 / 08:59:11 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+doLoadChangesFor: aWCActionNotify
+
+    "We should process only notifications for source 
+     and/or conflicted entries"
+
+    (aWCActionNotify action isConflict or:
+        [aWCActionNotify entry isSourceFileEntry])
+            ifTrue:[aWCActionNotify processUsing: self]
+
+    "Created: / 18-08-2009 / 08:59:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 27-08-2009 / 08:57:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+doRevert
+    SVN::ActivityNotification notify: 'Reverting local changes'.
+    (RevertCommand new)
+        workingCopy: self workingCopy path;
+        paths: (ProgrammingLanguage 
+                    allCollect: [:lang | '*.' , lang sourceFileSuffix ]);
+        execute.
+!
+
+doUpdate
+    SVN::ActivityNotification 
+        notify: 'Updating working copy to revision ' , self revision printString.
+    notifications := (UpdateCommand new)
+        workingCopy: self workingCopy;
+        revision: self revision;
+        execute
+
+    "Modified: / 19-08-2009 / 12:22:49 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
+!UpdateTask methodsFor:'private'!
+
+filterChangeSet: aChangeSet 
+    "
+        Removes changes for methods that are not interesting
+        (such as version methods & autogenerated package description
+        methods)"
+    
+    | changesToRemove |
+
+    changesToRemove := aChangeSet 
+                select: [:change | change isForGeneratedSubject ].
+    aChangeSet removeAll: changesToRemove.
+    ^ aChangeSet
+
+    "Created: / 08-04-2009 / 09:53:49 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
+!UpdateTask methodsFor:'processing - private'!
+
+processAddedEntry: entry
+
+    entry sourceLanguage isSmalltalk 
+        ifTrue:
+            [updates addAll:
+                (ChangeSet fromStream: entry readStream) ]
+        ifFalse:
+            [self error:'Non smalltalk source not yet supported']
+
+    "Created: / 27-08-2009 / 08:54:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 27-08-2009 / 10:37:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+processDeletedEntry: entry
+
+    entry sourceLanguage isSmalltalk ifTrue:
+        [entry path = 'extensions.st' ifTrue:[self halt"not yet finished"].
+        self halt.]
+
+    "Created: / 27-08-2009 / 09:56:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!UpdateTask class methodsFor:'documentation'!
+
+version
+    ^ '$Header$'
+! !