Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9.2, 1.9.3, and 2.0

shelve: show more descriptive names for patches and shelves

Rather than showing full paths, show 'Patch: foo' or 'Shelve: bar'. We keep
the list of absolute filenames for all shelves and patches so they do not have
to go to unicode and back, and so we can figure out what the user selected from
the combo boxes.

Changeset 3f6b65783816

Parent ed22e0d76982

by Steve Borho

Changes to 2 files · Browse files at 3f6b65783816 Showing diff from parent ed22e0d76982 Diff from another changeset...

 
26
27
28
 
 
29
30
31
 
176
177
178
179
 
 
180
181
182
183
184
185
186
 
190
191
192
193
 
 
194
195
196
197
198
199
200
 
202
203
204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
206
207
208
 
 
 
 
 
 
 
 
 
 
 
 
209
210
211
212
213
214
215
216
217
 
 
 
 
 
218
219
220
221
222
223
 
 
 
 
 
 
 
 
 
 
 
224
225
226
 
230
231
232
233
234
 
 
235
236
237
238
239
240
 
 
241
242
243
 
26
27
28
29
30
31
32
33
 
178
179
180
 
181
182
183
184
185
 
186
187
188
 
192
193
194
 
195
196
197
198
199
 
200
201
202
 
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
 
 
234
235
236
237
238
239
240
241
242
243
244
245
246
247
 
 
 
 
 
 
 
248
249
250
251
252
253
 
 
 
 
 
254
255
256
257
258
259
260
261
262
263
264
265
266
267
 
271
272
273
 
 
274
275
276
277
278
279
 
 
280
281
282
283
284
@@ -26,6 +26,8 @@
  QMainWindow.__init__(self)     self.repo = repo + self.shelves = [] + self.patches = []     self.splitter = QSplitter(self)   self.splitter.setOrientation(Qt.Horizontal) @@ -176,11 +178,11 @@
    @pyqtSlot()   def deleteShelfA(self): - ushelf = self.comboa.currentText() + shelf = self.currentPatchA() + ushelf = hglib.tounicode(os.path.basename(shelf))   if not qtlib.QuestionMsgBox(_('Are you sure?'),   _('Delete shelf file %s?') % ushelf):   return - shelf = hglib.fromunicode(ushelf)   try:   os.unlink(shelf)   self.showMessage(_('Shelf deleted')) @@ -190,11 +192,11 @@
    @pyqtSlot()   def deleteShelfB(self): - ushelf = self.combob.currentText() + shelf = self.currentPatchB() + ushelf = hglib.tounicode(os.path.basename(shelf))   if not qtlib.QuestionMsgBox(_('Are you sure?'),   _('Delete shelf file %s?') % ushelf):   return - shelf = hglib.fromunicode(ushelf)   try:   os.unlink(shelf)   self.showMessage(_('Shelf deleted')) @@ -202,25 +204,64 @@
  self.showMessage(hglib.tounicode(str(e)))   self.refreshCombos()   + def currentPatchA(self): + idx = self.comboa.currentIndex() + if idx == -1: + return None + if idx == 0: + return self.wdir + idx -= 1 + if idx < len(self.shelves): + return self.shelves[idx] + idx -= len(self.shelves) + if idx < len(self.patches): + return self.patches[idx] + return None + + def currentPatchB(self): + idx = self.combob.currentIndex() + if idx == -1: + return None + if idx < len(self.shelves): + return self.shelves[idx] + idx -= len(self.shelves) + if idx < len(self.patches): + return self.patches[idx] + return None +   @pyqtSlot()   def refreshCombos(self): - ushelvea = self.comboa.currentText() - ushelveb = self.combob.currentText() + shelvea, shelveb = self.currentPatchA(), self.currentPatchB() + + shelves = self.repo.thgshelves() + disp = [_('Shelf: %s') % hglib.tounicode(s) for s in shelves] + + patches = self.repo.thgmqunappliedpatches + disp += [_('Patch: %s') % hglib.tounicode(p) for p in patches] + + # store fully qualified paths + self.shelves = [os.path.join(self.repo.shelfdir, s) for s in shelves] + self.patches = [self.repo.mq.join(p) for p in patches] +   self.comboa.clear()   self.combob.clear() - shelves = [hglib.tounicode(s) for s in self.repo.thgshelves()] - patches = self.repo.thgmqunappliedpatches[:] - patches = [hglib.tounicode(self.repo.mq.join(p)) for p in patches] - patches = shelves + patches - self.comboa.addItems([self.wdir] + patches) - self.combob.addItems(patches) - if ushelvea == self.wdir: + self.comboa.addItems([self.wdir] + disp) + self.combob.addItems(disp) + + # attempt to restore selection + if shelvea == self.wdir:   self.comboa.setCurrentIndex(0) - elif ushelvea in patches: - self.comboa.setCurrentIndex(1 + patches.index(ushelvea)) - if ushelveb in patches: - self.combob.setCurrentIndex(patches.index(ushelveb)) - if not patches: + elif shelvea in self.shelves: + self.comboa.setCurrentIndex(1 + self.shelves.index(shelvea)) + elif shelvea in self.patches: + self.comboa.setCurrentIndex(1 + len(self.shelves) + + self.patches.index(shelvea)) + if shelveb in self.shelves: + self.combob.setCurrentIndex(self.shelves.index(shelveb)) + if shelveb in self.shelves: + self.combob.setCurrentIndex(len(self.shelves) + + self.patches.index(shelveb)) + if not patches and not shelves:   self.delShelfButtonB.setEnabled(False)   self.browseb.setContext(patchctx('', self.repo, None))   @@ -230,14 +271,14 @@
  rev = None   self.delShelfButtonA.setEnabled(False)   else: - rev = hglib.fromunicode(self.comboa.currentText()) - self.delShelfButtonA.setEnabled(rev.startswith(self.repo.shelfdir)) + rev = self.currentPatchA() + self.delShelfButtonA.setEnabled(index <= len(self.shelves))   self.browsea.setContext(self.repo.changectx(rev))     @pyqtSlot(int)   def comboBChanged(self, index): - rev = hglib.fromunicode(self.combob.currentText()) - self.delShelfButtonB.setEnabled(rev.startswith(self.repo.shelfdir)) + rev = self.currentPatchB() + self.delShelfButtonB.setEnabled(index < len(self.shelves))   self.browseb.setContext(self.repo.changectx(rev))     @pyqtSlot(int, int)
 
440
441
442
443
 
444
445
446
 
440
441
442
 
443
444
445
446
@@ -440,7 +440,7 @@
  def thgshelves(self):   self.shelfdir = sdir = self.join('shelves')   if os.path.isdir(sdir): - return [os.path.join(sdir, s) for s in os.listdir(sdir)] + return os.listdir(sdir)   return []     def thginvalidate(self):