SVN__WorkingCopyBrowser.st
changeset 775 f321c3505bf7
parent 403 7358e44af42e
child 817 c258e10fedc3
--- a/SVN__WorkingCopyBrowser.st	Mon Aug 08 15:43:30 2011 +0200
+++ b/SVN__WorkingCopyBrowser.st	Mon Aug 08 15:43:44 2011 +0200
@@ -1,3 +1,28 @@
+"
+ Copyright (c) 2007-2010 Jan Vrany
+ Copyright (c) 2009-2010 eXept Software AG
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the 'Software'), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+"
 "{ Package: 'stx:libsvn' }"
 
 "{ NameSpace: SVN }"
@@ -9,6 +34,43 @@
 	category:'SVN-UI-Browsers'
 !
 
+!WorkingCopyBrowser class methodsFor:'documentation'!
+
+copyright
+"
+ Copyright (c) 2007-2010 Jan Vrany
+ Copyright (c) 2009-2010 eXept Software AG
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the 'Software'), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+"
+! !
+
+!WorkingCopyBrowser class methodsFor:'instance creation'!
+
+on: aWorkingCopy
+
+    ^self new workingCopy: aWorkingCopy
+! !
 
 !WorkingCopyBrowser class methodsFor:'interface specs'!
 
@@ -20,9 +82,9 @@
      the UIPainter may not be able to read the specification."
 
     "
-     UIPainter new openOnClass:SVN::WCStatusApp andSelector:#windowSpec
-     SVN::WCStatusApp new openInterface:#windowSpec
-     SVN::WCStatusApp open
+     UIPainter new openOnClass:SVN::WorkingCopyBrowser andSelector:#windowSpec
+     SVN::WorkingCopyBrowser new openInterface:#windowSpec
+     SVN::WorkingCopyBrowser open
     "
 
     <resource: #canvas>
@@ -44,7 +106,7 @@
               name: 'WCEntryTable'
               layout: (LayoutFrame 0 0 0 0 0 1 -30 1)
               model: selectionHolder
-              menu: workingCopyEntryMenu
+              menu: entryMenu
               hasHorizontalScrollBar: true
               hasVerticalScrollBar: true
               dataList: workingCopyEntriesAspect
@@ -62,13 +124,11 @@
          
         )
       )
-
-    "Modified: / 22-10-2008 / 11:30:58 / Jan Vrany <vranyj1@fel.cvut.cz>"
 ! !
 
 !WorkingCopyBrowser class methodsFor:'menu specs'!
 
-workingCopyEntryMenu
+entryMenu
     "This resource specification was automatically generated
      by the MenuEditor of ST/X."
 
@@ -76,8 +136,8 @@
      the MenuEditor may not be able to read the specification."
 
     "
-     MenuEditor new openOnClass:SVN::WCStatusApp andSelector:#workingCopyEntryMenu
-     (Menu new fromLiteralArrayEncoding:(SVN::WCStatusApp workingCopyEntryMenu)) startUp
+     MenuEditor new openOnClass:SVN::WorkingCopyBrowser andSelector:#entryMenu
+     (Menu new fromLiteralArrayEncoding:(SVN::WorkingCopyBrowser entryMenu)) startUp
     "
 
     <resource: #menu>
@@ -86,23 +146,30 @@
      #(Menu
         (
          (MenuItem
-            label: 'Show changes (against HEAD)'
-            itemValue: menuActionShowChangesAgainstHEAD
+            label: 'Show changes'
+            itemValue: entryMenuShowChanges
             translateLabel: true
-            labelImage: (ResourceRetriever #'SVN::IconLibrary' compare 'Show changes (against HEAD)')
+            labelImage: (ResourceRetriever #'SVN::IconLibrary' compare 'Show changes')
           )
          (MenuItem
-            label: 'Show changes'
-            itemValue: menuActionShowChanges
+            label: '-'
+          )
+         (MenuItem
+            label: 'Revert'
+            itemValue: entryMenuRevert
             translateLabel: true
-            labelImage: (ResourceRetriever #'SVN::IconLibrary' compare 'Show changes')
+            labelImage: (ResourceRetriever #'SVN::IconLibrary' revert 'Revert')
           )
          )
         nil
         nil
       )
+! !
 
-    "Modified: / 19-04-2008 / 13:13:43 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!WorkingCopyBrowser class methodsFor:'others'!
+
+version_CVS
+    ^ '$Header$'
 ! !
 
 !WorkingCopyBrowser class methodsFor:'plugIn spec'!
@@ -122,7 +189,6 @@
         #model
       ).
 
-    "Modified: / 21-10-2008 / 18:53:15 / Jan Vrany <vranyj1@fel.cvut.cz>"
 ! !
 
 !WorkingCopyBrowser class methodsFor:'tableColumns specs'!
@@ -256,40 +322,54 @@
 
 !WorkingCopyBrowser methodsFor:'menu actions'!
 
-menuActionShowChanges
+entryMenuRevert
 
-    | entry log revision |
+    | entry |
     entry := self selection.
-    log := self model branch log: entry path.
-    revision := SVN::RevisionSelectionDialog openOn: log.
-    revision ifNotNil:
-        [self menuActionShowChangesAgainst: revision]
+    entry ifNotNil:[entry revert]
+
+    "Modified: / 09-10-2008 / 20:30:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Created: / 05-12-2009 / 20:10:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
 
-    "Modified: / 22-10-2008 / 11:31:16 / Jan Vrany <vranyj1@fel.cvut.cz>"
+entryMenuShowChanges
+    self entryMenuShowChangesAgainst:SVN::Revision head
+
+    "Modified: / 09-10-2008 / 20:30:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Created: / 05-12-2009 / 20:10:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-menuActionShowChangesAgainst: rev
-
-    | wc entry wcChangeSet repoChangeSet |
+entryMenuShowChangesAgainst:rev 
+    |wc entry wcChangeSet repoChangeSet diffset lang |
     wc := self model.
     entry := self selection.
-    wcChangeSet := wc changeSetForContainer: entry path.
-    repoChangeSet := wc branch changeSetForContainer: entry path revision: rev.
-    Tools::SmalltalkDiffTool
-        openOnDiffSet: (wcChangeSet diffSetsAgainst: repoChangeSet)
-        labelA: 'Working copy'
-        labelB: 'Revision ', rev printString
-        title: 'Changes for ', entry path
+    lang := entry programmingLanguage.
+    (lang notNil and: [lang isSmalltalk]) ifTrue:[
+        wcChangeSet := wc changeSetForContainer:entry path.
+        wcChangeSet name: wcChangeSet name, ' (working copy)'.
+        repoChangeSet := wc branch changeSetForContainer:entry path revision:rev.
+        diffset := ChangeSetDiff versionA:wcChangeSet versionB:repoChangeSet.
+        (Tools::ChangeSetDiffTool new)
+            beSingleColumn;
+            diffset:diffset;
+            title:('%1: Diffbetween working copy and rev. %2 ' bindWith: entry path with: rev printString);
+            open
+    ] ifFalse:[
+        | text1 text2 |
+        text1 := (wc containerReadStreamFor: entry path) contents asString.
+        text2 := wc branch cat: entry path.
+        (Tools::TextDiffTool new)
+            versionALabel: 'Working copy';
+            versionBLabel: ('r %1' bindWith: rev printString);
+            versionA: text1 versionB: text2;
+            title:('%1: Diffbetween working copy and rev. %2 ' bindWith: entry path with: rev printString);
+            open
+    ]
 
     "Created: / 09-10-2008 / 20:14:24 / Jan Vrany <vranyj1@fel.cvut.cz>"
     "Modified: / 09-08-2009 / 14:14:21 / Jan Vrany <vranyj1@fel.cvut.cz>"
-!
-
-menuActionShowChangesAgainstHEAD
-
-    self menuActionShowChangesAgainst: SVN::Revision head
-
-    "Modified: / 09-10-2008 / 20:30:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 07-07-2011 / 21:49:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-07-2011 / 23:09:09 / jv"
 ! !
 
 !WorkingCopyBrowser methodsFor:'private'!
@@ -308,14 +388,6 @@
 
 !WorkingCopyBrowser class methodsFor:'documentation'!
 
-version
-    ^ '$Header$'
-!
-
-version_CVS
-    ^ '$Header$'
-!
-
 version_SVN
-    ^'§Id: SVN__WorkingCopyBrowser.st 110 2009-08-19 13:21:10Z vranyj1 §'
+    ^ '§Id: SVN__WorkingCopyBrowser.st 354 2011-07-07 22:28:54Z vranyj1 §'
 ! !