Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0.5, 2.1, and 2.1.1

stable guess: improve renaming workflow

Do not require the user to select the files that will be looked for renames.
Instead, if no file is selected try to look for renames for all missing files.
Also, when no matches are selected the "Accept matches" button accepts all
matches (and it says so on the button text).

Changeset f7a2f8ff5c81

Parent 112dc67bc9ca

by Angel Ezquerra

Changes to one file · Browse files at f7a2f8ff5c81 Showing diff from parent 112dc67bc9ca Diff from another changeset...

 
84
85
86
87
 
88
89
90
 
92
93
94
95
96
97
98
99
100
 
106
107
108
109
 
110
111
112
 
116
117
118
119
 
 
 
 
120
121
122
 
163
164
165
 
 
 
 
166
167
 
168
169
170
 
172
173
174
175
176
177
 
 
178
179
180
 
 
 
 
 
 
 
181
182
183
 
196
197
198
199
 
 
200
201
202
 
205
206
207
208
209
 
 
 
 
 
 
 
 
 
 
210
211
212
 
84
85
86
 
87
88
89
90
 
92
93
94
 
 
 
95
96
97
 
103
104
105
 
106
107
108
109
 
113
114
115
 
116
117
118
119
120
121
122
 
163
164
165
166
167
168
169
170
171
172
173
174
175
 
177
178
179
 
 
 
180
181
182
 
 
183
184
185
186
187
188
189
190
191
192
 
205
206
207
 
208
209
210
211
212
 
215
216
217
 
 
218
219
220
221
222
223
224
225
226
227
228
229
230
@@ -84,7 +84,7 @@
  copycheck.setToolTip(_('Uncheck to consider all revisioned files '   'for copy sources'))   copycheck.setChecked(True) - findrenames = QPushButton(_('Find Rename')) + findrenames = QPushButton(_('Find Renames'))   findrenames.setToolTip(_('Find copy and/or rename sources'))   findrenames.setEnabled(False)   findrenames.clicked.connect(self.findRenames) @@ -92,9 +92,6 @@
  buthbox.addStretch(1)   buthbox.addWidget(findrenames)   self.findbtn, self.copycheck = findrenames, copycheck - def itemselect(): - self.findbtn.setEnabled(len(self.unrevlist.selectedItems())) - self.unrevlist.itemSelectionChanged.connect(itemselect)     matchlbl = QLabel(_('<b>Candidate Matches</b>'))   matchvbox.addWidget(matchlbl) @@ -106,7 +103,7 @@
  matchtv.setSortingEnabled(True)   matchtv.selectionModel().selectionChanged.connect(self.showDiff)   buthbox = QHBoxLayout() - matchbtn = QPushButton(_('Accept Selected Matches')) + matchbtn = QPushButton(_('Accept All Matches'))   matchbtn.clicked.connect(self.acceptMatch)   matchbtn.setEnabled(False)   buthbox.addStretch(1) @@ -116,7 +113,10 @@
  self.matchtv, self.matchbtn = matchtv, matchbtn   def matchselect(s, d):   count = len(matchtv.selectedIndexes()) - self.matchbtn.setEnabled(count > 0) + if count: + self.matchbtn.setText(_('Accept Selected Matches')) + else: + self.matchbtn.setText(_('Accept All Matches'))   selmodel = matchtv.selectionModel()   selmodel.selectionChanged.connect(matchselect)   @@ -163,8 +163,13 @@
  item.orig = x   self.unrevlist.addItem(item)   self.unrevlist.setItemSelected(item, x in self.pats) + if dests: + self.findbtn.setEnabled(True) + else: + self.findbtn.setEnabled(False)   self.difftb.clear()   self.pats = [] + self.matchbtn.setEnabled(len(self.matchtv.model().rows))     def findRenames(self):   'User pressed "find renames" button' @@ -172,12 +177,16 @@
  QMessageBox.information(self, _('Search already in progress'),   _('Cannot start a new search'))   return - ulist = [] - for item in self.unrevlist.selectedItems(): - ulist.append(item.orig) + + ulist = [it.orig for it in self.unrevlist.selectedItems()]   if not ulist: - QMessageBox.information(self, _('No rows selected'), - _('Select one or more rows for search')) + # When no files are selected, look for all files + ulist = [self.unrevlist.item(n).orig + for n in range(self.unrevlist.count())] + + if not ulist: + QMessageBox.information(self, _('No files to find'), + _('There are no files that may have been renamed'))   return     pct = self.simslider.value() / 100.0 @@ -196,7 +205,8 @@
  self.stbar.clear()   for col in xrange(3):   self.matchtv.resizeColumnToContents(col) - self.findbtn.setEnabled(len(self.unrevlist.selectedItems())) + self.findbtn.setEnabled(self.unrevlist.count()) + self.matchbtn.setEnabled(len(self.matchtv.model().rows))     def rowReceived(self, args):   self.matchtv.model().appendRow(*args) @@ -205,8 +215,16 @@
  'User pressed "accept match" button'   remdests = {}   wctx = self.repo[None] - for index in self.matchtv.selectionModel().selectedRows(): - src, dest, percent = self.matchtv.model().getRow(index) + m = self.matchtv.model() + + # If no rows are selected, ask the user if he'd like to accept all renames + if self.matchtv.selectionModel().hasSelection(): + itemList = [row for row in self.matchtv.selectionModel().selectedRows()] + else: + itemList = m.rows + + for item in itemList: + src, dest, percent = item   if dest in remdests:   udest = hglib.tounicode(dest)   QMessageBox.warning(self, _('Multiple sources chosen'),