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

chunks: implement working copy side of deleteSelectedChunks

Changeset b18285ae5a92

Parent 3f6b65783816

by Steve Borho

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

 
8
9
10
 
11
12
13
 
28
29
30
 
31
32
33
 
94
95
96
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
99
100
 
118
119
120
 
 
 
 
121
122
123
 
125
126
127
 
 
128
129
130
 
331
332
333
 
334
335
336
 
8
9
10
11
12
13
14
 
29
30
31
32
33
34
35
 
96
97
98
 
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
 
157
158
159
160
161
162
163
164
165
166
 
168
169
170
171
172
173
174
175
 
376
377
378
379
380
381
382
@@ -8,6 +8,7 @@
 import cStringIO  import os   +from mercurial import hg, util, patch  from hgext import record    from tortoisehg.util import hglib @@ -28,6 +29,7 @@
  showMessage = pyqtSignal(QString)   chunksSelected = pyqtSignal(bool)   fileSelected = pyqtSignal(bool) + fileModified = pyqtSignal()     def __init__(self, repo, parent):   QWidget.__init__(self, parent) @@ -94,7 +96,44 @@
  wctxactions.edit(self, self.repo.ui, self.repo, [path])     def deleteSelectedChunks(self): - pass + 'delete currently selected chunks' + repo = self.repo + chunks = self.diffbrowse.curchunks + dchunks = [c for c in chunks[1:] if c.selected] + if not dchunks: + self.showMessage.emit(_('No deletable chunks')) + return + kchunks = [c for c in chunks[1:] if not c.selected] + revertall = False + if not kchunks and qtlib.QuestionMsgBox(_('No chunks remain'), + _('Remove all file changes?')): + revertall = True + ctx = self.filelistmodel._ctx + if isinstance(ctx, patchctx): + raise 'unimplemented' + else: + path = repo.wjoin(self.currentFile) + if not os.path.exists(path): + self.showMessage.emit(_('file hsa been deleted, refresh')) + return + if self.mtime != os.path.getmtime(path): + self.showMessage.emit(_('file hsa been modified, refresh')) + return + if revertall: + hg.revert(repo, repo.dirstate.parents()[0], + lambda a: a == self.currentFile) + else: + repo.wopener(self.currentFile, 'wb').write( + self.diffbrowse.origcontents) + fp = cStringIO.StringIO() + chunks[0].write(fp) + for c in kchunks: + c.write(fp) + fp.seek(0) + pfiles = {} + patch.internalpatch(fp, repo.ui, 1, repo.root, files=pfiles, + eolmode=None) + self.fileModified.emit()     def addFile(self, wfile, chunks):   pass @@ -118,6 +157,10 @@
  self.fileSelected.emit(False)     def setContext(self, ctx): + if self.filelist.model() is not None: + f = self.filelist.currentFile() + else: + f = None   self.fileSelected.emit(False)   self.filelistmodel = filelistmodel.HgFileListModel(self.repo, self)   self.filelist.setModel(self.filelistmodel) @@ -125,6 +168,8 @@
  self.filelist.clearDisplay.connect(self.diffbrowse.clearDisplay)   self.diffbrowse.setContext(ctx)   self.filelistmodel.setContext(ctx) + if f and f in ctx: + self.filelist.selectFile(f)     def refresh(self):   f = self.filelist.currentFile() @@ -331,6 +376,7 @@
  else:   self.sci.markerAdd(start+i, self.vertical)   start += len(chunk.lines) + self.origcontents = fd.olddata   self.curchunks = chunks   self.countselected = 0   self.updateSummary()
 
100
101
102
 
103
104
105
 
130
131
132
 
133
134
135
 
140
141
142
 
143
144
145
146
 
147
148
149
 
100
101
102
103
104
105
106
 
131
132
133
134
135
136
137
 
142
143
144
145
146
147
148
149
150
151
152
153
@@ -100,6 +100,7 @@
  self.lefttbar = QToolBar(_('Left Toolbar'), objectName='lefttbar')   self.addToolBar(self.lefttbar)   self.deletea = a = QAction(_('Deleted selected chunks'), self) + self.deletea.triggered.connect(self.browsea.deleteSelectedChunks)   a.setIcon(qtlib.geticon('delfilesleft'))   self.lefttbar.addAction(self.deletea)   self.allright = a = QAction(_('Move all files right'), self) @@ -130,6 +131,7 @@
  a.setIcon(qtlib.geticon('media-seek-backward'))   self.righttbar.addAction(self.allleft)   self.deleteb = a = QAction(_('Deleted selected chunks'), self) + self.deleteb.triggered.connect(self.browseb.deleteSelectedChunks)   a.setIcon(qtlib.geticon('delfilesright'))   self.righttbar.addAction(self.deleteb)   @@ -140,10 +142,12 @@
  self.browsea.chunksSelected.connect(self.deletea.setEnabled)   self.browsea.fileSelected.connect(self.fileright.setEnabled)   self.browsea.fileSelected.connect(self.editfilea.setEnabled) + self.browsea.fileModified.connect(self.refreshCombos)   self.browseb.chunksSelected.connect(self.chunksleft.setEnabled)   self.browseb.chunksSelected.connect(self.deleteb.setEnabled)   self.browseb.fileSelected.connect(self.fileleft.setEnabled)   self.browseb.fileSelected.connect(self.editfileb.setEnabled) + self.browseb.fileModified.connect(self.refreshCombos)     self.statusbar = cmdui.ThgStatusBar(self)   self.setStatusBar(self.statusbar)