Commits

Yuya Nishihara committed 27a45a4

fin

Comments (0)

Files changed (10)

fd-chunkexcmeth.diff

-# HG changeset patch
-# Date 1390040422 -32400
-# Parent 8c2cc35a81f54165d9363a633e082516ea94cebd
-filedata: move responsibility to update chunk selection state from fileview
-
-diff --git a/tortoisehg/hgqt/filedata.py b/tortoisehg/hgqt/filedata.py
---- a/tortoisehg/hgqt/filedata.py
-+++ b/tortoisehg/hgqt/filedata.py
-@@ -430,6 +430,17 @@ class FileData(_AbstractFileData):
-             return udiff
-         return _trimdiffheader(udiff)
- 
-+    def setChunkExcluded(self, chunk, exclude):
-+        assert chunk in self.changes.hunks
-+        if chunk.excluded == exclude:
-+            return
-+        if exclude:
-+            chunk.excluded = True
-+            self.changes.excludecount += 1
-+        else:
-+            chunk.excluded = False
-+            self.changes.excludecount -= 1
-+
- 
- class DirData(_AbstractFileData):
- 
-diff --git a/tortoisehg/hgqt/fileview.py b/tortoisehg/hgqt/fileview.py
---- a/tortoisehg/hgqt/fileview.py
-+++ b/tortoisehg/hgqt/fileview.py
-@@ -1337,14 +1337,7 @@ class _ChunkSelectionViewControl(_Abstra
-             self._updateMarker(chunk)
- 
-     def updateChunk(self, chunk, exclude):
--        if chunk.excluded == exclude:
--            return
--        if exclude:
--            chunk.excluded = True
--            self._fd.changes.excludecount += 1
--        else:
--            chunk.excluded = False
--            self._fd.changes.excludecount -= 1
-+        self._fd.setChunkExcluded(chunk, exclude)
-         self._updateMarker(chunk)
- 
-     def _updateMarker(self, chunk):

fv-chunkmarkupdatable.diff

-# HG changeset patch
-# Date 1390025304 -32400
-# Parent a85d30e84d1d15ee9c72ac7b00231d3e0d0f3145
-fileview: do not add/remove chunk selection message and markers more than once
-
-This makes _updateMarker() callable without changing the chunk.excluded state.
-
-diff --git a/tortoisehg/hgqt/fileview.py b/tortoisehg/hgqt/fileview.py
---- a/tortoisehg/hgqt/fileview.py
-+++ b/tortoisehg/hgqt/fileview.py
-@@ -1306,7 +1306,13 @@ class _ChunkSelectionViewControl(_Abstra
- 
-     def _updateMarker(self, chunk):
-         excludemsg = ' ' + _('(excluded from the next commit)')
--        if chunk.excluded:
-+        # markerAdd() does not check if the specified marker is already
-+        # present, but markerDelete() does
-+        m = self._sci.markersAtLine(chunk.lineno)
-+        inclmarked = m & (1 << _IncludedChunkStartMarker)
-+        exclmarked = m & (1 << _ExcludedChunkStartMarker)
-+
-+        if chunk.excluded and not exclmarked:
-             self._sci.setReadOnly(False)
-             llen = self._sci.lineLength(chunk.lineno)  # in bytes
-             self._sci.insertAt(excludemsg, chunk.lineno, llen - 1)
-@@ -1319,7 +1325,8 @@ class _ChunkSelectionViewControl(_Abstra
-             self._sci.fillIndicatorRange(chunk.lineno + 1, 0,
-                                          chunk.lineno + chunk.linecount, 0,
-                                          self._excludeindicator)
--        else:
-+
-+        if not chunk.excluded and exclmarked:
-             self._sci.setReadOnly(False)
-             llen = self._sci.lineLength(chunk.lineno)  # in bytes
-             mlen = len(excludemsg.encode('utf-8'))  # in bytes
-@@ -1329,6 +1336,7 @@ class _ChunkSelectionViewControl(_Abstra
-             self._sci.SendScintilla(qsci.SCI_REPLACETARGET, 0, '')
-             self._sci.setReadOnly(True)
- 
-+        if not chunk.excluded and not inclmarked:
-             self._sci.markerDelete(chunk.lineno, _ExcludedChunkStartMarker)
-             self._sci.markerAdd(chunk.lineno, _IncludedChunkStartMarker)
-             for i in xrange(chunk.linecount - 1):

fv-chunkmsplit.diff

-# HG changeset patch
-# Date 1390019439 -32400
-# Parent cefdfb674d8377b439bd375a53e0f56b2710e64b
-fileview: split method to display chunk selection state without change
-
-diff --git a/tortoisehg/hgqt/fileview.py b/tortoisehg/hgqt/fileview.py
---- a/tortoisehg/hgqt/fileview.py
-+++ b/tortoisehg/hgqt/fileview.py
-@@ -1296,11 +1296,17 @@ class _ChunkSelectionViewControl(_Abstra
-     def updateChunk(self, chunk, exclude):
-         if chunk.excluded == exclude:
-             return
--        excludemsg = ' ' + _('(excluded from the next commit)')
-         if exclude:
-             chunk.excluded = True
-             self._changes.excludecount += 1
-+        else:
-+            chunk.excluded = False
-+            self._changes.excludecount -= 1
-+        self._updateMarker(chunk)
- 
-+    def _updateMarker(self, chunk):
-+        excludemsg = ' ' + _('(excluded from the next commit)')
-+        if chunk.excluded:
-             self._sci.setReadOnly(False)
-             llen = self._sci.lineLength(chunk.lineno)  # in bytes
-             self._sci.insertAt(excludemsg, chunk.lineno, llen - 1)
-@@ -1314,9 +1320,6 @@ class _ChunkSelectionViewControl(_Abstra
-                                          chunk.lineno + chunk.linecount, 0,
-                                          self._excludeindicator)
-         else:
--            chunk.excluded = False
--            self._changes.excludecount -= 1
--
-             self._sci.setReadOnly(False)
-             llen = self._sci.lineLength(chunk.lineno)  # in bytes
-             mlen = len(excludemsg.encode('utf-8'))  # in bytes

fv-chunkselkeepfd.diff

-# HG changeset patch
-# Date 1390040381 -32400
-# Parent 09e79d79b2604d7c7cadd2ad3ccfef82247305a7
-fileview: keep file data in place of chunks table
-
-diff --git a/tortoisehg/hgqt/fileview.py b/tortoisehg/hgqt/fileview.py
---- a/tortoisehg/hgqt/fileview.py
-+++ b/tortoisehg/hgqt/fileview.py
-@@ -173,7 +173,7 @@ class HgFileView(QFrame):
-         annotatec.setSourceRequested.connect(self._setSource)
-         annotatec.visualDiffRevisionRequested.connect(self._visualDiffRevision)
-         annotatec.visualDiffToLocalRequested.connect(self._visualDiffToLocal)
--        chunkselc = _ChunkSelectionViewControl(self.sci, self)
-+        chunkselc = _ChunkSelectionViewControl(self.sci, self._fd, self)
-         chunkselc.chunkSelectionChanged.connect(self.chunkSelectionChanged)
- 
-         self._activeViewControls = []
-@@ -1236,7 +1236,7 @@ class _ChunkSelectionViewControl(_Abstra
- 
-     chunkSelectionChanged = pyqtSignal()
- 
--    def __init__(self, sci, parent=None):
-+    def __init__(self, sci, fd, parent=None):
-         super(_ChunkSelectionViewControl, self).__init__(parent)
-         self._sci = sci
-         p = qtlib.getcheckboxpixmap(QStyle.State_On, QColor('#B0FFA0'), sci)
-@@ -1270,7 +1270,7 @@ class _ChunkSelectionViewControl(_Abstra
-         a.setEnabled(False)
-         a.activated.connect(self._toggleCurrentChunk)
- 
--        self._changes = None
-+        self._fd = fd
-         self._chunkatline = {}
- 
-     def open(self):
-@@ -1282,11 +1282,10 @@ class _ChunkSelectionViewControl(_Abstra
-         self._toggleshortcut.setEnabled(False)
- 
-     def display(self, fd):
--        self._changes = None
-+        self._fd = fd
-         self._chunkatline.clear()
-         if not fd.changes:
-             return
--        self._changes = fd.changes
-         for chunk in fd.changes.hunks:
-             self._chunkatline[chunk.lineno] = chunk
-             self._updateMarker(chunk)
-@@ -1296,10 +1295,10 @@ class _ChunkSelectionViewControl(_Abstra
-             return
-         if exclude:
-             chunk.excluded = True
--            self._changes.excludecount += 1
-+            self._fd.changes.excludecount += 1
-         else:
-             chunk.excluded = False
--            self._changes.excludecount -= 1
-+            self._fd.changes.excludecount -= 1
-         self._updateMarker(chunk)
- 
-     def _updateMarker(self, chunk):

fv-displayloaded.diff

-# HG changeset patch
-# Date 1390040312 -32400
-# Parent 530150ba676c5a5cf1c01855e8deba9fcafd9c00
-fileview: allow to preload file data by client code
-
-diff --git a/tortoisehg/hgqt/filedata.py b/tortoisehg/hgqt/filedata.py
---- a/tortoisehg/hgqt/filedata.py
-+++ b/tortoisehg/hgqt/filedata.py
-@@ -105,6 +105,10 @@ class _AbstractFileData(object):
-                                posixpath.join(self._rpath, self._wfile),
-                                self._ctx)
- 
-+    def isLoaded(self):
-+        loadables = [self.contents, self.ucontents, self.error, self.diff]
-+        return util.any(e is not None for e in loadables)
-+
-     def isNull(self):
-         return self._ctx.rev() == nullrev and not self._wfile
- 
-diff --git a/tortoisehg/hgqt/fileview.py b/tortoisehg/hgqt/fileview.py
---- a/tortoisehg/hgqt/fileview.py
-+++ b/tortoisehg/hgqt/fileview.py
-@@ -460,7 +460,8 @@ class HgFileView(QFrame):
-         self._displayLoaded(self._fd)
- 
-     def display(self, fd):
--        fd.load(self.isChangeSelectionEnabled())
-+        if not fd.isLoaded():
-+            fd.load(self.isChangeSelectionEnabled())
-         fd.setTextEncoding(self._textEncoding())
-         if self._autoTextEncoding():
-             fd.detectTextEncoding()

fv-preservechunksel.diff

-# HG changeset patch
-# Date 1390020401 -32400
-# Parent b3a1a54928221410b9467872d9966cd9d0be333b
-fileview: remember chunk selection on view mode switch
-
-It is no longer necessary to reload chunks since the view can start with
-chunk.excluded = True.
-
-But still it emits newChunkList(path, None) to reset selection states when
-DiffMode is switched off.  This is because the other modes cannot handle
-partial selections.
-
-diff --git a/tortoisehg/hgqt/fileview.py b/tortoisehg/hgqt/fileview.py
---- a/tortoisehg/hgqt/fileview.py
-+++ b/tortoisehg/hgqt/fileview.py
-@@ -310,9 +310,6 @@ class HgFileView(QFrame):
-         mode = action.data().toInt()[0]
-         self._lostMode = _NullMode
-         self._changeEffectiveMode(mode)
--        # TODO: delete fd.load(), which is necessary because ChunkSelection
--        # view cannot start with chunk.excluded = True
--        self._fd.load(self.isChangeSelectionEnabled())
-         self._displayLoaded(self._fd)
- 
-     def _effectiveMode(self):
-@@ -1337,7 +1334,7 @@ class _ChunkSelectionViewControl(_Abstra
-         self._changes = fd.changes
-         for chunk in fd.changes.hunks:
-             self._chunkatline[chunk.lineno] = chunk
--            self._sci.markerAdd(chunk.lineno, _IncludedChunkStartMarker)
-+            self._updateMarker(chunk)
- 
-     def updateChunk(self, chunk, exclude):
-         if chunk.excluded == exclude:

fv-updatechunkpriv.diff

-# HG changeset patch
-# Date 1390040763 -32400
-# Parent 40de3d946643b584f87f65326cfb02045b8b9326
-fileview: inline updateChunk() which is private now
-
-diff --git a/tortoisehg/hgqt/fileview.py b/tortoisehg/hgqt/fileview.py
---- a/tortoisehg/hgqt/fileview.py
-+++ b/tortoisehg/hgqt/fileview.py
-@@ -299,10 +299,6 @@ class HgFileView(QFrame):
-         if self._effectiveMode() == DiffMode:
-             self._changeEffectiveMode(DiffMode)
- 
--    def updateChunk(self, chunk, exclude):
--        'change chunk exclusion state, update display when necessary'
--        self._chunkSelectionViewControl.updateChunk(chunk, exclude)
--
-     @pyqtSlot(QAction)
-     def _setModeByAction(self, action):
-         'One of the mode toolbar buttons has been toggled'
-@@ -1330,10 +1326,6 @@ class _ChunkSelectionViewControl(_Abstra
-             self._chunkatline[chunk.lineno] = chunk
-             self._updateMarker(chunk)
- 
--    def updateChunk(self, chunk, exclude):
--        self._fd.setChunkExcluded(chunk, exclude)
--        self._updateMarker(chunk)
--
-     def _updateMarker(self, chunk):
-         excludemsg = ' ' + _('(excluded from the next commit)')
-         # markerAdd() does not check if the specified marker is already
-@@ -1404,7 +1396,9 @@ class _ChunkSelectionViewControl(_Abstra
- 
-     def _setChunkAtLines(self, lines, excluded):
-         for l in lines:
--            self.updateChunk(self._chunkatline[l], excluded)
-+            chunk = self._chunkatline[l]
-+            self._fd.setChunkExcluded(chunk, excluded)
-+            self._updateMarker(chunk)
-         self.chunkSelectionChanged.emit()
- 
-     def _toggleChunkAtLine(self, line):
-fv-chunkmsplit.diff
-fv-chunkmarkupdatable.diff
-fv-preservechunksel.diff
-fv-displayloaded.diff
-fv-chunkselkeepfd.diff
-fd-chunkexcmeth.diff
-st-chunkupdate.diff
-st-chunkredisplay.diff
-fv-updatechunkpriv.diff
 fv-updatechunktrace.diff
 fv-chunkexcltrace.diff
 graphdele-invalidate.diff

st-chunkredisplay.diff

-# HG changeset patch
-# Date 1390040710 -32400
-# Parent 953e1c0a14068043716eca28b93014996bab33f1
-status: redisplay file content if partial selection is invalided
-
-fileview.updateChunk() is no longer needed.  Its function is superseded by
-fd.setChunkExcluded().
-
-diff --git a/tortoisehg/hgqt/status.py b/tortoisehg/hgqt/status.py
---- a/tortoisehg/hgqt/status.py
-+++ b/tortoisehg/hgqt/status.py
-@@ -479,11 +479,9 @@ class StatusWidget(QWidget):
-         'user has toggled a checkbox, update partial chunk selection status'
-         wfile = hglib.fromunicode(wfile)
-         if wfile in self.partials:
-+            del self.partials[wfile]
-             if wfile == hglib.fromunicode(self.fileview.filePath()):
--                for chunk in self.partials[wfile].hunks:
--                    self.fileview.updateChunk(chunk, not checked)
--            else:
--                del self.partials[wfile]
-+                self.onCurrentChange(self.tv.currentIndex())
- 
-     def checkAll(self):
-         model = self.tv.model()
-@@ -534,8 +532,8 @@ class StatusWidget(QWidget):
-         self.actions.updateActionSensitivity(selrows)
- 
-     # Disabled decorator because of bug in older PyQt releases
--    #@pyqtSlot(QModelIndex, QModelIndex)
--    def onCurrentChange(self, index, old):
-+    #@pyqtSlot(QModelIndex)
-+    def onCurrentChange(self, index):
-         'Connected to treeview "currentChanged" signal'
-         row = index.model().getRow(index)
-         if row is None:

st-chunkupdate.diff

-# HG changeset patch
-# Date 1390040576 -32400
-# Parent 7f090a153322becd3b58a4d55194fe466f7d5dbb
-status: preload file data to merge chunk selection prior to displaying it
-
-newChunkList signal is no longer necessary because StatusWidget loads chunks
-by itself.  This also means partial selections are now preserved between mode
-changes.
-
-diff --git a/tortoisehg/hgqt/fileview.py b/tortoisehg/hgqt/fileview.py
---- a/tortoisehg/hgqt/fileview.py
-+++ b/tortoisehg/hgqt/fileview.py
-@@ -51,7 +51,6 @@ class HgFileView(QFrame):
-     showMessage = pyqtSignal(QString)
-     revisionSelected = pyqtSignal(int)
-     shelveToolExited = pyqtSignal()
--    newChunkList = pyqtSignal(QString, object)
-     chunkSelectionChanged = pyqtSignal()
- 
-     grepRequested = pyqtSignal(unicode, dict)
-@@ -514,11 +513,6 @@ class HgFileView(QFrame):
-         for c in self._activeViewControls:
-             c.display(fd)
- 
--        if self._effectiveMode() == DiffMode and fd.isValid():
--            self.newChunkList.emit(fd.filePath(), fd.changes)
--        else:
--            self.newChunkList.emit(fd.filePath(), None)
--
-         self.highlightText(*self._lastSearch)
-         self.fileDisplayed.emit(fd.filePath(), fd.fileText())
- 
-diff --git a/tortoisehg/hgqt/status.py b/tortoisehg/hgqt/status.py
---- a/tortoisehg/hgqt/status.py
-+++ b/tortoisehg/hgqt/status.py
-@@ -185,7 +185,6 @@ class StatusWidget(QWidget):
-         self.fileview.linkActivated.connect(self.linkActivated)
-         self.fileview.fileDisplayed.connect(self.fileDisplayed)
-         self.fileview.shelveToolExited.connect(self.refreshWctx)
--        self.fileview.newChunkList.connect(self.updatePartials)
-         self.fileview.chunkSelectionChanged.connect(self.chunkSelectionChanged)
-         self.fileview.grepRequested.connect(self.grepRequested)
-         self.fileview.setMinimumSize(QSize(16, 16))
-@@ -240,8 +239,7 @@ class StatusWidget(QWidget):
-         self.fileview.saveSettings(qs, prefix+'/fileview')
-         qs.setValue(prefix+'/state', self.split.saveState())
- 
--    @pyqtSlot(QString, object)
--    def updatePartials(self, wfile, changes):
-+    def _updatePartials(self, fd):
-         # remove files from the partials dictionary if they are not partial
-         # selections, in order to simplify refresh.
-         dels = []
-@@ -256,7 +254,8 @@ class StatusWidget(QWidget):
-         for file in dels:
-             del self.partials[file]
- 
--        wfile = hglib.fromunicode(wfile)
-+        wfile = hglib.fromunicode(fd.filePath())
-+        changes = fd.changes
-         if changes is None:
-             if wfile in self.partials:
-                 del self.partials[wfile]
-@@ -269,14 +268,14 @@ class StatusWidget(QWidget):
-             oldstates = dict([(c.fromline, c.excluded) for c in oldhunks])
-             for chunk in changes.hunks:
-                 if chunk.fromline in oldstates:
--                    self.fileview.updateChunk(chunk, oldstates[chunk.fromline])
-+                    fd.setChunkExcluded(chunk, oldstates[chunk.fromline])
-         else:
-             # the file was not in the partials dictionary, so it is either
-             # checked (all changes enabled) or unchecked (all changes
-             # excluded).
-             if wfile not in self.getChecked():
-                 for chunk in changes.hunks:
--                    self.fileview.updateChunk(chunk, True)
-+                    fd.setChunkExcluded(chunk, True)
-         self.chunkSelectionChanged()
-         self.partials[wfile] = changes
- 
-@@ -549,6 +548,10 @@ class StatusWidget(QWidget):
-             fd = filedata.createSubrepoData(ctx, pctx, wfile)
-         else:
-             fd = filedata.createFileData(ctx, pctx, wfile, status)
-+        changeselect = self.fileview.isChangeSelectionEnabled()
-+        fd.load(changeselect)
-+        if changeselect and status != 'S':
-+            self._updatePartials(fd)
-         self.fileview.display(fd)
- 
-