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

chunks: maintain chunk selection through file refresh

This needs to work in order for chunk movement to work correctly

Changeset 09ab8accf99d

Parent 0d2c3b8d6527

by Steve Borho

Changes to one file · Browse files at 09ab8accf99d Showing diff from parent 0d2c3b8d6527 Diff from another changeset...

 
66
67
68
 
 
 
69
70
71
72
73
74
 
 
75
76
77
 
205
206
207
208
 
 
 
 
209
210
211
 
305
306
307
 
308
309
310
 
315
316
317
318
319
320
321
322
323
324
 
 
325
326
327
328
329
330
 
332
333
334
335
336
337
 
338
339
340
 
349
350
351
 
352
353
354
 
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
 
466
467
468
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
470
471
 
480
481
482
 
 
483
484
485
486
487
488
 
 
 
 
 
 
489
490
491
 
529
530
531
 
532
533
 
 
 
534
535
536
 
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 
210
211
212
 
213
214
215
216
217
218
219
 
313
314
315
316
317
318
319
 
324
325
326
 
 
327
328
329
330
331
332
333
334
335
 
336
337
338
 
340
341
342
 
 
 
343
344
345
346
 
355
356
357
358
359
360
361
 
457
458
459
 
 
 
 
 
 
 
 
 
 
 
 
 
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
 
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
 
547
548
549
550
551
 
552
553
554
555
556
557
@@ -66,12 +66,17 @@
  self.diffbrowse.linkActivated.connect(self.linkActivated)   self.diffbrowse.chunksSelected.connect(self.chunksSelected)   + self.filelist.fileRevSelected.connect(self.displayFile) + self.filelist.clearDisplay.connect(self.diffbrowse.clearDisplay) +   self.splitter.setStretchFactor(0, 0)   self.splitter.setStretchFactor(1, 3)   self.timerevent = self.startTimer(500)     def timerEvent(self, event):   'Periodic poll of currently displayed patch or working file' + if not hasattr(self, 'filelistmodel'): + return   ctx = self.filelistmodel._ctx   if ctx is None:   return @@ -205,7 +210,10 @@
  ctx._files[wfile] = newchunks   else:   # add file to patch - ctx._files[wfile] = chunks + lines = ['diff -r aaaaaaaaaaaa -r bbbbbbbbbbb %s\n' % wfile] + lines.append('--- a/%s\n' % wfile) + lines.append('+++ b/%s\n' % wfile) + ctx._files[wfile] = [record.header(lines)] + chunks   ctx._fileorder.append(wfile)   repo.thgbackup(ctx._path)   fp = util.atomictempfile(ctx._path, 'wb') @@ -305,6 +313,7 @@
  else:   self.currentFile = None   self.diffbrowse.clearDisplay() + self.diffbrowse.clearChunks()   self.fileSelected.emit(False)     def setContext(self, ctx): @@ -315,16 +324,15 @@
  self.fileSelected.emit(False)   self.filelistmodel = filelistmodel.HgFileListModel(self.repo, self)   self.filelist.setModel(self.filelistmodel) - self.filelist.fileRevSelected.connect(self.displayFile) - self.filelist.clearDisplay.connect(self.diffbrowse.clearDisplay)   self.diffbrowse.setContext(ctx)   self.filelistmodel.setContext(ctx)   self.fileModelEmpty.emit(len(ctx.files()) == 0)   if f and f in ctx:   self.filelist.selectFile(f) + else: + self.diffbrowse.clearChunks()     def refresh(self): - f = self.filelist.currentFile()   ctx = self.filelistmodel._ctx   if isinstance(ctx, patchctx):   # if patch mtime has not changed, it could return the same ctx @@ -332,9 +340,7 @@
  else:   self.repo.thginvalidate()   ctx = self.repo.changectx(ctx.node()) - self.filelistmodel.setContext(ctx) - if f in ctx: - self.filelist.selectFile(f) + self.setContext(ctx)    class DiffBrowser(QFrame):   """diff browser""" @@ -349,6 +355,7 @@
  self.curchunks = []   self.countselected = 0   self._ctx = None + self._lastfile = None     vbox = QVBoxLayout()   vbox.setContentsMargins(0,0,0,0) @@ -450,22 +457,25 @@
  def marginClicked(self, margin, line, modifiers):   for chunk in self.curchunks[1:]:   if line >= chunk.lrange[0] and line < chunk.lrange[1]: - self.sci.markerDelete(chunk.mline, -1) - if chunk.selected: - self.sci.markerAdd(chunk.mline, self.unselected) - chunk.selected = False - self.countselected -= 1 - for i in xrange(*chunk.lrange): - self.sci.markerDelete(i, self.selcolor) - else: - self.sci.markerAdd(chunk.mline, self.selected) - chunk.selected = True - self.countselected += 1 - for i in xrange(*chunk.lrange): - self.sci.markerAdd(i, self.selcolor) + self.toggleChunk(chunk)   self.updateSummary()   return   + def toggleChunk(self, chunk): + self.sci.markerDelete(chunk.mline, -1) + if chunk.selected: + self.sci.markerAdd(chunk.mline, self.unselected) + chunk.selected = False + self.countselected -= 1 + for i in xrange(*chunk.lrange): + self.sci.markerDelete(i, self.selcolor) + else: + self.sci.markerAdd(chunk.mline, self.selected) + chunk.selected = True + self.countselected += 1 + for i in xrange(*chunk.lrange): + self.sci.markerAdd(i, self.selcolor) +   def setContext(self, ctx):   self._ctx = ctx   self.sci.setTabWidth(ctx._repo.tabwidth) @@ -480,12 +490,20 @@
  self.sci.clear()   self.filenamelabel.setText(' ')   self.extralabel.hide() + + def clearChunks(self):   self.curchunks = []   self.countselected = 0   self.updateSummary()     def displayFile(self, filename, status):   self.clearDisplay() + if filename == self._lastfile: + reenable = [c.fromline for c in self.curchunks[1:] if c.selected] + else: + reenable = [] + self._lastfile = filename + self.clearChunks()     fd = fileview.FileData(self._ctx, None, filename, status)   @@ -529,8 +547,11 @@
  self.sci.markerAdd(start+i, self.vertical)   start += len(chunk.lines)   self.origcontents = fd.olddata + self.countselected = 0   self.curchunks = chunks - self.countselected = 0 + for c in chunks[1:]: + if c.fromline in reenable: + self.toggleChunk(c)   self.updateSummary()    def run(ui, *pats, **opts):