Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.6, 0.7, and 0.7.1

status: add button to move files to other directory within repo

Note: only 'clean' files may be moved.

Changeset 813ae72b13ee

Parent 2d6ba604344b

by TK Soh

Changes to one file · Browse files at 813ae72b13ee Showing diff from parent 2d6ba604344b Diff from another changeset...

Change 1 of 4 Show Entire File hggtk/​status.py Stacked
 
27
28
29
30
 
31
32
33
 
151
152
153
 
 
 
154
155
156
 
522
523
524
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
526
527
 
695
696
697
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
698
699
700
 
27
28
29
 
30
31
32
33
 
151
152
153
154
155
156
157
158
159
 
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
 
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
@@ -27,7 +27,7 @@
 from mercurial import merge as merge_  from hgext import extdiff  from shlib import shell_notify -from hglib import toutf +from hglib import toutf, rootpath  from gdialog import *    class GStatus(GDialog): @@ -151,6 +151,9 @@
  self._revert_clicked, tip='revert'),   self.make_toolbutton(gtk.STOCK_ADD, '_Add',   self._add_clicked, tip='add'), + self.make_toolbutton(gtk.STOCK_JUMP_TO, 'Move', + self._move_clicked, + tip='move selected files to other directory'),   self.make_toolbutton(gtk.STOCK_DELETE, '_Remove',   self._remove_clicked, tip='remove'),   gtk.SeparatorToolItem(), @@ -522,6 +525,24 @@
  self.reload_status()     + def _hg_move(self, files): + wfiles = [self.repo.wjoin(x) for x in files] + if self.count_revs() > 1: + Prompt('Nothing Moved', 'Move is not enabled when ' + 'multiple revisions are specified.', self).run() + return + + # Create new opts, so nothing unintented gets through + moveopts = self.merge_opts(commands.table['rename|mv'][1], + ('include', 'exclude')) + def dohgmove(): + #moveopts['force'] = True + commands.rename(self.ui, self.repo, *wfiles, **moveopts) + success, outtext = self._hg_call_wrapper('Move', dohgmove) + if success: + self.reload_status() + +   def _tree_selection_changed(self, selection, force):   ''' Update the diff text '''   def dohgdiff(): @@ -695,6 +716,37 @@
  Prompt('Nothing Removed', 'No removable files selected', self).run()   return True   + def _move_clicked(self, toolbutton, data=None): + move_list = self._relevant_files('C') + if move_list: + # get destination directory to files into + dialog = gtk.FileChooserDialog(title="Move files to diretory...", + parent=self, + action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, + buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL, + gtk.STOCK_OPEN,gtk.RESPONSE_OK)) + dialog.set_default_response(gtk.RESPONSE_OK) + dialog.set_current_folder(self.repo.root) + response = dialog.run() + destdir = dialog.get_filename() + dialog.destroy() + if response != gtk.RESPONSE_OK: + return True + + # verify directory + destroot = rootpath(destdir) + if destroot != self.repo.root: + Prompt('Nothing Moved', "Can't move outside repo!", self).run() + return True + + # move the files to dest directory + move_list.append(destdir) + self._hg_move(move_list) + else: + Prompt('Nothing Moved', 'No movable files selected\n\n' + 'Note: only clean files can be moved.', self).run() + return True +   def _delete_file(self, stat, file):   self._delete_files([file])