Fixed an 'invalid' error message caused by the code trying to get the parents for revision 0. 5_3_x

Sun, 14 Apr 2013 13:12:53 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 14 Apr 2013 13:12:53 +0200
branch
5_3_x
changeset 2582
d56b8f649745
parent 2568
b66f1577c6b9
child 2584
70d6fecbccf0

Fixed an 'invalid' error message caused by the code trying to get the parents for revision 0.
(grafted from a3498dcc75ccb7a2837d9a093c0104b959772c50)

Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/HgLogDialog.py file | annotate | diff | comparison | revisions
--- a/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Sat Apr 13 13:06:39 2013 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py	Sun Apr 14 13:12:53 2013 +0200
@@ -372,51 +372,52 @@
         errMsg = ""
         parents = [-1]
         
-        args = []
-        args.append("parents")
-        if self.commandMode == "incoming":
-            if self.bundle:
-                args.append("--repository")
-                args.append(self.bundle)
-            elif self.vcs.bundleFile and os.path.exists(self.vcs.bundleFile):
-                args.append("--repository")
-                args.append(self.vcs.bundleFile)
-        args.append("--template")
-        args.append("{rev}\n")
-        args.append("-r")
-        args.append(rev)
-        if not self.projectMode:
-            args.append(self.filename)
-        
-        output = ""
-        if self.__hgClient:
-            output, errMsg = self.__hgClient.runcommand(args)
-        else:
-            process = QProcess()
-            process.setWorkingDirectory(self.repodir)
-            process.start('hg', args)
-            procStarted = process.waitForStarted()
-            if procStarted:
-                finished = process.waitForFinished(30000)
-                if finished and process.exitCode() == 0:
-                    output = \
-                        str(process.readAllStandardOutput(),
-                            Preferences.getSystem("IOEncoding"),
-                            'replace')
+        if int(rev) > 0:
+            args = []
+            args.append("parents")
+            if self.commandMode == "incoming":
+                if self.bundle:
+                    args.append("--repository")
+                    args.append(self.bundle)
+                elif self.vcs.bundleFile and os.path.exists(self.vcs.bundleFile):
+                    args.append("--repository")
+                    args.append(self.vcs.bundleFile)
+            args.append("--template")
+            args.append("{rev}\n")
+            args.append("-r")
+            args.append(rev)
+            if not self.projectMode:
+                args.append(self.filename)
+            
+            output = ""
+            if self.__hgClient:
+                output, errMsg = self.__hgClient.runcommand(args)
+            else:
+                process = QProcess()
+                process.setWorkingDirectory(self.repodir)
+                process.start('hg', args)
+                procStarted = process.waitForStarted()
+                if procStarted:
+                    finished = process.waitForFinished(30000)
+                    if finished and process.exitCode() == 0:
+                        output = \
+                            str(process.readAllStandardOutput(),
+                                Preferences.getSystem("IOEncoding"),
+                                'replace')
+                    else:
+                        if not finished:
+                            errMsg = self.trUtf8(
+                                "The hg process did not finish within 30s.")
                 else:
-                    if not finished:
-                        errMsg = self.trUtf8(
-                            "The hg process did not finish within 30s.")
-            else:
-                errMsg = self.trUtf8("Could not start the hg executable.")
-        
-        if errMsg:
-            E5MessageBox.critical(self,
-                self.trUtf8("Mercurial Error"),
-                errMsg)
-        
-        if output:
-            parents = [int(p) for p in output.strip().splitlines()]
+                    errMsg = self.trUtf8("Could not start the hg executable.")
+            
+            if errMsg:
+                E5MessageBox.critical(self,
+                    self.trUtf8("Mercurial Error"),
+                    errMsg)
+            
+            if output:
+                parents = [int(p) for p in output.strip().splitlines()]
         
         return parents
     
--- a/Plugins/VcsPlugins/vcsMercurial/HgLogDialog.py	Sat Apr 13 13:06:39 2013 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgLogDialog.py	Sun Apr 14 13:12:53 2013 +0200
@@ -200,50 +200,52 @@
         errMsg = ""
         parents = []
         
-        args = []
-        args.append("parents")
-        if self.mode == "incoming":
-            if self.bundle:
-                args.append("--repository")
-                args.append(self.bundle)
-            elif self.vcs.bundleFile and os.path.exists(self.vcs.bundleFile):
-                args.append("--repository")
-                args.append(self.vcs.bundleFile)
-        args.append("--template")
-        args.append("{rev}:{node|short}\n")
-        args.append("-r")
-        args.append(rev)
-        if not self.projectMode:
-            args.append(self.filename)
-        
-        output = ""
-        if self.__hgClient:
-            output, errMsg = self.__hgClient.runcommand(args)
-        else:
-            process = QProcess()
-            process.setWorkingDirectory(self.repodir)
-            process.start('hg', args)
-            procStarted = process.waitForStarted()
-            if procStarted:
-                finished = process.waitForFinished(30000)
-                if finished and process.exitCode() == 0:
-                    output = \
-                        str(process.readAllStandardOutput(),
-                            Preferences.getSystem("IOEncoding"),
-                            'replace')
+        if int(rev) > 0:
+            args = []
+            args.append("parents")
+            if self.mode == "incoming":
+                if self.bundle:
+                    args.append("--repository")
+                    args.append(self.bundle)
+                elif self.vcs.bundleFile and os.path.exists(self.vcs.bundleFile):
+                    args.append("--repository")
+                    args.append(self.vcs.bundleFile)
+            args.append("--template")
+            args.append("{rev}:{node|short}\n")
+            args.append("-r")
+            args.append(rev)
+            if not self.projectMode:
+                args.append(self.filename)
+            
+            output = ""
+            if self.__hgClient:
+                output, errMsg = self.__hgClient.runcommand(args)
+            else:
+                process = QProcess()
+                process.setWorkingDirectory(self.repodir)
+                process.start('hg', args)
+                procStarted = process.waitForStarted()
+                if procStarted:
+                    finished = process.waitForFinished(30000)
+                    if finished and process.exitCode() == 0:
+                        output = \
+                            str(process.readAllStandardOutput(),
+                                Preferences.getSystem("IOEncoding"),
+                                'replace')
+                    else:
+                        if not finished:
+                            errMsg = self.trUtf8(
+                                "The hg process did not finish within 30s.")
                 else:
-                    if not finished:
-                        errMsg = self.trUtf8("The hg process did not finish within 30s.")
-            else:
-                errMsg = self.trUtf8("Could not start the hg executable.")
-        
-        if errMsg:
-            E5MessageBox.critical(self,
-                self.trUtf8("Mercurial Error"),
-                errMsg)
-        
-        if output:
-            parents = [p for p in output.strip().splitlines()]
+                    errMsg = self.trUtf8("Could not start the hg executable.")
+            
+            if errMsg:
+                E5MessageBox.critical(self,
+                    self.trUtf8("Mercurial Error"),
+                    errMsg)
+            
+            if output:
+                parents = [p for p in output.strip().splitlines()]
         
         return parents
     

eric ide

mercurial