Fixed the treatment of the Mercurial version number.

Thu, 01 Sep 2011 09:25:05 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 01 Sep 2011 09:25:05 +0200
changeset 1263
1b6054a9b668
parent 1262
3a359afecc10
child 1264
da42fd833a66

Fixed the treatment of the Mercurial version number.

Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/HgLogDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/HgStatusMonitorThread.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/hg.py file | annotate | diff | comparison | revisions
--- a/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Thu Sep 01 09:11:23 2011 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Thu Sep 01 09:25:05 2011 +0200
@@ -126,7 +126,7 @@
         
         self.logTree.setIconSize(
             QSize(100 * self.__rowHeight, self.__rowHeight))
-        if self.vcs.versionStr >= "1.8":
+        if self.vcs.version >= (1, 8):
             self.logTree.headerItem().setText(self.logTree.columnCount(),
                 self.trUtf8("Bookmarks"))
     
@@ -635,7 +635,7 @@
         if self.commandMode == "log":
             args.append('--copies')
         args.append('--style')
-        if self.vcs.versionStr >= "1.8":
+        if self.vcs.version >= (1, 8):
             args.append(os.path.join(os.path.dirname(__file__),
                                      "styles", "logBrowserBookmark.style"))
         else:
--- a/Plugins/VcsPlugins/vcsMercurial/HgLogDialog.py	Thu Sep 01 09:11:23 2011 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgLogDialog.py	Thu Sep 01 09:25:05 2011 +0200
@@ -130,7 +130,7 @@
         if self.mode == "log":
             args.append('--copies')
         args.append('--style')
-        if self.vcs.versionStr >= "1.8":
+        if self.vcs.version >= (1, 8):
             args.append(os.path.join(os.path.dirname(__file__),
                                      "styles", "logDialogBookmark.style"))
         else:
--- a/Plugins/VcsPlugins/vcsMercurial/HgStatusMonitorThread.py	Thu Sep 01 09:11:23 2011 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgStatusMonitorThread.py	Thu Sep 01 09:25:05 2011 +0200
@@ -59,7 +59,7 @@
         self.shouldUpdate = False
         
         if self.__client is None and not self.__useCommandLine:
-            if self.vcs.versionStr >= "1.9.3":
+            if self.vcs.version >= (1, 9, 3):
                 # versions below that have a bug causing a second
                 # to not recognize changes to the status
                 client = HgClient(self.projectDir, "utf-8")
--- a/Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py	Thu Sep 01 09:11:23 2011 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py	Thu Sep 01 09:25:05 2011 +0200
@@ -934,7 +934,7 @@
         menu.addAction(self.vcsTagAct)
         menu.addAction(self.hgTagListAct)
         menu.addAction(self.hgBranchAct)
-        if self.vcs.versionStr >= '1.6.0':
+        if self.vcs.version >= (1, 6):
             menu.addAction(self.hgPushBranchAct)
         menu.addAction(self.hgCloseBranchAct)
         menu.addAction(self.hgBranchListAct)
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py	Thu Sep 01 09:11:23 2011 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/hg.py	Thu Sep 01 09:25:05 2011 +0200
@@ -9,6 +9,7 @@
 
 import os
 import shutil
+import re
 import urllib.request
 import urllib.parse
 import urllib.error
@@ -223,6 +224,16 @@
                 output = \
                     str(process.readAllStandardOutput(), ioEncoding, 'replace')
                 self.versionStr = output.splitlines()[0].split()[-1][0:-1]
+                v = list(re.match(r'.*?(\d+)\.(\d+)\.?(\d+)?(\+[0-9a-f-]+)?',
+                                  self.versionStr).groups())
+                for i in range(3):
+                    try:
+                        v[i] = int(v[i])
+                    except TypeError:
+                        v[i] = 0
+                    except IndexError:
+                        v.append(0)
+                self.version = tuple(v)
                 self.__getExtensionsInfo()
                 return True, errMsg
             else:
@@ -2396,7 +2407,7 @@
                 extensionName = line.split("=", 1)[0].strip().split(".")[-1].strip()
                 self.__activeExtensions.append(extensionName)
         
-        if self.versionStr >= "1.8":
+        if self.version >= (1, 8):
             if "bookmarks" not in self.__activeExtensions:
                 self.__activeExtensions.append("bookmarks")
         
@@ -2448,7 +2459,7 @@
         self.__projectHelper.setObjects(self, project)
         self.__monitorRepoIniFile(project.getProjectPath())
         
-        if self.versionStr >= "1.9":
+        if self.version >= (1, 9):
             client = HgClient(project.getProjectPath(), "utf-8", self)
             ok, err = client.startServer()
             if ok:

eric ide

mercurial