[PATCH] Fix issue on Windows with file merge on repo with extended char in path

Rémy Roy remyroy at remyroy.com
Wed Jul 30 22:56:42 CDT 2008


Hello,

Here is my new patch for the same problem. It has been tested to work 
properly on my system.

# HG changeset patch
# User Remy Roy <remyroy at remyroy.com>
# Date 1217476285 14400
# Node ID 5f2ebb28cdcf901b0abf5f8b0d734d8c9599f020
# Parent  cbdfd08eabc96116d801d0e2e7d1856adfdde911
Fix issue on Windows with file merge on repo with extended char in path

On Windows, if you try a file merge on a repository that contains an
extended character (out of ascii range), you migth get an UnicodeDecodeError
exception because of an unexpected implicit unicode convertion if your merge
tool is part of the registry lookup keys.

This patch is a fix for issue 1126.

diff -r cbdfd08eabc9 -r 5f2ebb28cdcf mercurial/filemerge.py
--- a/mercurial/filemerge.py    Tue Jul 22 13:03:31 2008 -0500
+++ b/mercurial/filemerge.py    Wed Jul 30 23:51:25 2008 -0400
@@ -22,6 +22,8 @@
     if k:
         p = util.lookup_reg(k, _toolstr(ui, tool, "regname"))
         if p:
+            if isinstance(p, unicode):
+                p = util.tolocal(p.encode('UTF-8'))
             p = util.find_exe(p + _toolstr(ui, tool, "regappend"))
             if p:
                 return p


Matt Mackall a écrit :
> On Wed, 2008-07-30 at 12:56 -0400, Rémy Roy wrote:
>> # HG changeset patch
>> # User Remy Roy <remyroy at remyroy.com>
>> # Date 1217436000 14400
>> # Node ID d8fcda0fe5b64aa6ba02dab8584cad11f33b0cf2
>> # Parent  cbdfd08eabc96116d801d0e2e7d1856adfdde911
>> Fix issue on Windows with file merge on repo with extended char in path
>>
>> On Windows, if you try a file merge on a repository that contains an 
>> extended
>> character (out of ascii range), you will get an UnicodeDecodeError exception
>> because of an unexpected implicit unicode convertion. This patch catch the
>> exception and fix the charset convertion to make it work on Windows.
>>
>> This patch is a fix for issue 1126.
>
> Where does the Unicode string come from? It's best to trace such
> infections to their source otherwise they're liable to fatally infect
> other innocent strings. If it comes from our registry-querying code, we
> should do util.tolocal there instead.
>
>> diff -r cbdfd08eabc9 -r d8fcda0fe5b6 mercurial/filemerge.py
>> --- a/mercurial/filemerge.py    Tue Jul 22 13:03:31 2008 -0500
>> +++ b/mercurial/filemerge.py    Wed Jul 30 12:40:00 2008 -0400
>> @@ -192,7 +192,13 @@
>>          replace = dict(local=a, base=b, other=c, output=out)
>>          args = re.sub("\$(local|base|other|output)",
>>                        lambda x: '"%s"' % replace[x.group()[1:]], args)
>> -        r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env)
>> +        try:
>> +            cmd = toolpath + ' ' + args
>> +        except UnicodeDecodeError:
>> +            cmd = util.tolocal(toolpath.encode('UTF-8') +
>> +                               ' '.encode('UTF-8') +
>> +                               util.fromlocal(args))
>> +        r = util.system(cmd, cwd=repo.root, environ=env)
>>  
>>      if not r and _toolbool(ui, tool, "checkconflicts"):
>>          if re.match("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data()):
>>
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list