Fixed the Mercurial command server client handling large data chunks on slow machines.

Fri, 18 Apr 2014 15:07:48 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 18 Apr 2014 15:07:48 +0200
changeset 3518
1d681235c1b4
parent 3516
4992e89def32
child 3521
7d17803aab56

Fixed the Mercurial command server client handling large data chunks on slow machines.

Plugins/VcsPlugins/vcsMercurial/HgClient.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/HgLogDialog.py file | annotate | diff | comparison | revisions
--- a/Plugins/VcsPlugins/vcsMercurial/HgClient.py	Thu Apr 17 18:22:56 2014 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgClient.py	Fri Apr 18 15:07:48 2014 +0200
@@ -175,24 +175,22 @@
         @return tuple of channel designator and channel data
             (string, integer or string or bytes)
         """
-        additionalData = b""
-        
         if self.__server.bytesAvailable() > 0 or \
            self.__server.waitForReadyRead(10000):
-            while bytes(self.__server.peek(1)) not in HgClient.Channels:
-                additionalData += bytes(self.__server.read(1))
-            if additionalData:
-                return ("o", str(additionalData, self.__encoding, "replace"))
-            
-            data = bytes(self.__server.read(HgClient.OutputFormatSize))
-            if not data:
+            data = bytes(self.__server.peek(HgClient.OutputFormatSize))
+            if not data or len(data) < HgClient.OutputFormatSize:
                 return "", ""
             
             channel, length = struct.unpack(HgClient.OutputFormat, data)
             channel = channel.decode(self.__encoding)
             if channel in "IL":
+                self.__server.read(HgClient.OutputFormatSize)
                 return channel, length
             else:
+                if self.__server.bytesAvailable() < \
+                        HgClient.OutputFormatSize + length:
+                    return "", ""
+                self.__server.read(HgClient.OutputFormatSize)
                 data = self.__server.read(length)
                 if channel == "r":
                     return (channel, data)
@@ -271,7 +269,7 @@
                 raise RuntimeError(
                     "Unexpected but required channel '{0}'.".format(channel))
             
-            # optional channels
+            # optional channels or no channel at all
             else:
                 pass
     
--- a/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Thu Apr 17 18:22:56 2014 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Fri Apr 18 15:07:48 2014 +0200
@@ -19,8 +19,6 @@
 from E5Gui.E5Application import e5App
 from E5Gui import E5MessageBox
 
-from Globals import isWindowsPlatform
-
 from .Ui_HgLogBrowserDialog import Ui_HgLogBrowserDialog
 
 import UI.PixmapCache
@@ -87,10 +85,7 @@
         else:
             self.commandMode = "log"
             self.initialCommandMode = "log"
-        if isWindowsPlatform():
-            self.__hgClient = None
-        else:
-            self.__hgClient = vcs.getClient()
+        self.__hgClient = vcs.getClient()
         
         self.__bundle = ""
         self.__filename = ""
--- a/Plugins/VcsPlugins/vcsMercurial/HgLogDialog.py	Thu Apr 17 18:22:56 2014 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgLogDialog.py	Fri Apr 18 15:07:48 2014 +0200
@@ -16,8 +16,6 @@
 from E5Gui.E5Application import e5App
 from E5Gui import E5MessageBox
 
-from Globals import isWindowsPlatform
-
 from .Ui_HgLogDialog import Ui_HgLogDialog
 
 import Utilities
@@ -54,10 +52,7 @@
         else:
             self.mode = "log"
         self.bundle = bundle
-        if isWindowsPlatform():
-            self.__hgClient = None
-        else:
-            self.__hgClient = self.vcs.getClient()
+        self.__hgClient = self.vcs.getClient()
         
         self.contents.setHtml(
             self.tr('<b>Processing your request, please wait...</b>'))

eric ide

mercurial