Hello, Bastian!

My fix to above problem caused another problem :)
All files now treats as UTF-8, but it's not correct behavior for me.
So, I still need mercurial messages in non-UTF8 encoding. My quick fix
for it is here. Main idea is to get encoding from HGENCODING
environment variable. It just works for me. If it's good enought, may
be you include this patch to MercrurialEclipse project. I don't have
any experience in java, so, it may be buggy fix.

Thank you for your work.

cat fix_for_log_encoding.patch

diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF
old mode 100644
new mode 100755
diff --git a/src/com/vectrace/MercurialEclipse/commands/
AbstractParseChangesetClient.java b/src/com/vectrace/MercurialEclipse/
commands/AbstractParseChangesetClient.java
old mode 100644
new mode 100755
--- a/src/com/vectrace/MercurialEclipse/commands/
AbstractParseChangesetClient.java
+++ b/src/com/vectrace/MercurialEclipse/commands/
AbstractParseChangesetClient.java
@@ -445,7 +445,7 @@
             reader.setContentHandler(getHandler(res, direction,
repository,
                     bundleFile, hgRoot, fileRevisions));
             reader.parse(new InputSource(new
ByteArrayInputStream(myInput
-                    .getBytes())));
+                    .getBytes("UTF8"))));
         } catch (Exception e) {
             String nextTry = cleanControlChars(myInput);
             try {
@@ -453,7 +453,7 @@
                 reader.setContentHandler(getHandler(res, direction,
repository,
                         bundleFile, hgRoot, fileRevisions));
                 reader.parse(new InputSource(new
ByteArrayInputStream(nextTry
-                        .getBytes())));
+                        .getBytes("UTF8"))));
             } catch (Exception e1) {
                 throw new HgException(e1.getLocalizedMessage(), e);
             }
diff --git a/src/com/vectrace/MercurialEclipse/commands/
AbstractShellCommand.java b/src/com/vectrace/MercurialEclipse/commands/
AbstractShellCommand.java
old mode 100644
new mode 100755
--- a/src/com/vectrace/MercurialEclipse/commands/
AbstractShellCommand.java
+++ b/src/com/vectrace/MercurialEclipse/commands/
AbstractShellCommand.java
@@ -15,6 +15,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -23,6 +24,7 @@

 import org.eclipse.core.resources.IResource;

+import com.vectrace.MercurialEclipse.MercurialEclipsePlugin;
 import com.vectrace.MercurialEclipse.exception.HgException;
 import
com.vectrace.MercurialEclipse.preferences.MercurialPreferenceConstants;

@@ -138,7 +140,9 @@
         try {
             List<String> cmd = getCommands();
             String cmdString = cmd.toString().replace(",",
"").substring(1);
+            String encoding = System.getenv("HGENCODING");
             cmdString = cmdString.substring(0, cmdString.length() -
1);
+

             ProcessBuilder builder = new ProcessBuilder(cmd);

@@ -162,11 +166,17 @@
             consumer.join(timeout); // 30 seconds timeout
             if (!consumer.isAlive()) {
                 int exitCode = process.waitFor();
+                String msg;
                 returnValue = consumer.getBytes();
-                String msg = new String(returnValue);
+                try {
+                    msg = new String(returnValue, encoding);
+                } catch (UnsupportedEncodingException e) {
+                    MercurialEclipsePlugin.logError(e);
+                    msg = "";
+                }
                 // everything fine
                 if (exitCode == 0 || !expectPositiveReturnValue) {
-                    getConsole().commandCompleted(0, new
String(returnValue),
+                    getConsole().commandCompleted(0, new
String(returnValue, encoding),
                             null);
                     if (isDebugMode()) {
                         getConsole().printMessage(msg, null);
@@ -177,7 +187,7 @@
                 // exit code > 0
                 HgException hgex = new HgException(
                         "Process error, return code: " + exitCode
-                                + ", message: " + new
String(returnValue));
+                                + ", message: " + new
String(returnValue, encoding));

                 // exit code == 1 usually isn't fatal.
                 getConsole().commandCompleted(exitCode, msg, hgex);
@@ -187,7 +197,7 @@
             returnValue = consumer.getBytes();
             HgException hgEx = new HgException("Process timeout");
             if (returnValue != null) {
-                getConsole().printError(new String(returnValue),
hgEx);
+                getConsole().printError(new String(returnValue,
encoding), hgEx);
             } else {
                 getConsole().printError(hgEx.getMessage(), hgEx);
             }
@@ -215,10 +225,16 @@

     public String executeToString() throws HgException {
         byte[] bytes = executeToBytes();
+        String ret_string = "";
         if (bytes != null) {
-            return new String(bytes);
+            try {
+             ret_string = new String(bytes,
System.getenv("HGENCODING"));
+            } catch (UnsupportedEncodingException e) {
+                MercurialEclipsePlugin.logError(e);
+                ret_string = "";
+            }
         }
-        return "";
+        return ret_string;
     }

     protected List<String> getCommands() {



On 2 окт, 18:15, Bastian Doetsch <[EMAIL PROTECTED]> wrote:
> We should probably offer an option to set the locale of a repository
> which would then be used when parsing the log xml. Glad, you could solve
> your problem!
>
> Bastian
>
> On Do, 2008-10-02 at 15:58 +0600, Aleksandr wrote:
>
> > I've found a cause fo the problem. This was not exaclty what I wrote.
> > The problem was in chracters encoding. When history log contained some
> > cyrillic commit messages, history was not displayed.
>
> > I've added
> >   -Dfile.encoding=UTF-8
> > in eclipse.ini
>
> > and changed env. variable HGENCODING:
> > HGENCODING=utf8
>
> > Now i have correct history view and console messages.
>
> > On Thu, Oct 2, 2008 at 1:25 PM, Alexander Kuzentsov <[EMAIL PROTECTED]> 
> > wrote:
> > > I've upgraded MercurialEclipse to this new release 1.1.867 (from
> > > previous release), and found a problem.
>
> > > When I choose "Team" -> "Show History" for any directory (not a file),
> > > history window is not show any history, it's clear. But, for any file
> > > from the same project, history view works fine, as it worked in
> > > previous release.
>
> > > My system is: Windows XP SP2, Eclipse Version: 3.4.0, Mercurial
> > > version 1.0.2
>
> > > In Mercurial console log:
> > > 1) For a file
> > > log call (success)
> > > C:\Utils\Mercurial\hg.exe log --debug --style S:\work\src\.metadata
> > > \.plugins\com.vectrace.MercurialEclipse\log_style -l 500 -f S:\work\src
> > > \stream-complete-current\.hgignore
>
> > > then glog call (success)
> > > C:\Utils\Mercurial\hg.exe glog --config extensions.graphlog= --
> > > template *{rev}
>
> > > 2) For a directory
> > > log call (success)
> > > C:\Utils\Mercurial\hg.exe log --debug --style S:\work\src\.metadata
> > > \.plugins\com.vectrace.MercurialEclipse\log_style -l 500 S:\work\src
> > > \stream-complete-current\include
>
> > > If it's known problem, then there may be some workaround to solve it?
>
> > > --
> > > WBR,
> > > Alexander
>
>
>
>  signature.asc
> < 1KViewDownload

--
WBR,
Alexander

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MercurialEclipse" group.
To post to this group, send email to mercurialeclipse@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mercurialeclipse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to