1. Yuya Nishihara
  2. thg-qt-mq

Source

thg-qt-mq / reporeg-cache-exp.diff

# HG changeset patch
# Parent 48ce38b4cb4f0f198cb25d56869c5a8f9c4d0141
address slow startup speed caused by subrepo scan (issue #940)

This patch shows a rough idea to avoid overhead of scanning subrepos at
startup.

https://bitbucket.org/tortoisehg/thg/issue/940/

It includes:

 - save subrepo items in thg-reporegistry.xml
 - reload subrepo items when user opens the repository
 - add option to scan all sub-repositories at startup (default: off),
   which is currently called as "Show Subrepos on Registry"

As you can see, this is an experimental patch and will introduce several
bugs. I'll start writing a production code in this direction.

diff --git a/tortoisehg/hgqt/reporegistry.py b/tortoisehg/hgqt/reporegistry.py
--- a/tortoisehg/hgqt/reporegistry.py
+++ b/tortoisehg/hgqt/reporegistry.py
@@ -401,6 +401,9 @@ class RepoRegistryView(QDockWidget):
         if it:
             self._activeTabRepo = it
             it.setActive(True)
+            # XXX missing begin/endInsertRows() may cause crash
+            if not it.childs:  # XXX should refresh subrepos instead
+                it.appendSubrepos()
             self.tview.dataChanged(QModelIndex(), QModelIndex())
 
             # Make sure that the active tab is visible by expanding its parent
diff --git a/tortoisehg/hgqt/repotreeitem.py b/tortoisehg/hgqt/repotreeitem.py
--- a/tortoisehg/hgqt/repotreeitem.py
+++ b/tortoisehg/hgqt/repotreeitem.py
@@ -248,6 +248,7 @@ class RepoItem(RepoTreeItem):
         xw.writeAttribute('root', hglib.tounicode(self._root))
         xw.writeAttribute('shortname', self.shortname())
         xw.writeAttribute('basenode', node.hex(self.basenode()))
+        RepoTreeItem.dump(self, xw)
 
     def undump(self, xr):
         self._valid = True
diff --git a/tortoisehg/hgqt/workbench.py b/tortoisehg/hgqt/workbench.py
--- a/tortoisehg/hgqt/workbench.py
+++ b/tortoisehg/hgqt/workbench.py
@@ -209,12 +209,12 @@ class Workbench(QMainWindow):
                   checkable=True, menu='viewregistryopts')
 
         self.actionShowSubrepos = \
-            newaction(_("Show Subrepos on Registry"),
+            newaction(_("Scan repositories at Startup"),
                 self.reporegistry.setShowSubrepos,
                   checkable=True, menu='viewregistryopts')
 
         self.actionShowNetworkSubrepos = \
-            newaction(_("Show Subrepos for remote repositories"),
+            newaction(_("Scan remote repositories"),
                 self.reporegistry.setShowNetworkSubrepos,
                   checkable=True, menu='viewregistryopts')
 
@@ -1055,9 +1055,9 @@ class Workbench(QMainWindow):
         # settings), we tell the setters to avoid reloading the repo tree
         # model, and then we  manually reload the model
         ssr = s.value(wb + 'showSubrepos',
-            defaultValue=QVariant(True)).toBool()
+            defaultValue=QVariant(False)).toBool()
         snsr = s.value(wb + 'showNetworkSubrepos',
-            defaultValue=QVariant(True)).toBool()
+            defaultValue=QVariant(False)).toBool()
         ssp = s.value(wb + 'showShortPaths',
             defaultValue=QVariant(True)).toBool()
         self.reporegistry.setShowSubrepos(ssr, False)