Source

thg-qt-mq / wb-delayload.diff

# HG changeset patch
# Parent c4b7eb3879484bf7acc1ab8a317aa87f8cb3df5c
workbench: postpone loading repos and reporegistry after window visible

It won't change the whole startup speed, but will make feel a bit fast.

diff --git a/tortoisehg/hgqt/filedialogs.py b/tortoisehg/hgqt/filedialogs.py
--- a/tortoisehg/hgqt/filedialogs.py
+++ b/tortoisehg/hgqt/filedialogs.py
@@ -69,8 +69,10 @@ class _AbstractFileDialog(QMainWindow):
             # prevent recursive import
             from workbench import Workbench
             self.repoviewer = Workbench()
+            self.repoviewer.show()
             self.repoviewer.launch()
-        self.repoviewer.show()
+        else:
+            self.repoviewer.show()
         self.repoviewer.activateWindow()
         self.repoviewer.raise_()
         self.repoviewer.showRepo(hglib.tounicode(self.repo.root))
diff --git a/tortoisehg/hgqt/workbench.py b/tortoisehg/hgqt/workbench.py
--- a/tortoisehg/hgqt/workbench.py
+++ b/tortoisehg/hgqt/workbench.py
@@ -1029,9 +1029,7 @@ class Workbench(QMainWindow):
         s = QSettings()
         wb = "Workbench/"
 
-        # Reload the all the repos that were open on the last session
-        # This may be a lengthy operation, which happens before the Workbench GUI is open
-        # We use a progress dialog to let the user know that the workbench is being loaded
+        # This may be a lengthy operation
         openreposvalue = unicode(s.value(wb + 'openrepos').toString())
         if openreposvalue:
             openrepos = openreposvalue.split(',')
@@ -1215,26 +1213,28 @@ def run(ui, *pats, **opts):
         mustcreateserver = not serverexists
 
     w = Workbench()
-    if mustcreateserver:
-        w.createWorkbenchServer()
-    w.launch()
-    if root:
-        root = hglib.tounicode(root)
-        bundle = opts.get('bundle')
-        if bundle:
-            w._openRepo(root, False, bundle=bundle)
-        else:
-            w.showRepo(root)
+    def init():
+        if mustcreateserver:
+            w.createWorkbenchServer()
+        w.launch()
+        if root:
+            uroot = hglib.tounicode(root)
+            bundle = opts.get('bundle')
+            if bundle:
+                w._openRepo(uroot, False, bundle=bundle)
+            else:
+                w.showRepo(uroot)
 
-        if pats:
-            q = []
-            for pat in pats:
-                f = repo.wjoin(pat)
-                if os.path.isdir(f):
-                    q.append('file("%s/**")' % pat)
-                elif os.path.isfile(f):
-                    q.append('file("%s")' % pat)
-            w.setRevsetFilter(root, ' or '.join(q))
-    if w.repoTabsWidget.count() <= 0:
-        w.reporegistry.setVisible(True)
+            if pats:
+                q = []
+                for pat in pats:
+                    f = repo.wjoin(pat)
+                    if os.path.isdir(f):
+                        q.append('file("%s/**")' % pat)
+                    elif os.path.isfile(f):
+                        q.append('file("%s")' % pat)
+                w.setRevsetFilter(uroot, ' or '.join(q))
+        if w.repoTabsWidget.count() <= 0:
+            w.reporegistry.setVisible(True)
+    QTimer.singleShot(0, init)  # after window visible
     return w