Implemented commit menu item in file browser.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 12 Jan 2013 14:10:22 +0000
changeset 173 c72794df7ae3
parent 172 ca0b1a930b87
child 174 0d293012a897
Implemented commit menu item in file browser.
mercurial/HGCommitDialog.st
mercurial/extensions.st
mercurial/mercurial.rc
mercurial/stx_libscm_mercurial.st
--- a/mercurial/HGCommitDialog.st	Sat Jan 12 14:04:19 2013 +0000
+++ b/mercurial/HGCommitDialog.st	Sat Jan 12 14:10:22 2013 +0000
@@ -480,12 +480,14 @@
     "*** (and replace this comment by something more useful ;-)"
 
     remoteHolder isNil ifTrue:[
-        remoteHolder := self task package repository remoteDefault asValue
+        | remote |
 
+        remote := self task isPackageCommit ifTrue:[self task package repository remoteDefault] ifFalse:[nil].
+        remoteHolder := remote asValue.
     ].
     ^ remoteHolder.
 
-    "Modified: / 10-12-2012 / 01:28:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-01-2013 / 12:05:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 remoteListHolder
@@ -499,14 +501,14 @@
     "*** (and replace this comment by something more useful ;-)"
 
     remoteListHolder isNil ifTrue:[
-        remoteListHolder := self task package repository remotes asValue
-"/ if your app needs to be notified of changes, uncomment one of the lines below:
-"/       remoteListHolder addDependent:self.
-"/       remoteListHolder onChangeSend:#remoteListHolderChanged to:self.
+        | remoteList |
+
+        remoteList := self task isPackageCommit ifTrue:[self task package repository remotes] ifFalse:[nil].
+        remoteListHolder := remoteList asValue
     ].
     ^ remoteListHolder.
 
-    "Modified: / 10-12-2012 / 01:28:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-01-2013 / 12:06:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 remotePushHolder
@@ -537,7 +539,7 @@
     showOnlyModified := fileListShowOnlyModifiedHolder value.
     "HACK..."
 
-    wcroot := self model package temporaryWorkingCopyRoot.
+    wcroot := self task temporaryWorkingCopyRoot.
     wcrootPathNameRelative := wcroot pathNameRelative.
     wcrootPathNameRelativeLen := wcrootPathNameRelative size.
 
@@ -563,7 +565,7 @@
     self fileListHolder value: entries
 
     "Created: / 08-02-2012 / 18:05:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 01-12-2012 / 00:48:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-01-2013 / 13:58:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGCommitDialog methodsFor:'private'!
--- a/mercurial/extensions.st	Sat Jan 12 14:04:19 2013 +0000
+++ b/mercurial/extensions.st	Sat Jan 12 14:10:22 2013 +0000
@@ -22,6 +22,89 @@
     "Created: / 14-12-2012 / 18:26:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!AbstractFileBrowser methodsFor:'menu actions-scm-hg'!
+
+hgCommit
+    | wc task |
+
+    wc := self currentHgRepository workingCopy.
+    task := HGCommitTask new temporaryWorkingCopy: wc.
+    HGCommitDialog new
+        task: task;
+        open
+
+    "Created: / 11-01-2013 / 19:27:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-01-2013 / 13:57:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!AbstractFileBrowser methodsFor:'menu actions-scm-hg'!
+
+hgExecuteCommand: command
+    "Executes svn command on currently selected objects"
+
+    self hgExecuteCommand: command objects: self currentSelectedObjects.
+
+    "Created: / 12-01-2013 / 12:08:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!AbstractFileBrowser methodsFor:'menu actions-scm-hg'!
+
+hgExecuteCommand: command objects: givenObjects
+    "Executes svn command on given objects (files/dirs)"
+
+    | objects workdir objectsAsString executionBlock |
+
+    objects := givenObjects.
+
+    (self isKindOf: FileBrowserV2) ifTrue:[
+        workdir := self currentDirectoryDisplayed.
+        workdir isDirectory ifFalse:[
+            workdir := workdir directory
+        ].
+    ] ifFalse:[
+        (objects size == 1 and:[objects anElement isDirectory]) ifTrue:[
+            workdir := objects anElement
+        ] ifFalse:[
+            workdir := Filename currentDirectory.
+        ]
+    ].
+
+    objectsAsString := String streamContents:[:s|
+        objects size == 1 ifTrue:[
+            workdir asString = objects anElement asString ifTrue:[
+                s nextPut:$.
+            ] ifFalse:[
+                s nextPutAll: objects anElement asString.
+            ]
+        ] ifFalse:[
+            objects do:[:each|s nextPut:$"; nextPutAll:each asString; nextPut:$"]
+                separatedBy:[s space]
+        ]
+    ].
+
+    executionBlock := [:stream |
+        | cmd |
+
+        cmd := '%1 --noninteractive %2 %3' 
+                bindWith: HGCommand hgCommand
+                    with: command
+                    with: objectsAsString.
+        stream nextPutAll: cmd; cr; cr.
+        (self getExecutionBlockForCommand:cmd inDirectory: workdir) value:stream.
+    ].
+    self makeExecutionResultProcessFor:executionBlock withName:'Mercurial> hg ', command.
+
+    "Created: / 12-01-2013 / 12:09:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!AbstractFileBrowser methodsFor:'menu actions-scm-hg'!
+
+hgStatus
+    self hgExecuteCommand: 'status'
+
+    "Modified: / 12-01-2013 / 12:09:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !AbstractFileBrowser class methodsFor:'menu specs-scm'!
 
 hgMenu
@@ -52,6 +135,13 @@
             label: '-'
           )
          (MenuItem
+            label: 'Status'
+            itemValue: hgStatus
+          )
+         (MenuItem
+            label: '-'
+          )
+         (MenuItem
             enabled: hasHGWorkingCopySelected
             label: 'Merge'
             submenuChannel: hgMenuMerge
@@ -259,6 +349,21 @@
 
 !Tools::NewSystemBrowser methodsFor:'menu actions-hg'!
 
+commonMenuHGBrowseTemporaryWorkingCopy
+    self selectedProjectsForHG value do:[:package|
+        | pkg  |
+
+        pkg := HGPackageModel named: package.
+        pkg notNil ifTrue:[
+            pkg temporaryWorkingCopy browse 
+        ].
+    ].
+
+    "Created: / 11-01-2013 / 18:47:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Tools::NewSystemBrowser methodsFor:'menu actions-hg'!
+
 commonMenuHGBrowseWorkingCopy
     self selectedProjectsForHG value do:[:package|
         | pkg  |
--- a/mercurial/mercurial.rc	Sat Jan 12 14:04:19 2013 +0000
+++ b/mercurial/mercurial.rc	Sat Jan 12 14:10:22 2013 +0000
@@ -3,7 +3,7 @@
 // automagically generated from the projectDefinition: stx_libscm_mercurial.
 //
 VS_VERSION_INFO VERSIONINFO
-  FILEVERSION     6,2,709,709
+  FILEVERSION     6,2,6359,6359
   PRODUCTVERSION  6,2,3,0
 #if (__BORLANDC__)
   FILEFLAGSMASK   VS_FF_DEBUG | VS_FF_PRERELEASE
@@ -20,12 +20,12 @@
     BEGIN
       VALUE "CompanyName", "Jan Vrany\0"
       VALUE "FileDescription", "Mercurial integration for Smalltalk/X (LIB)\0"
-      VALUE "FileVersion", "6.2.709.709\0"
+      VALUE "FileVersion", "6.2.6359.6359\0"
       VALUE "InternalName", "stx:libscm/mercurial\0"
       VALUE "LegalCopyright", "Copyright Jan Vrany 2012\0"
       VALUE "ProductName", "Smalltalk/X Mercurial Integration\0"
       VALUE "ProductVersion", "6.2.3.0\0"
-      VALUE "ProductDate", "Sun, 16 Dec 2012 12:01:41 GMT\0"
+      VALUE "ProductDate", "Sat, 12 Jan 2013 14:04:29 GMT\0"
     END
 
   END
--- a/mercurial/stx_libscm_mercurial.st	Sat Jan 12 14:04:19 2013 +0000
+++ b/mercurial/stx_libscm_mercurial.st	Sat Jan 12 14:10:22 2013 +0000
@@ -27,14 +27,14 @@
      exclude individual packages in the #excludedFromPrerequisites method."
 
     ^ #(
-        #'stx:goodies/sunit'    "TestResource - superclass of HGRepositoriesResource "
-        #'stx:libbasic'    "LibraryDefinition - superclass of stx_libscm_mercurial "
-        #'stx:libbasic2'    "Singleton - superclass of HGStatus::Added "
+        #'stx:goodies/sunit'    "TestCase - superclass of HGTests "
+        #'stx:libbasic'    "UninterpretedBytes - superclass of HGChangesetId "
+        #'stx:libbasic2'    "Singleton - superclass of HGStatus "
         #'stx:libbasic3'    "AbstractSourceCodeManager - superclass of HGSourceCodeManager "
-        #'stx:libscm/common'    "SCMAbstractFileoutLikeTask - superclass of HGCommitTask "
-        #'stx:libtool'    "DirectoryContentsBrowser - superclass of HGWorkingCopyBrowser::DirectoryContentsBrowser "
-        #'stx:libview'    "Depth8Image - referenced by HGIconLibrary class>>commit "
-        #'stx:libview2'    "Model - superclass of HGSourceCodeManagementSettingsAppl "
+        #'stx:libscm/common'    "SCMAbstractSourceCodeManager - superclass of HGSourceCodeManager "
+        #'stx:libtool'    "AbstractSettingsApplication - superclass of HGSourceCodeManagementSettingsAppl "
+        #'stx:libview'    "Color - referenced by HGCommitDialog>>moreOptionsLabel "
+        #'stx:libview2'    "ApplicationModel - superclass of HGCommitDialog "
     )
 ! !
 
@@ -118,6 +118,11 @@
         'ConfigurableFeatures class' hasHGSupportEnabled
         AbstractFileBrowser currentHgRepository
         AbstractFileBrowser hasHGWorkingCopySelected
+        AbstractFileBrowser hgCommit
+        AbstractFileBrowser hgExecuteCommand:
+        AbstractFileBrowser hgExecuteCommand:objects:
+        AbstractFileBrowser hgStatus
+        #'Tools::NewSystemBrowser' commonMenuHGBrowseTemporaryWorkingCopy
     )
 ! !