mercurial/extensions.st
changeset 173 c72794df7ae3
parent 170 e0bdc6f35bf9
child 174 0d293012a897
equal deleted inserted replaced
172:ca0b1a930b87 173:c72794df7ae3
    18 
    18 
    19     ^ self hgMenusAreShown 
    19     ^ self hgMenusAreShown 
    20         and:[((Smalltalk at:#HGRepository) discover:self currentDirectoryDisplayed) notNil]
    20         and:[((Smalltalk at:#HGRepository) discover:self currentDirectoryDisplayed) notNil]
    21 
    21 
    22     "Created: / 14-12-2012 / 18:26:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    22     "Created: / 14-12-2012 / 18:26:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    23 ! !
       
    24 
       
    25 !AbstractFileBrowser methodsFor:'menu actions-scm-hg'!
       
    26 
       
    27 hgCommit
       
    28     | wc task |
       
    29 
       
    30     wc := self currentHgRepository workingCopy.
       
    31     task := HGCommitTask new temporaryWorkingCopy: wc.
       
    32     HGCommitDialog new
       
    33         task: task;
       
    34         open
       
    35 
       
    36     "Created: / 11-01-2013 / 19:27:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    37     "Modified: / 12-01-2013 / 13:57:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    38 ! !
       
    39 
       
    40 !AbstractFileBrowser methodsFor:'menu actions-scm-hg'!
       
    41 
       
    42 hgExecuteCommand: command
       
    43     "Executes svn command on currently selected objects"
       
    44 
       
    45     self hgExecuteCommand: command objects: self currentSelectedObjects.
       
    46 
       
    47     "Created: / 12-01-2013 / 12:08:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    48 ! !
       
    49 
       
    50 !AbstractFileBrowser methodsFor:'menu actions-scm-hg'!
       
    51 
       
    52 hgExecuteCommand: command objects: givenObjects
       
    53     "Executes svn command on given objects (files/dirs)"
       
    54 
       
    55     | objects workdir objectsAsString executionBlock |
       
    56 
       
    57     objects := givenObjects.
       
    58 
       
    59     (self isKindOf: FileBrowserV2) ifTrue:[
       
    60         workdir := self currentDirectoryDisplayed.
       
    61         workdir isDirectory ifFalse:[
       
    62             workdir := workdir directory
       
    63         ].
       
    64     ] ifFalse:[
       
    65         (objects size == 1 and:[objects anElement isDirectory]) ifTrue:[
       
    66             workdir := objects anElement
       
    67         ] ifFalse:[
       
    68             workdir := Filename currentDirectory.
       
    69         ]
       
    70     ].
       
    71 
       
    72     objectsAsString := String streamContents:[:s|
       
    73         objects size == 1 ifTrue:[
       
    74             workdir asString = objects anElement asString ifTrue:[
       
    75                 s nextPut:$.
       
    76             ] ifFalse:[
       
    77                 s nextPutAll: objects anElement asString.
       
    78             ]
       
    79         ] ifFalse:[
       
    80             objects do:[:each|s nextPut:$"; nextPutAll:each asString; nextPut:$"]
       
    81                 separatedBy:[s space]
       
    82         ]
       
    83     ].
       
    84 
       
    85     executionBlock := [:stream |
       
    86         | cmd |
       
    87 
       
    88         cmd := '%1 --noninteractive %2 %3' 
       
    89                 bindWith: HGCommand hgCommand
       
    90                     with: command
       
    91                     with: objectsAsString.
       
    92         stream nextPutAll: cmd; cr; cr.
       
    93         (self getExecutionBlockForCommand:cmd inDirectory: workdir) value:stream.
       
    94     ].
       
    95     self makeExecutionResultProcessFor:executionBlock withName:'Mercurial> hg ', command.
       
    96 
       
    97     "Created: / 12-01-2013 / 12:09:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    98 ! !
       
    99 
       
   100 !AbstractFileBrowser methodsFor:'menu actions-scm-hg'!
       
   101 
       
   102 hgStatus
       
   103     self hgExecuteCommand: 'status'
       
   104 
       
   105     "Modified: / 12-01-2013 / 12:09:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    23 ! !
   106 ! !
    24 
   107 
    25 !AbstractFileBrowser class methodsFor:'menu specs-scm'!
   108 !AbstractFileBrowser class methodsFor:'menu specs-scm'!
    26 
   109 
    27 hgMenu
   110 hgMenu
    45          (MenuItem
   128          (MenuItem
    46             enabled: hasHGWorkingCopySelected
   129             enabled: hasHGWorkingCopySelected
    47             label: 'Commit'
   130             label: 'Commit'
    48             itemValue: hgCommit
   131             itemValue: hgCommit
    49             labelImage: (ResourceRetriever HGIconLibrary commit 'Commit')
   132             labelImage: (ResourceRetriever HGIconLibrary commit 'Commit')
       
   133           )
       
   134          (MenuItem
       
   135             label: '-'
       
   136           )
       
   137          (MenuItem
       
   138             label: 'Status'
       
   139             itemValue: hgStatus
    50           )
   140           )
    51          (MenuItem
   141          (MenuItem
    52             label: '-'
   142             label: '-'
    53           )
   143           )
    54          (MenuItem
   144          (MenuItem
   253 
   343 
   254 asHGChangesetId
   344 asHGChangesetId
   255     ^ HGChangesetId fromString:self.
   345     ^ HGChangesetId fromString:self.
   256 
   346 
   257     "Created: / 16-11-2012 / 21:24:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   347     "Created: / 16-11-2012 / 21:24:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   348 ! !
       
   349 
       
   350 !Tools::NewSystemBrowser methodsFor:'menu actions-hg'!
       
   351 
       
   352 commonMenuHGBrowseTemporaryWorkingCopy
       
   353     self selectedProjectsForHG value do:[:package|
       
   354         | pkg  |
       
   355 
       
   356         pkg := HGPackageModel named: package.
       
   357         pkg notNil ifTrue:[
       
   358             pkg temporaryWorkingCopy browse 
       
   359         ].
       
   360     ].
       
   361 
       
   362     "Created: / 11-01-2013 / 18:47:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   258 ! !
   363 ! !
   259 
   364 
   260 !Tools::NewSystemBrowser methodsFor:'menu actions-hg'!
   365 !Tools::NewSystemBrowser methodsFor:'menu actions-hg'!
   261 
   366 
   262 commonMenuHGBrowseWorkingCopy
   367 commonMenuHGBrowseWorkingCopy