Plugins/VcsPlugins/vcsMercurial/HgSummaryDialog.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3396
5320ecd70fdb
child 3591
2f2a4a76dd22
--- a/Plugins/VcsPlugins/vcsMercurial/HgSummaryDialog.py	Sun Mar 30 22:00:14 2014 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgSummaryDialog.py	Thu Apr 03 23:05:31 2014 +0200
@@ -10,8 +10,8 @@
 
 from __future__ import unicode_literals
 try:
-    str = unicode    # __IGNORE_WARNING__
-except (NameError):
+    str = unicode
+except NameError:
     pass
 
 import os
@@ -25,8 +25,6 @@
 
 from .Ui_HgSummaryDialog import Ui_HgSummaryDialog
 
-import Preferences
-
 
 class HgSummaryDialog(QDialog, Ui_HgSummaryDialog):
     """
@@ -44,9 +42,9 @@
         self.setupUi(self)
         
         self.refreshButton = self.buttonBox.addButton(
-            self.trUtf8("Refresh"), QDialogButtonBox.ActionRole)
+            self.tr("Refresh"), QDialogButtonBox.ActionRole)
         self.refreshButton.setToolTip(
-            self.trUtf8("Press to refresh the summary display"))
+            self.tr("Press to refresh the summary display"))
         self.refreshButton.setEnabled(False)
         
         self.process = None
@@ -67,23 +65,27 @@
         
         e.accept()
     
-    def start(self, path, mq=False):
+    def start(self, path, mq=False, largefiles=False):
         """
         Public slot to start the hg summary command.
         
         @param path path name of the working directory (string)
         @param mq flag indicating to show the queue status as well (boolean)
+        @param largefiles flag indicating to show the largefiles status as
+            well (boolean)
         """
         self.errorGroup.hide()
         self.__path = path
         self.__mq = mq
+        self.__largefiles = largefiles
         
-        args = []
-        args.append('summary')
-        self.vcs.addArguments(args, self.vcs.options['global'])
-        args.append("--remote")
+        args = self.vcs.initCommand("summary")
+        if self.vcs.canPull():
+            args.append("--remote")
         if self.__mq:
             args.append("--mq")
+        if self.__largefiles:
+            args.append("--large")
         
         # find the root of the repo
         repodir = self.__path
@@ -96,8 +98,7 @@
             self.process.kill()
         else:
             self.process = QProcess()
-            prepareProcess(self.process, Preferences.getSystem("IOEncoding"),
-                           "C")
+            prepareProcess(self.process, language="C")
             self.process.finished.connect(self.__procFinished)
             self.process.readyReadStandardOutput.connect(self.__readStdout)
             self.process.readyReadStandardError.connect(self.__readStderr)
@@ -111,8 +112,8 @@
         if not procStarted:
             E5MessageBox.critical(
                 self,
-                self.trUtf8('Process Generation Error'),
-                self.trUtf8(
+                self.tr('Process Generation Error'),
+                self.tr(
                     'The process {0} could not be started. '
                     'Ensure, that it is in the search path.'
                 ).format('hg'))
@@ -163,10 +164,8 @@
             self.process.setReadChannel(QProcess.StandardOutput)
             
             while self.process.canReadLine():
-                line = str(
-                    self.process.readLine(),
-                    Preferences.getSystem("IOEncoding"),
-                    'replace')
+                line = str(self.process.readLine(), self.vcs.getEncoding(),
+                           'replace')
                 self.__buffer.append(line)
     
     def __readStderr(self):
@@ -178,8 +177,7 @@
         """
         if self.process is not None:
             s = str(self.process.readAllStandardError(),
-                    Preferences.getSystem("IOEncoding"),
-                    'replace')
+                    self.vcs.getEncoding(), 'replace')
             self.__showError(s)
     
     def __showError(self, out):
@@ -220,6 +218,8 @@
         # step 1: parse the output
         while output:
             line = output.pop(0)
+            if ':' not in line:
+                continue
             name, value = line.split(": ", 1)
             value = value.strip()
             
@@ -275,11 +275,11 @@
                 if value.endswith("(current)"):
                     value = ("@CURRENT@", 0, 0)
                 elif value.endswith("(update)"):
-                    value = ("@UPDATE@", value.split(" ", 1)[0], 0)
+                    value = ("@UPDATE@", int(value.split(" ", 1)[0]), 0)
                 elif value.endswith("(merge)"):
                     parts = value.split(", ")
-                    value = ("@MERGE@", parts[0].split(" ", 1)[0],
-                             parts[1].split(" ", 1)[0])
+                    value = ("@MERGE@", int(parts[0].split(" ", 1)[0]),
+                             int(parts[1].split(" ", 1)[0]))
                 else:
                     value = ("@UNKNOWN@", 0, 0)
             elif name == "remote":
@@ -310,6 +310,11 @@
                         elif category == "unapplied":
                             unapplied = int(count)
                     value = (applied, unapplied)
+            elif name == "largefiles":
+                if not value[0].isdigit():
+                    value = 0
+                else:
+                    value = int(value.split(None, 1)[0])
             else:
                 # ignore unknown entries
                 continue
@@ -324,32 +329,32 @@
                 pindex += 1
                 changeset = "{0}:{1}".format(rev, node)
                 if len(infoDict["parent"]) > 1:
-                    info.append(self.trUtf8(
+                    info.append(self.tr(
                         "<tr><td><b>Parent #{0}</b></td><td>{1}</td></tr>")
                         .format(pindex, changeset))
                 else:
-                    info.append(self.trUtf8(
+                    info.append(self.tr(
                         "<tr><td><b>Parent</b></td><td>{0}</td></tr>")
                         .format(changeset))
                 if tags:
-                    info.append(self.trUtf8(
+                    info.append(self.tr(
                         "<tr><td><b>Tags</b></td><td>{0}</td></tr>")
                         .format('<br/>'.join(tags.split())))
                 if message:
-                    info.append(self.trUtf8(
+                    info.append(self.tr(
                         "<tr><td><b>Commit Message</b></td><td>{0}</td></tr>")
                         .format(message))
                 if remarks:
                     rem = []
                     if "@EMPTY@" in remarks:
-                        rem.append(self.trUtf8("empty repository"))
+                        rem.append(self.tr("empty repository"))
                     if "@NO_REVISION@" in remarks:
-                        rem.append(self.trUtf8("no revision checked out"))
-                    info.append(self.trUtf8(
+                        rem.append(self.tr("no revision checked out"))
+                    info.append(self.tr(
                         "<tr><td><b>Remarks</b></td><td>{0}</td></tr>")
                         .format(", ".join(rem)))
             if "branch" in infoDict:
-                info.append(self.trUtf8(
+                info.append(self.tr(
                     "<tr><td><b>Branch</b></td><td>{0}</td></tr>")
                     .format(infoDict["branch"]))
             if "bookmarks" in infoDict:
@@ -357,105 +362,114 @@
                 for i in range(len(bookmarks)):
                     if bookmarks[i].startswith("*"):
                         bookmarks[i] = "<b>{0}</b>".format(bookmarks[i])
-                info.append(self.trUtf8(
+                info.append(self.tr(
                     "<tr><td><b>Bookmarks</b></td><td>{0}</td></tr>")
                     .format('<br/>'.join(bookmarks)))
             if "commit" in infoDict:
                 cinfo = []
                 for category, count in infoDict["commit"][0].items():
                     if category == "modified":
-                        cinfo.append(self.trUtf8("{0} modified").format(count))
+                        cinfo.append(self.tr("{0} modified").format(count))
                     elif category == "added":
-                        cinfo.append(self.trUtf8("{0} added").format(count))
+                        cinfo.append(self.tr("{0} added").format(count))
                     elif category == "removed":
-                        cinfo.append(self.trUtf8("{0} removed").format(count))
+                        cinfo.append(self.tr("{0} removed").format(count))
                     elif category == "renamed":
-                        cinfo.append(self.trUtf8("{0} renamed").format(count))
+                        cinfo.append(self.tr("{0} renamed").format(count))
                     elif category == "copied":
-                        cinfo.append(self.trUtf8("{0} copied").format(count))
+                        cinfo.append(self.tr("{0} copied").format(count))
                     elif category == "deleted":
-                        cinfo.append(self.trUtf8("{0} deleted").format(count))
+                        cinfo.append(self.tr("{0} deleted").format(count))
                     elif category == "unknown":
-                        cinfo.append(self.trUtf8("{0} unknown").format(count))
+                        cinfo.append(self.tr("{0} unknown").format(count))
                     elif category == "ignored":
-                        cinfo.append(self.trUtf8("{0} ignored").format(count))
+                        cinfo.append(self.tr("{0} ignored").format(count))
                     elif category == "unresolved":
                         cinfo.append(
-                            self.trUtf8("{0} unresolved").format(count))
+                            self.tr("{0} unresolved").format(count))
                     elif category == "subrepos":
-                        cinfo.append(self.trUtf8("{0} subrepos").format(count))
+                        cinfo.append(self.tr("{0} subrepos").format(count))
                 remark = infoDict["commit"][1]
                 if remark == "merge":
-                    cinfo.append(self.trUtf8("Merge needed"))
+                    cinfo.append(self.tr("Merge needed"))
                 elif remark == "new branch":
-                    cinfo.append(self.trUtf8("New Branch"))
+                    cinfo.append(self.tr("New Branch"))
                 elif remark == "head closed":
-                    cinfo.append(self.trUtf8("Head is closed"))
+                    cinfo.append(self.tr("Head is closed"))
                 elif remark == "clean":
-                    cinfo.append(self.trUtf8("No commit required"))
+                    cinfo.append(self.tr("No commit required"))
                 elif remark == "new branch head":
-                    cinfo.append(self.trUtf8("New Branch Head"))
-                info.append(self.trUtf8(
+                    cinfo.append(self.tr("New Branch Head"))
+                info.append(self.tr(
                     "<tr><td><b>Commit Status</b></td><td>{0}</td></tr>")
                     .format("<br/>".join(cinfo)))
             if "update" in infoDict:
                 if infoDict["update"][0] == "@CURRENT@":
-                    uinfo = self.trUtf8("current")
+                    uinfo = self.tr("current")
                 elif infoDict["update"][0] == "@UPDATE@":
-                    uinfo = self.trUtf8(
+                    uinfo = self.tr(
                         "%n new changeset(s)<br/>Update required", "",
                         infoDict["update"][1])
                 elif infoDict["update"][0] == "@MERGE@":
-                    uinfo1 = self.trUtf8(
+                    uinfo1 = self.tr(
                         "%n new changeset(s)", "", infoDict["update"][1])
-                    uinfo2 = self.trUtf8(
+                    uinfo2 = self.tr(
                         "%n branch head(s)", "", infoDict["update"][2])
-                    uinfo = self.trUtf8(
+                    uinfo = self.tr(
                         "{0}<br/>{1}<br/>Merge required",
                         "0 is changesets, 1 is branch heads")\
                         .format(uinfo1, uinfo2)
                 else:
-                    uinfo = self.trUtf8("unknown status")
-                info.append(self.trUtf8(
+                    uinfo = self.tr("unknown status")
+                info.append(self.tr(
                     "<tr><td><b>Update Status</b></td><td>{0}</td></tr>")
                     .format(uinfo))
             if "remote" in infoDict:
                 if infoDict["remote"] == (0, 0, 0, 0):
-                    rinfo = self.trUtf8("synched")
+                    rinfo = self.tr("synched")
                 else:
                     li = []
                     if infoDict["remote"][0]:
-                        li.append(self.trUtf8("1 or more incoming"))
+                        li.append(self.tr("1 or more incoming"))
                     if infoDict["remote"][1]:
-                        li.append(self.trUtf8("{0} outgoing")
+                        li.append(self.tr("{0} outgoing")
                                   .format(infoDict["remote"][1]))
                     if infoDict["remote"][2]:
-                        li.append(self.trUtf8("%n incoming bookmark(s)", "",
+                        li.append(self.tr("%n incoming bookmark(s)", "",
                                   infoDict["remote"][2]))
                     if infoDict["remote"][3]:
-                        li.append(self.trUtf8("%n outgoing bookmark(s)", "",
+                        li.append(self.tr("%n outgoing bookmark(s)", "",
                                   infoDict["remote"][3]))
                     rinfo = "<br/>".join(li)
-                info.append(self.trUtf8(
+                info.append(self.tr(
                     "<tr><td><b>Remote Status</b></td><td>{0}</td></tr>")
                     .format(rinfo))
             if "mq" in infoDict:
                 if infoDict["mq"] == (0, 0):
-                    qinfo = self.trUtf8("empty queue")
+                    qinfo = self.tr("empty queue")
                 else:
                     li = []
                     if infoDict["mq"][0]:
-                        li.append(self.trUtf8("{0} applied")
+                        li.append(self.tr("{0} applied")
                                   .format(infoDict["mq"][0]))
                     if infoDict["mq"][1]:
-                        li.append(self.trUtf8("{0} unapplied")
+                        li.append(self.tr("{0} unapplied")
                                   .format(infoDict["mq"][1]))
                     qinfo = "<br/>".join(li)
-                info.append(self.trUtf8(
+                info.append(self.tr(
                     "<tr><td><b>Queues Status</b></td><td>{0}</td></tr>")
                     .format(qinfo))
+            if "largefiles" in infoDict:
+                if infoDict["largefiles"] == 0:
+                    lfInfo = self.tr("No files to upload")
+                else:
+                    lfInfo = self.tr("%n file(s) to upload", "",
+                                     infoDict["largefiles"])
+                info.append(self.tr(
+                    "<tr><td><b>Large Files</b></td><td>{0}</td></tr>")
+                    .format(lfInfo))
             info.append("</table>")
         else:
-            info = [self.trUtf8("<p>No status information available.</p>")]
+            info = [self.tr("<p>No status information available.</p>")]
         
         self.summary.insertHtml("\n".join(info))

eric ide

mercurial